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/>.
28 #ifdef USE_OSD_QUICK_MENU
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"
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
)
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
;
74 static const void *cmsx_RateProfileWriteback(displayPort_t
*pDisp
, const OSD_Entry
*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
);
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
},
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
},
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
,
117 .onEnter
= quickMenuOnEnter
,
118 .onExit
= cmsx_RateProfileWriteback
,
119 .onDisplayUpdate
= NULL
,
120 .entries
= menuMainEntries
,
123 #endif // USE_OSD_QUICK_MENU