New SPI API supporting DMA
[betaflight.git] / src / main / cms / cms_menu_failsafe.c
blob59ab5eaaf29310f9cddc4e00f5315a18cb8b3ba4
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>
26 #include "platform.h"
28 #ifdef USE_CMS_FAILSAFE_MENU
30 #include "cms/cms.h"
31 #include "cms/cms_types.h"
32 #include "cms/cms_menu_failsafe.h"
34 #ifdef USE_CMS_GPS_RESCUE_MENU
35 #include "cms/cms_menu_gps_rescue.h"
36 #endif
38 #include "config/feature.h"
40 #include "config/config.h"
42 #include "flight/failsafe.h"
44 #include "rx/rx.h"
46 uint8_t failsafeConfig_failsafe_procedure;
47 uint8_t failsafeConfig_failsafe_delay;
48 uint8_t failsafeConfig_failsafe_off_delay;
49 uint16_t failsafeConfig_failsafe_throttle;
51 static const void *cmsx_Failsafe_onEnter(displayPort_t *pDisp)
53 UNUSED(pDisp);
55 failsafeConfig_failsafe_procedure = failsafeConfig()->failsafe_procedure;
56 failsafeConfig_failsafe_delay = failsafeConfig()->failsafe_delay;
57 failsafeConfig_failsafe_off_delay = failsafeConfig()->failsafe_off_delay;
58 failsafeConfig_failsafe_throttle = failsafeConfig()->failsafe_throttle;
60 return NULL;
63 static const void *cmsx_Failsafe_onExit(displayPort_t *pDisp, const OSD_Entry *self)
65 UNUSED(pDisp);
66 UNUSED(self);
68 failsafeConfigMutable()->failsafe_procedure = failsafeConfig_failsafe_procedure;
69 failsafeConfigMutable()->failsafe_delay = failsafeConfig_failsafe_delay;
70 failsafeConfigMutable()->failsafe_off_delay = failsafeConfig_failsafe_off_delay;
71 failsafeConfigMutable()->failsafe_throttle = failsafeConfig_failsafe_throttle;
73 return NULL;
76 static const OSD_Entry cmsx_menuFailsafeEntries[] =
78 { "-- FAILSAFE --", OME_Label, NULL, NULL, 0},
80 { "PROCEDURE", OME_TAB, NULL, &(OSD_TAB_t) { &failsafeConfig_failsafe_procedure, FAILSAFE_PROCEDURE_COUNT - 1, failsafeProcedureNames }, REBOOT_REQUIRED },
81 { "GUARD TIME", OME_FLOAT, NULL, &(OSD_FLOAT_t) { &failsafeConfig_failsafe_delay, 0, 200, 1, 100 }, REBOOT_REQUIRED },
82 { "STAGE 2 DELAY", OME_FLOAT, NULL, &(OSD_FLOAT_t) { &failsafeConfig_failsafe_off_delay, 0, 200, 1, 100 }, REBOOT_REQUIRED },
83 { "STAGE 2 THROTTLE", OME_UINT16, NULL, &(OSD_UINT16_t) { &failsafeConfig_failsafe_throttle, PWM_PULSE_MIN, PWM_PULSE_MAX, 1 }, REBOOT_REQUIRED },
84 #ifdef USE_CMS_GPS_RESCUE_MENU
85 { "GPS RESCUE", OME_Submenu, cmsMenuChange, &cmsx_menuGpsRescue, 0},
86 #endif
87 { "BACK", OME_Back, NULL, NULL, 0 },
88 { NULL, OME_END, NULL, NULL, 0 }
91 CMS_Menu cmsx_menuFailsafe = {
92 #ifdef CMS_MENU_DEBUG
93 .GUARD_text = "MENUFS",
94 .GUARD_type = OME_MENU,
95 #endif
96 .onEnter = cmsx_Failsafe_onEnter,
97 .onExit = cmsx_Failsafe_onExit,
98 .onDisplayUpdate = NULL,
99 .entries = cmsx_menuFailsafeEntries
102 #endif