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)
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/>.
28 #ifdef USE_CMS_FAILSAFE_MENU
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"
38 #include "config/feature.h"
40 #include "config/config.h"
42 #include "flight/failsafe.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
)
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
;
63 static const void *cmsx_Failsafe_onExit(displayPort_t
*pDisp
, const OSD_Entry
*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
;
76 static const OSD_Entry cmsx_menuFailsafeEntries
[] =
78 { "-- FAILSAFE --", OME_Label
, NULL
, NULL
},
80 { "PROCEDURE", OME_TAB
| REBOOT_REQUIRED
, NULL
, &(OSD_TAB_t
) { &failsafeConfig_failsafe_procedure
, FAILSAFE_PROCEDURE_COUNT
- 1, failsafeProcedureNames
} },
81 { "GUARD TIME", OME_FLOAT
| REBOOT_REQUIRED
, NULL
, &(OSD_FLOAT_t
) { &failsafeConfig_failsafe_delay
, 0, 200, 1, 100 } },
82 { "STAGE 2 DELAY", OME_FLOAT
| REBOOT_REQUIRED
, NULL
, &(OSD_FLOAT_t
) { &failsafeConfig_failsafe_off_delay
, 0, 200, 1, 100 } },
83 { "STAGE 2 THROTTLE", OME_UINT16
| REBOOT_REQUIRED
, NULL
, &(OSD_UINT16_t
) { &failsafeConfig_failsafe_throttle
, PWM_PULSE_MIN
, PWM_PULSE_MAX
, 1 } },
84 #ifdef USE_CMS_GPS_RESCUE_MENU
85 { "GPS RESCUE", OME_Submenu
, cmsMenuChange
, &cmsx_menuGpsRescue
},
87 { "BACK", OME_Back
, NULL
, NULL
},
88 { NULL
, OME_END
, NULL
, NULL
}
91 CMS_Menu cmsx_menuFailsafe
= {
93 .GUARD_text
= "MENUFS",
94 .GUARD_type
= OME_MENU
,
96 .onEnter
= cmsx_Failsafe_onEnter
,
97 .onExit
= cmsx_Failsafe_onExit
,
98 .onDisplayUpdate
= NULL
,
99 .entries
= cmsx_menuFailsafeEntries