Update cloud build defines (#14080)
[betaflight.git] / src / main / cms / cms_menu_rpm_limit.c
blobeaff55d87d95095bca60b87f5d7a2d6af26c1666
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 <stdint.h>
24 #include <string.h>
25 #include <ctype.h>
27 #include "platform.h"
29 #ifdef USE_CMS
30 #ifdef USE_RPM_LIMIT
32 #include "cms/cms.h"
33 #include "cms/cms_types.h"
34 #include "config/config.h"
35 #include "pg/stats.h"
36 #include "flight/mixer.h"
38 #include "cms/cms_menu_rpm_limit.h"
40 uint16_t rpm_limit_value;
41 uint16_t kv;
42 bool rpm_limit;
44 static const void *cmsx_RpmLimit_onEnter(displayPort_t *pDisp)
46 UNUSED(pDisp);
48 rpm_limit_value = mixerConfig()->rpm_limit_value;
49 kv = motorConfig()->kv;
50 rpm_limit = mixerConfig()->rpm_limit;
52 return NULL;
55 static const void *cmsx_RpmLimit_onExit(displayPort_t *pDisp, const OSD_Entry *self)
57 UNUSED(pDisp);
58 UNUSED(self);
60 mixerConfigMutable()->rpm_limit_value = rpm_limit_value;
61 motorConfigMutable()->kv = kv;
62 mixerConfigMutable()->rpm_limit = rpm_limit;
64 return NULL;
67 static const OSD_Entry cmsx_menuRpmLimitEntries[] =
69 { "-- RPM LIMIT --", OME_Label, NULL, NULL },
70 { "ACTIVE", OME_Bool | REBOOT_REQUIRED, NULL, &rpm_limit },
71 { "MAX RPM", OME_UINT16, NULL, &(OSD_UINT16_t){ &rpm_limit_value, 0, UINT16_MAX, 100} },
72 { "KV", OME_UINT16, NULL, &(OSD_UINT16_t){ &kv, 0, UINT16_MAX, 1} },
74 { "SAVE&REBOOT", OME_OSD_Exit, cmsMenuExit, (void *)CMS_POPUP_SAVEREBOOT },
75 { "BACK", OME_Back, NULL, NULL },
76 { NULL, OME_END, NULL, NULL}
79 CMS_Menu cmsx_menuRpmLimit = {
80 #ifdef CMS_MENU_DEBUG
81 .GUARD_text = "RPMLIMIT",
82 .GUARD_type = OME_MENU,
83 #endif
84 .onEnter = cmsx_RpmLimit_onEnter,
85 .onExit = cmsx_RpmLimit_onExit,
86 .onDisplayUpdate = NULL,
87 .entries = cmsx_menuRpmLimitEntries
90 #endif
91 #endif // USE_RPM_LIMIT