Merge pull request #10309 from etracer65/gps_rescue_disable_headfree
[betaflight.git] / src / main / cms / cms_types.h
blobb07c1b3aff2b69ed8c2c985ce75b41ab4c12f549
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_String,
43 OME_FLOAT, //only up to 255 value and cant be 2.55 or 25.5, just for PID's
44 //wlasciwosci elementow
45 #ifdef USE_OSD
46 OME_VISIBLE,
47 #endif
48 OME_TAB,
49 OME_END,
51 // Debug aid
52 OME_MENU,
54 OME_MAX = OME_MENU
55 } OSD_MenuElement;
57 typedef const void *(*CMSEntryFuncPtr)(displayPort_t *displayPort, const void *ptr);
59 typedef struct
61 const char * text;
62 OSD_MenuElement type;
63 CMSEntryFuncPtr func;
64 void *data;
65 uint8_t flags;
66 } __attribute__((packed)) OSD_Entry;
68 // Bits in flags
69 #define PRINT_VALUE 0x01 // Value has been changed, need to redraw
70 #define PRINT_LABEL 0x02 // Text label should be printed
71 #define DYNAMIC 0x04 // Value should be updated dynamically
72 #define OPTSTRING 0x08 // (Temporary) Flag for OME_Submenu, indicating func should be called to get a string to display.
73 #define REBOOT_REQUIRED 0x10 // Reboot is required if the value is changed
75 #define IS_PRINTVALUE(x) ((x) & PRINT_VALUE)
76 #define SET_PRINTVALUE(x) do { (x) |= PRINT_VALUE; } while (0)
77 #define CLR_PRINTVALUE(x) do { (x) &= ~PRINT_VALUE; } while (0)
79 #define IS_PRINTLABEL(x) ((x) & PRINT_LABEL)
80 #define SET_PRINTLABEL(x) do { (x) |= PRINT_LABEL; } while (0)
81 #define CLR_PRINTLABEL(x) do { (x) &= ~PRINT_LABEL; } while (0)
83 #define IS_DYNAMIC(p) ((p)->flags & DYNAMIC)
85 typedef const void *(*CMSMenuFuncPtr)(displayPort_t *pDisp);
87 // Special return value(s) for function chaining by CMSMenuFuncPtr
88 extern int menuChainBack;
89 #define MENU_CHAIN_BACK (&menuChainBack) // Causes automatic cmsMenuBack
92 onExit function is called with self:
93 (1) Pointer to an OSD_Entry when cmsMenuBack() was called.
94 Point to an OSD_Entry with type == OME_Back if BACK was selected.
95 (2) NULL if called from menu exit (forced exit at top level).
98 typedef const void *(*CMSMenuOnExitPtr)(displayPort_t *pDisp, const OSD_Entry *self);
100 typedef const void *(*CMSMenuOnDisplayUpdatePtr)(displayPort_t *pDisp, const OSD_Entry *selected);
102 typedef struct
104 #ifdef CMS_MENU_DEBUG
105 // These two are debug aids for menu content creators.
106 const char *GUARD_text;
107 const OSD_MenuElement GUARD_type;
108 #endif
109 const CMSMenuFuncPtr onEnter;
110 const CMSMenuOnExitPtr onExit;
111 const CMSMenuOnDisplayUpdatePtr onDisplayUpdate;
112 const OSD_Entry *entries;
113 } CMS_Menu;
115 typedef struct
117 uint8_t *val;
118 uint8_t min;
119 uint8_t max;
120 uint8_t step;
121 } OSD_UINT8_t;
123 typedef struct
125 int8_t *val;
126 int8_t min;
127 int8_t max;
128 int8_t step;
129 } OSD_INT8_t;
131 typedef struct
133 int16_t *val;
134 int16_t min;
135 int16_t max;
136 int16_t step;
137 } OSD_INT16_t;
139 typedef struct
141 uint16_t *val;
142 uint16_t min;
143 uint16_t max;
144 uint16_t step;
145 } OSD_UINT16_t;
147 typedef struct
149 uint8_t *val;
150 uint8_t min;
151 uint8_t max;
152 uint8_t step;
153 uint16_t multipler;
154 } OSD_FLOAT_t;
156 typedef struct
158 uint8_t *val;
159 uint8_t max;
160 const char * const *names;
161 } OSD_TAB_t;
163 typedef struct
165 char *val;
166 } OSD_String_t;