Update cloud build defines (#14080)
[betaflight.git] / src / main / cms / cms_menu_misc.c
blob6ff699e52776512133edc0c0ff0e0d07a5acb630
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/>.
21 #include <stdbool.h>
22 #include <stdint.h>
23 #include <string.h>
24 #include <ctype.h>
25 #include <math.h>
27 #include "platform.h"
29 #ifdef USE_CMS
31 #include "build/version.h"
33 #include "cms/cms.h"
34 #include "cms/cms_types.h"
35 #include "cms/cms_menu_gps_lap_timer.h"
36 #include "cms/cms_menu_ledstrip.h"
38 #include "common/utils.h"
40 #include "config/config.h"
41 #include "config/feature.h"
43 #include "drivers/time.h"
45 #include "fc/rc_controls.h"
47 #include "flight/mixer.h"
49 #include "pg/motor.h"
50 #include "pg/pg.h"
51 #include "pg/pg_ids.h"
52 #include "pg/rx.h"
54 #include "rx/rx.h"
56 #include "sensors/battery.h"
58 #include "cms_menu_misc.h"
61 // Misc
64 static const void *cmsx_menuRcOnEnter(displayPort_t *pDisp)
66 UNUSED(pDisp);
68 inhibitSaveMenu();
70 return NULL;
73 static const void *cmsx_menuRcConfirmBack(displayPort_t *pDisp, const OSD_Entry *self)
75 UNUSED(pDisp);
77 if (self && ((self->flags & OSD_MENU_ELEMENT_MASK) == OME_Back)) {
78 return NULL;
79 } else {
80 return MENU_CHAIN_BACK;
84 static int16_t rcDataInt[AUX4 + 1];
86 static const void *cmsx_menuRcOnDisplayUpdate(displayPort_t *pDisp, const OSD_Entry *selected)
88 UNUSED(pDisp);
89 UNUSED(selected);
91 for (int i = 0; i <= AUX4; i++) {
92 rcDataInt[i] = lrintf(rcData[i]);
95 return NULL;
99 // RC preview
101 static const OSD_Entry cmsx_menuRcEntries[] =
103 { "-- RC PREV --", OME_Label, NULL, NULL},
105 { "ROLL", OME_INT16 | DYNAMIC, NULL, &(OSD_INT16_t){ &rcDataInt[ROLL], 1, 2500, 0 } },
106 { "PITCH", OME_INT16 | DYNAMIC, NULL, &(OSD_INT16_t){ &rcDataInt[PITCH], 1, 2500, 0 } },
107 { "THR", OME_INT16 | DYNAMIC, NULL, &(OSD_INT16_t){ &rcDataInt[THROTTLE], 1, 2500, 0 } },
108 { "YAW", OME_INT16 | DYNAMIC, NULL, &(OSD_INT16_t){ &rcDataInt[YAW], 1, 2500, 0 } },
110 { "AUX1", OME_INT16 | DYNAMIC, NULL, &(OSD_INT16_t){ &rcDataInt[AUX1], 1, 2500, 0 } },
111 { "AUX2", OME_INT16 | DYNAMIC, NULL, &(OSD_INT16_t){ &rcDataInt[AUX2], 1, 2500, 0 } },
112 { "AUX3", OME_INT16 | DYNAMIC, NULL, &(OSD_INT16_t){ &rcDataInt[AUX3], 1, 2500, 0 } },
113 { "AUX4", OME_INT16 | DYNAMIC, NULL, &(OSD_INT16_t){ &rcDataInt[AUX4], 1, 2500, 0 } },
115 { "BACK", OME_Back, NULL, NULL},
116 {NULL, OME_END, NULL, NULL}
119 CMS_Menu cmsx_menuRcPreview = {
120 #ifdef CMS_MENU_DEBUG
121 .GUARD_text = "XRCPREV",
122 .GUARD_type = OME_MENU,
123 #endif
124 .onEnter = cmsx_menuRcOnEnter,
125 .onExit = cmsx_menuRcConfirmBack,
126 .onDisplayUpdate = cmsx_menuRcOnDisplayUpdate,
127 .entries = cmsx_menuRcEntries
130 static uint8_t motorConfig_motorIdle;
131 static uint8_t rxConfig_fpvCamAngleDegrees;
132 static uint8_t mixerConfig_crashflip_rate;
134 static const void *cmsx_menuMiscOnEnter(displayPort_t *pDisp)
136 UNUSED(pDisp);
138 motorConfig_motorIdle = motorConfig()->motorIdle / 10;
139 rxConfig_fpvCamAngleDegrees = rxConfig()->fpvCamAngleDegrees;
140 mixerConfig_crashflip_rate = mixerConfig()->crashflip_rate;
142 return NULL;
145 static const void *cmsx_menuMiscOnExit(displayPort_t *pDisp, const OSD_Entry *self)
147 UNUSED(pDisp);
148 UNUSED(self);
150 motorConfigMutable()->motorIdle = 10 * motorConfig_motorIdle;
151 rxConfigMutable()->fpvCamAngleDegrees = rxConfig_fpvCamAngleDegrees;
152 mixerConfigMutable()->crashflip_rate = mixerConfig_crashflip_rate;
154 return NULL;
157 static const OSD_Entry menuMiscEntries[]=
159 { "-- MISC --", OME_Label, NULL, NULL },
161 { "IDLE OFFSET", OME_UINT8 | REBOOT_REQUIRED, NULL, &(OSD_UINT8_t) { &motorConfig_motorIdle, 0, 200, 1 } },
162 { "FPV CAM ANGLE", OME_UINT8, NULL, &(OSD_UINT8_t) { &rxConfig_fpvCamAngleDegrees, 0, 90, 1 } },
163 { "CRASHFLIP RATE", OME_UINT8 | REBOOT_REQUIRED, NULL, &(OSD_UINT8_t) { &mixerConfig_crashflip_rate, 0, 100, 1 } },
164 { "RC PREV", OME_Submenu, cmsMenuChange, &cmsx_menuRcPreview},
165 #ifdef USE_GPS_LAP_TIMER
166 { "GPS LAP TIMER", OME_Submenu, cmsMenuChange, &cms_menuGpsLapTimer },
167 #endif // USE_GPS_LAP_TIMER
169 { "BACK", OME_Back, NULL, NULL},
170 { NULL, OME_END, NULL, NULL}
173 CMS_Menu cmsx_menuMisc = {
174 #ifdef CMS_MENU_DEBUG
175 .GUARD_text = "XMISC",
176 .GUARD_type = OME_MENU,
177 #endif
178 .onEnter = cmsx_menuMiscOnEnter,
179 .onExit = cmsx_menuMiscOnExit,
180 .onDisplayUpdate = NULL,
181 .entries = menuMiscEntries
184 #endif // CMS