From 7087a5c87b78ca84dc5b0bb97f2a32b14f46a96a Mon Sep 17 00:00:00 2001 From: Bruce Luckcuck Date: Sat, 16 Nov 2019 18:23:01 -0500 Subject: [PATCH] Disable stick arming by default, require settings change to enable Previously stick arming was assumed to be the case if an arming switch was not configured. This leads to a less safe default state and can lead to beginners thinking that stick arming is the default. This change adds an `enable_stick_arming` setting which defaults to `OFF`. For stick arming to function the user must actively change this setting. The previous condition about there not being an arming switch configured still applies. --- src/main/cli/settings.c | 1 + src/main/config/config.c | 1 + src/main/config/config.h | 1 + src/main/fc/rc_controls.c | 2 +- 4 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/cli/settings.c b/src/main/cli/settings.c index 78a5749aeb..17fd146eff 100644 --- a/src/main/cli/settings.c +++ b/src/main/cli/settings.c @@ -1384,6 +1384,7 @@ const clivalue_t valueTable[] = { #endif { "pwr_on_arm_grace", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 30 }, PG_SYSTEM_CONFIG, offsetof(systemConfig_t, powerOnArmingGraceTime) }, { "scheduler_optimize_rate", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON_AUTO }, PG_SYSTEM_CONFIG, offsetof(systemConfig_t, schedulerOptimizeRate) }, + { "enable_stick_arming", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_SYSTEM_CONFIG, offsetof(systemConfig_t, enableStickArming) }, // PG_VTX_CONFIG #ifdef USE_VTX_COMMON diff --git a/src/main/config/config.c b/src/main/config/config.c index 1e069c7cd4..5bf633b694 100644 --- a/src/main/config/config.c +++ b/src/main/config/config.c @@ -114,6 +114,7 @@ PG_RESET_TEMPLATE(systemConfig_t, systemConfig, .hseMhz = SYSTEM_HSE_VALUE, // Not used for non-F4 targets .configurationState = CONFIGURATION_STATE_DEFAULTS_BARE, .schedulerOptimizeRate = SCHEDULER_OPTIMIZE_RATE_AUTO, + .enableStickArming = false, ); uint8_t getCurrentPidProfileIndex(void) diff --git a/src/main/config/config.h b/src/main/config/config.h index 5b3065d7c5..e66d262125 100644 --- a/src/main/config/config.h +++ b/src/main/config/config.h @@ -60,6 +60,7 @@ typedef struct systemConfig_s { uint8_t hseMhz; // Not used for non-F4 targets uint8_t configurationState; // The state of the configuration (defaults / configured) uint8_t schedulerOptimizeRate; + uint8_t enableStickArming; // boolean that determines whether stick arming can be used } systemConfig_t; PG_DECLARE(systemConfig_t, systemConfig); diff --git a/src/main/fc/rc_controls.c b/src/main/fc/rc_controls.c index 003ecf9fc4..c26333b102 100644 --- a/src/main/fc/rc_controls.c +++ b/src/main/fc/rc_controls.c @@ -396,5 +396,5 @@ int32_t getRcStickDeflection(int32_t axis, uint16_t midrc) { void rcControlsInit(void) { analyzeModeActivationConditions(); - isUsingSticksToArm = !isModeActivationConditionPresent(BOXARM); + isUsingSticksToArm = !isModeActivationConditionPresent(BOXARM) && systemConfig()->enableStickArming; }