Update cloud build defines (#14080)
[betaflight.git] / src / main / cms / cms_menu_quick.c
blobb8cda645625b803eddae03618f69830f62bbc274
1 /*
2 * This file is part of Betaflight.
4 * Betaflight is free software. You can redistribute this software
5 * and/or modify this software under the terms of the GNU General
6 * Public License as published by the Free Software Foundation,
7 * either version 3 of the License, or (at your option) any later
8 * version.
10 * Betaflight is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this software.
19 * If not, see <http://www.gnu.org/licenses/>.
22 #include <stdbool.h>
23 #include <string.h>
25 #include "platform.h"
27 #ifdef USE_CMS
28 #ifdef USE_OSD_QUICK_MENU
30 #include "cms/cms.h"
31 #include "cms/cms_types.h"
32 #include "cms/cms_menu_main.h"
33 #include "cms/cms_menu_vtx_common.h"
34 #include "cms/cms_menu_rpm_limit.h"
35 #include "common/printf.h"
36 #include "config/config.h"
38 #include "drivers/pwm_output.h"
40 #include "fc/controlrate_profile.h"
41 #include "fc/core.h"
42 #include "fc/runtime_config.h"
43 #include "flight/pid.h"
44 #include "flight/pid_init.h"
46 #include "sensors/battery.h"
48 #include "cli/settings.h"
50 #include "cms_menu_quick.h"
52 static controlRateConfig_t rateProfile;
53 static uint8_t rateProfileIndex;
54 static batteryConfig_t batteryProfile;
55 static uint8_t cmsx_motorOutputLimit;
56 static uint8_t pidProfileIndex;
57 static pidProfile_t *pidProfile;
59 static const void *quickMenuOnEnter(displayPort_t *pDisp)
61 UNUSED(pDisp);
62 pidProfileIndex = getCurrentPidProfileIndex();
63 pidProfile = pidProfilesMutable(pidProfileIndex);
65 rateProfileIndex = getCurrentControlRateProfileIndex();
66 memcpy(&rateProfile, controlRateProfiles(rateProfileIndex), sizeof(controlRateConfig_t));
67 memcpy(&batteryProfile, batteryConfigMutable(), sizeof(batteryConfig_t));
69 cmsx_motorOutputLimit = pidProfile->motor_output_limit;
71 return NULL;
74 static const void *cmsx_RateProfileWriteback(displayPort_t *pDisp, const OSD_Entry *self)
76 UNUSED(pDisp);
77 UNUSED(self);
79 memcpy(controlRateProfilesMutable(rateProfileIndex), &rateProfile, sizeof(controlRateConfig_t));
80 memcpy(batteryConfigMutable(), &batteryProfile, sizeof(batteryConfig_t));
82 pidProfile_t *pidProfile = pidProfilesMutable(pidProfileIndex);
83 pidProfile->motor_output_limit = cmsx_motorOutputLimit;
85 pidInitConfig(currentPidProfile);
87 return NULL;
90 static const OSD_Entry menuMainEntries[] =
92 { "-- QUICK --", OME_Label, NULL, NULL },
94 #if defined(USE_RPM_LIMIT)
95 { "RPM LIM", OME_Submenu, cmsMenuChange, &cmsx_menuRpmLimit },
96 #endif
97 { "THR LIM TYPE", OME_TAB, NULL, &(OSD_TAB_t) { &rateProfile.throttle_limit_type, THROTTLE_LIMIT_TYPE_COUNT - 1, lookupTableThrottleLimitType } },
98 { "THR LIM %", OME_UINT8, NULL, &(OSD_UINT8_t) { &rateProfile.throttle_limit_percent, 25, 100, 1 } },
99 { "MTR OUT LIM %", OME_UINT8, NULL, &(OSD_UINT8_t) { &cmsx_motorOutputLimit, MOTOR_OUTPUT_LIMIT_PERCENT_MIN, MOTOR_OUTPUT_LIMIT_PERCENT_MAX, 1 } },
100 { "FORCE CELLS", OME_UINT8, NULL, &(OSD_UINT8_t) { &batteryProfile.forceBatteryCellCount, 0, 24, 1 } },
101 #if defined(USE_VTX_CONTROL)
102 #if defined(USE_VTX_RTC6705) || defined(USE_VTX_SMARTAUDIO) || defined(USE_VTX_TRAMP)
103 {"VTX", OME_Funcall, cmsSelectVtx, NULL},
104 #endif
105 #endif // VTX_CONTROL
106 { "MAIN", OME_Submenu, NULL, &cmsx_menuMain },
107 { "EXIT", OME_OSD_Exit, cmsMenuExit, (void *)CMS_EXIT},
108 { "SAVE&REBOOT", OME_OSD_Exit, cmsMenuExit, (void *)CMS_POPUP_SAVEREBOOT},
109 {NULL, OME_END, NULL, NULL},
112 CMS_Menu cmsx_menuQuick = {
113 #ifdef CMS_MENU_DEBUG
114 .GUARD_text = "MENUQUICK",
115 .GUARD_type = OME_MENU,
116 #endif
117 .onEnter = quickMenuOnEnter,
118 .onExit = cmsx_RateProfileWriteback,
119 .onDisplayUpdate = NULL,
120 .entries = menuMainEntries,
123 #endif // USE_OSD_QUICK_MENU
124 #endif // USE_CMS