mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-24 00:35:39 +03:00
Add CMS failsafe setup menu
Located under the Features top-level menu. Allows configuring the failsafe procedure (like selecting GPS-RESCUE if applicable). Bounded with `#ifdef USE_CMS_FAILSAFE_MENU` so it can be disabled for space critical targets.
This commit is contained in:
parent
d76807fd33
commit
330d93eb5b
8 changed files with 134 additions and 1 deletions
|
@ -121,6 +121,7 @@ COMMON_SRC = \
|
||||||
cms/cms.c \
|
cms/cms.c \
|
||||||
cms/cms_menu_blackbox.c \
|
cms/cms_menu_blackbox.c \
|
||||||
cms/cms_menu_builtin.c \
|
cms/cms_menu_builtin.c \
|
||||||
|
cms/cms_menu_failsafe.c \
|
||||||
cms/cms_menu_imu.c \
|
cms/cms_menu_imu.c \
|
||||||
cms/cms_menu_ledstrip.c \
|
cms/cms_menu_ledstrip.c \
|
||||||
cms/cms_menu_misc.c \
|
cms/cms_menu_misc.c \
|
||||||
|
@ -297,6 +298,7 @@ SIZE_OPTIMISED_SRC := $(SIZE_OPTIMISED_SRC) \
|
||||||
cms/cms.c \
|
cms/cms.c \
|
||||||
cms/cms_menu_blackbox.c \
|
cms/cms_menu_blackbox.c \
|
||||||
cms/cms_menu_builtin.c \
|
cms/cms_menu_builtin.c \
|
||||||
|
cms/cms_menu_failsafe.c \
|
||||||
cms/cms_menu_imu.c \
|
cms/cms_menu_imu.c \
|
||||||
cms/cms_menu_ledstrip.c \
|
cms/cms_menu_ledstrip.c \
|
||||||
cms/cms_menu_misc.c \
|
cms/cms_menu_misc.c \
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include "cms/cms_menu_ledstrip.h"
|
#include "cms/cms_menu_ledstrip.h"
|
||||||
#include "cms/cms_menu_misc.h"
|
#include "cms/cms_menu_misc.h"
|
||||||
#include "cms/cms_menu_power.h"
|
#include "cms/cms_menu_power.h"
|
||||||
|
#include "cms/cms_menu_failsafe.h"
|
||||||
|
|
||||||
// VTX supplied menus
|
// VTX supplied menus
|
||||||
|
|
||||||
|
@ -120,6 +121,9 @@ static OSD_Entry menuFeaturesEntries[] =
|
||||||
{"LED STRIP", OME_Submenu, cmsMenuChange, &cmsx_menuLedstrip, 0},
|
{"LED STRIP", OME_Submenu, cmsMenuChange, &cmsx_menuLedstrip, 0},
|
||||||
#endif // LED_STRIP
|
#endif // LED_STRIP
|
||||||
{"POWER", OME_Submenu, cmsMenuChange, &cmsx_menuPower, 0},
|
{"POWER", OME_Submenu, cmsMenuChange, &cmsx_menuPower, 0},
|
||||||
|
#ifdef USE_CMS_FAILSAFE_MENU
|
||||||
|
{"FAILSAFE", OME_Submenu, cmsMenuChange, &cmsx_menuFailsafe, 0},
|
||||||
|
#endif
|
||||||
{"BACK", OME_Back, NULL, NULL, 0},
|
{"BACK", OME_Back, NULL, NULL, 0},
|
||||||
{NULL, OME_END, NULL, NULL, 0}
|
{NULL, OME_END, NULL, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
90
src/main/cms/cms_menu_failsafe.c
Normal file
90
src/main/cms/cms_menu_failsafe.c
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Cleanflight and Betaflight.
|
||||||
|
*
|
||||||
|
* Cleanflight and Betaflight are free software. You can redistribute
|
||||||
|
* this software and/or modify this software under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, either version 3 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Cleanflight and Betaflight are distributed in the hope that they
|
||||||
|
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this software.
|
||||||
|
*
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
|
#include "platform.h"
|
||||||
|
|
||||||
|
#ifdef USE_CMS_FAILSAFE_MENU
|
||||||
|
|
||||||
|
#include "cms/cms.h"
|
||||||
|
#include "cms/cms_types.h"
|
||||||
|
#include "cms/cms_menu_failsafe.h"
|
||||||
|
|
||||||
|
#include "config/feature.h"
|
||||||
|
|
||||||
|
#include "fc/config.h"
|
||||||
|
|
||||||
|
#include "flight/failsafe.h"
|
||||||
|
|
||||||
|
#include "rx/rx.h"
|
||||||
|
|
||||||
|
uint8_t failsafeConfig_failsafe_procedure;
|
||||||
|
uint8_t failsafeConfig_failsafe_delay;
|
||||||
|
uint8_t failsafeConfig_failsafe_off_delay;
|
||||||
|
uint16_t failsafeConfig_failsafe_throttle;
|
||||||
|
|
||||||
|
static long cmsx_Failsafe_onEnter(void)
|
||||||
|
{
|
||||||
|
failsafeConfig_failsafe_procedure = failsafeConfig()->failsafe_procedure;
|
||||||
|
failsafeConfig_failsafe_delay = failsafeConfig()->failsafe_delay;
|
||||||
|
failsafeConfig_failsafe_off_delay = failsafeConfig()->failsafe_off_delay;
|
||||||
|
failsafeConfig_failsafe_throttle = failsafeConfig()->failsafe_throttle;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static long cmsx_Failsafe_onExit(const OSD_Entry *self)
|
||||||
|
{
|
||||||
|
UNUSED(self);
|
||||||
|
|
||||||
|
failsafeConfigMutable()->failsafe_procedure = failsafeConfig_failsafe_procedure;
|
||||||
|
failsafeConfigMutable()->failsafe_delay = failsafeConfig_failsafe_delay;
|
||||||
|
failsafeConfigMutable()->failsafe_off_delay = failsafeConfig_failsafe_off_delay;
|
||||||
|
failsafeConfigMutable()->failsafe_throttle = failsafeConfig_failsafe_throttle;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static OSD_Entry cmsx_menuFailsafeEntries[] =
|
||||||
|
{
|
||||||
|
{ "-- FAILSAFE --", OME_Label, NULL, NULL, 0},
|
||||||
|
|
||||||
|
{ "PROCEDURE", OME_TAB, NULL, &(OSD_TAB_t) { &failsafeConfig_failsafe_procedure, FAILSAFE_PROCEDURE_COUNT - 1, failsafeProcedureNames }, 0 },
|
||||||
|
{ "GUARD TIME", OME_FLOAT, NULL, &(OSD_FLOAT_t) { &failsafeConfig_failsafe_delay, 0, 200, 1, 100 }, 0 },
|
||||||
|
{ "STAGE 2 DELAY", OME_FLOAT, NULL, &(OSD_FLOAT_t) { &failsafeConfig_failsafe_off_delay, 0, 200, 1, 100 }, 0 },
|
||||||
|
{ "STAGE 2 THROTTLE", OME_UINT16, NULL, &(OSD_UINT16_t) { &failsafeConfig_failsafe_throttle, PWM_PULSE_MIN, PWM_PULSE_MAX, 1 }, 0 },
|
||||||
|
{ "BACK", OME_Back, NULL, NULL, 0 },
|
||||||
|
{ NULL, OME_END, NULL, NULL, 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
CMS_Menu cmsx_menuFailsafe = {
|
||||||
|
#ifdef CMS_MENU_DEBUG
|
||||||
|
.GUARD_text = "MENUFS",
|
||||||
|
.GUARD_type = OME_MENU,
|
||||||
|
#endif
|
||||||
|
.onEnter = cmsx_Failsafe_onEnter,
|
||||||
|
.onExit = cmsx_Failsafe_onExit,
|
||||||
|
.entries = cmsx_menuFailsafeEntries
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
23
src/main/cms/cms_menu_failsafe.h
Normal file
23
src/main/cms/cms_menu_failsafe.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
/*
|
||||||
|
* This file is part of Cleanflight and Betaflight.
|
||||||
|
*
|
||||||
|
* Cleanflight and Betaflight are free software. You can redistribute
|
||||||
|
* this software and/or modify this software under the terms of the
|
||||||
|
* GNU General Public License as published by the Free Software
|
||||||
|
* Foundation, either version 3 of the License, or (at your option)
|
||||||
|
* any later version.
|
||||||
|
*
|
||||||
|
* Cleanflight and Betaflight are distributed in the hope that they
|
||||||
|
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
||||||
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this software.
|
||||||
|
*
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
extern CMS_Menu cmsx_menuFailsafe;
|
|
@ -72,6 +72,12 @@ PG_RESET_TEMPLATE(failsafeConfig_t, failsafeConfig,
|
||||||
.failsafe_procedure = FAILSAFE_PROCEDURE_DROP_IT // default full failsafe procedure is 0: auto-landing
|
.failsafe_procedure = FAILSAFE_PROCEDURE_DROP_IT // default full failsafe procedure is 0: auto-landing
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const char * const failsafeProcedureNames[FAILSAFE_PROCEDURE_COUNT] = {
|
||||||
|
"AUTO-LAND",
|
||||||
|
"DROP",
|
||||||
|
"GPS-RESCUE"
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Should called when the failsafe config needs to be changed - e.g. a different profile has been selected.
|
* Should called when the failsafe config needs to be changed - e.g. a different profile has been selected.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -61,9 +61,12 @@ typedef enum {
|
||||||
typedef enum {
|
typedef enum {
|
||||||
FAILSAFE_PROCEDURE_AUTO_LANDING = 0,
|
FAILSAFE_PROCEDURE_AUTO_LANDING = 0,
|
||||||
FAILSAFE_PROCEDURE_DROP_IT,
|
FAILSAFE_PROCEDURE_DROP_IT,
|
||||||
FAILSAFE_PROCEDURE_GPS_RESCUE
|
FAILSAFE_PROCEDURE_GPS_RESCUE,
|
||||||
|
FAILSAFE_PROCEDURE_COUNT // must be last
|
||||||
} failsafeProcedure_e;
|
} failsafeProcedure_e;
|
||||||
|
|
||||||
|
extern const char * const failsafeProcedureNames[FAILSAFE_PROCEDURE_COUNT];
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
FAILSAFE_SWITCH_MODE_STAGE1 = 0,
|
FAILSAFE_SWITCH_MODE_STAGE1 = 0,
|
||||||
FAILSAFE_SWITCH_MODE_KILL,
|
FAILSAFE_SWITCH_MODE_KILL,
|
||||||
|
|
|
@ -243,3 +243,7 @@
|
||||||
#undef USE_DSHOT_TELEMETRY
|
#undef USE_DSHOT_TELEMETRY
|
||||||
#undef USE_RPM_FILTER
|
#undef USE_RPM_FILTER
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef USE_CMS
|
||||||
|
#undef USE_CMS_FAILSAFE_MENU
|
||||||
|
#endif
|
||||||
|
|
|
@ -245,5 +245,6 @@
|
||||||
#define USE_OSD_STICK_OVERLAY
|
#define USE_OSD_STICK_OVERLAY
|
||||||
#define USE_ESCSERIAL_SIMONK
|
#define USE_ESCSERIAL_SIMONK
|
||||||
#define USE_SERIAL_4WAY_SK_BOOTLOADER
|
#define USE_SERIAL_4WAY_SK_BOOTLOADER
|
||||||
|
#define USE_CMS_FAILSAFE_MENU
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue