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
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/>.
33 #include "cms/cms_types.h"
34 #include "config/config.h"
36 #include "flight/mixer.h"
38 #include "cms/cms_menu_rpm_limit.h"
40 uint16_t rpm_limit_value
;
44 static const void *cmsx_RpmLimit_onEnter(displayPort_t
*pDisp
)
48 rpm_limit_value
= mixerConfig()->rpm_limit_value
;
49 kv
= motorConfig()->kv
;
50 rpm_limit
= mixerConfig()->rpm_limit
;
55 static const void *cmsx_RpmLimit_onExit(displayPort_t
*pDisp
, const OSD_Entry
*self
)
60 mixerConfigMutable()->rpm_limit_value
= rpm_limit_value
;
61 motorConfigMutable()->kv
= kv
;
62 mixerConfigMutable()->rpm_limit
= rpm_limit
;
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
= {
81 .GUARD_text
= "RPMLIMIT",
82 .GUARD_type
= OME_MENU
,
84 .onEnter
= cmsx_RpmLimit_onEnter
,
85 .onExit
= cmsx_RpmLimit_onExit
,
86 .onDisplayUpdate
= NULL
,
87 .entries
= cmsx_menuRpmLimitEntries
91 #endif // USE_RPM_LIMIT