Blackbox device type 'file' (SITL) considered working when file handler is available
[inav.git] / src / main / drivers / display_widgets.h
blob9e7c536999a18e34f8f44ad493d571819496d7a9
1 #pragma once
3 #include <stdbool.h>
4 #include <stdint.h>
6 #include "drivers/osd.h"
8 typedef struct widgetRect_s {
9 int x;
10 int y;
11 unsigned w;
12 unsigned h;
13 } widgetRect_t;
15 typedef enum {
16 DISPLAY_WIDGET_TYPE_AHI,
17 DISPLAY_WIDGET_TYPE_SIDEBAR,
18 } displayWidgetType_e;
20 typedef enum {
21 DISPLAY_WIDGET_AHI_STYLE_STAIRCASE = 0,
22 DISPLAY_WIDGET_AHI_STYLE_LINE = 1,
23 } widgetAHIStyle_e;
25 typedef enum {
26 DISPLAY_WIDGET_AHI_OPTION_SHOW_CORNERS = 1 << 0,
27 } widgetAHIOptions_t;
29 typedef struct widgetAHIConfiguration_s {
30 widgetRect_t rect;
31 widgetAHIStyle_e style;
32 widgetAHIOptions_t options;
33 unsigned crosshairMargin;
34 unsigned strokeWidth;
35 } widgetAHIConfiguration_t;
37 typedef struct widgetAHIData_s {
38 float pitch; // radians
39 float roll; // radians
40 } widgetAHIData_t;
42 typedef enum
44 DISPLAY_WIDGET_SIDEBAR_OPTION_LEFT = 1 << 0, // Display the sidebar oriented to the left. Default is to the right
45 DISPLAY_WIDGET_SIDEBAR_OPTION_REVERSE = 1 << 1, // Reverse the sidebar direction, so positive values move it down
46 DISPLAY_WIDGET_SIDEBAR_OPTION_UNLABELED = 1 << 2, // Don't display the central label with the value.
47 DISPLAY_WIDGET_SIDEBAR_OPTION_STATIC = 1 << 3, // The sidebar doesn't scroll nor display values along it.
48 } widgetSidebarOptions_t;
50 typedef struct widgetSidebarConfiguration_s {
51 widgetRect_t rect;
52 widgetSidebarOptions_t options;
53 uint8_t divisions; // How many divisions the sidebar will have
54 uint16_t counts_per_step; // How much the value increases/decreases per division BEFORE applying the unit scale
55 osdUnit_t unit; // The unit used to display the values in the sidebar
56 } widgetSidebarConfiguration_t;
58 typedef struct displayWidgetsVTable_s displayWidgetsVTable_t;
60 typedef struct displayWidgets_s {
61 const displayWidgetsVTable_t *vTable;
62 void *device;
63 } displayWidgets_t;
65 typedef struct displayWidgetsVTable_s {
66 int (*supportedInstances)(displayWidgets_t *widgets, displayWidgetType_e widgetType);
67 bool (*configureAHI)(displayWidgets_t *widgets, unsigned instance, const widgetAHIConfiguration_t *config);
68 bool (*drawAHI)(displayWidgets_t *widgets, unsigned instance, const widgetAHIData_t *data);
69 bool (*configureSidebar)(displayWidgets_t *widgets, unsigned instance, const widgetSidebarConfiguration_t *config);
70 bool (*drawSidebar)(displayWidgets_t *widgets, unsigned instance, int32_t data);
71 } displayWidgetsVTable_t;
73 int displayWidgetsSupportedInstances(displayWidgets_t *widgets, displayWidgetType_e widgetType);
74 bool displayWidgetsConfigureAHI(displayWidgets_t *widgets, unsigned instance, const widgetAHIConfiguration_t *config);
75 bool displayWidgetsDrawAHI(displayWidgets_t *widgets, unsigned instance, const widgetAHIData_t *data);
76 bool displayWidgetsConfigureSidebar(displayWidgets_t *widgets, unsigned instance, const widgetSidebarConfiguration_t *config);
77 bool displayWidgetsDrawSidebar(displayWidgets_t *widgets, unsigned instance, int32_t data);