Auto updated submodule references [18-01-2025]
[betaflight.git] / src / main / cms / cms_types.h
blob2c61a8a415ebf3e1bdbb185a47de8d766cea3d6e
1 /*
2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
8 * any later version.
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
22 // Menu element types
23 // XXX Upon separation, all OME would be renamed to CME_ or similar.
26 #pragma once
28 //type of elements
30 typedef enum
32 OME_Label,
33 OME_Back,
34 OME_OSD_Exit,
35 OME_Submenu,
36 OME_Funcall,
37 OME_Bool,
38 OME_INT8,
39 OME_UINT8,
40 OME_UINT16,
41 OME_INT16,
42 OME_UINT32,
43 OME_INT32,
44 OME_String,
45 OME_FLOAT, //only up to 255 value and cant be 2.55 or 25.5, just for PID's
46 //wlasciwosci elementow
47 #ifdef USE_OSD
48 OME_VISIBLE,
49 #endif
50 OME_TAB,
51 OME_END,
53 // Debug aid
54 OME_MENU,
56 OME_MAX = OME_MENU
57 } OSD_MenuElement;
59 typedef const void *(*CMSEntryFuncPtr)(displayPort_t *displayPort, const void *ptr);
61 #ifdef __APPLE__
62 #define PTR_PACKING
63 #else
64 #define PTR_PACKING __attribute__((packed))
65 #endif
67 typedef struct
69 const char * text;
70 // Logical OR of OSD_MenuElement and flags below
71 uint16_t flags;
72 CMSEntryFuncPtr func;
73 void *data;
74 } PTR_PACKING OSD_Entry;
76 // Bits in flags
77 #define OSD_MENU_ELEMENT_MASK 0x001f
78 #define PRINT_VALUE 0x0020 // Value has been changed, need to redraw
79 #define PRINT_LABEL 0x0040 // Text label should be printed
80 #define DYNAMIC 0x0080 // Value should be updated dynamically
81 #define OPTSTRING 0x0100 // (Temporary) Flag for OME_Submenu, indicating func should be called to get a string to display.
82 #define REBOOT_REQUIRED 0x0200 // Reboot is required if the value is changed
83 #define SCROLLING_TICKER 0x0400 // Long values are displayed as horizontally scrolling tickers (OME_TAB only)
84 #define SLIDER_RP 0x0800 // Value should be read only if simplified RP slider is enabled
85 #define SLIDER_RPY 0x1000 // Value should be read only if simplified RPY slider is enabled
86 #define SLIDER_GYRO 0x2000 // Value should be read only if simplified gyro slider is enabled
87 #define SLIDER_DTERM 0x4000 // Value should be read only if simplified D term slider is enabled
89 #define IS_PRINTVALUE(x) ((x) & PRINT_VALUE)
90 #define SET_PRINTVALUE(x) do { (x) |= PRINT_VALUE; } while (0)
91 #define CLR_PRINTVALUE(x) do { (x) &= ~PRINT_VALUE; } while (0)
93 #define IS_PRINTLABEL(x) ((x) & PRINT_LABEL)
94 #define SET_PRINTLABEL(x) do { (x) |= PRINT_LABEL; } while (0)
95 #define CLR_PRINTLABEL(x) do { (x) &= ~PRINT_LABEL; } while (0)
97 #define IS_DYNAMIC(p) ((p)->flags & DYNAMIC)
99 #define IS_SCROLLINGTICKER(x) ((x) & SCROLLING_TICKER)
100 #define SET_SCROLLINGTICKER(x) do { (x) |= SCROLLING_TICKER; } while (0)
101 #define CLR_SCROLLINGTICKER(x) do { (x) &= ~SCROLLING_TICKER; } while (0)
103 typedef const void *(*CMSMenuFuncPtr)(displayPort_t *pDisp);
105 // Special return value(s) for function chaining by CMSMenuFuncPtr
106 extern int menuChainBack;
107 #define MENU_CHAIN_BACK (&menuChainBack) // Causes automatic cmsMenuBack
110 onExit function is called with self:
111 (1) Pointer to an OSD_Entry when cmsMenuBack() was called.
112 Point to an OSD_Entry with type == OME_Back if BACK was selected.
113 (2) NULL if called from menu exit (forced exit at top level).
116 typedef const void *(*CMSMenuOnExitPtr)(displayPort_t *pDisp, const OSD_Entry *self);
118 typedef const void *(*CMSMenuOnDisplayUpdatePtr)(displayPort_t *pDisp, const OSD_Entry *selected);
120 typedef struct
122 #ifdef CMS_MENU_DEBUG
123 // These two are debug aids for menu content creators.
124 const char *GUARD_text;
125 const OSD_MenuElement GUARD_type;
126 #endif
127 const CMSMenuFuncPtr onEnter;
128 const CMSMenuOnExitPtr onExit;
129 const CMSMenuOnDisplayUpdatePtr onDisplayUpdate;
130 const OSD_Entry *entries;
131 } CMS_Menu;
133 typedef struct
135 uint8_t *val;
136 uint8_t min;
137 uint8_t max;
138 uint8_t step;
139 } OSD_UINT8_t;
141 typedef struct
143 int8_t *val;
144 int8_t min;
145 int8_t max;
146 int8_t step;
147 } OSD_INT8_t;
149 typedef struct
151 int16_t *val;
152 int16_t min;
153 int16_t max;
154 int16_t step;
155 } OSD_INT16_t;
157 typedef struct
159 uint16_t *val;
160 uint16_t min;
161 uint16_t max;
162 uint16_t step;
163 } OSD_UINT16_t;
165 typedef struct
167 int32_t *val;
168 int32_t min;
169 int32_t max;
170 int32_t step;
171 } OSD_INT32_t;
173 typedef struct
175 uint32_t *val;
176 uint32_t min;
177 uint32_t max;
178 uint32_t step;
179 } OSD_UINT32_t;
181 typedef struct
183 uint8_t *val;
184 uint8_t min;
185 uint8_t max;
186 uint8_t step;
187 uint16_t multipler;
188 } OSD_FLOAT_t;
190 typedef struct
192 uint8_t *val;
193 uint8_t max;
194 const char * const *names;
195 } OSD_TAB_t;
197 typedef struct
199 char *val;
200 } OSD_String_t;