From 17cef3bba036fd57d6d014ad013930897a4e1c14 Mon Sep 17 00:00:00 2001 From: nerdCopter <56646290+nerdCopter@users.noreply.github.com> Date: Tue, 10 Dec 2024 06:57:04 -0600 Subject: [PATCH] PreArm allow Re-Arm (without resetting PreArm AUX) (#14013) * added prearm_until_first_arm setting * Update src/main/cli/settings.c space removed Co-authored-by: Mark Haslinghuis * increased PG revision * prearm_allow_rearm * Update src/main/fc/rc_controls.c Co-authored-by: Jan Post --------- Co-authored-by: sprv Co-authored-by: sprv <86803346+niksprv@users.noreply.github.com> Co-authored-by: Mark Haslinghuis Co-authored-by: Jan Post --- src/main/cli/settings.c | 2 +- src/main/fc/core.c | 2 +- src/main/fc/parameter_names.h | 1 + src/main/fc/rc_controls.c | 5 +++-- src/main/fc/rc_controls.h | 1 + 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/main/cli/settings.c b/src/main/cli/settings.c index 3b83b3b1cca..f01c942fa27 100644 --- a/src/main/cli/settings.c +++ b/src/main/cli/settings.c @@ -1046,7 +1046,7 @@ const clivalue_t valueTable[] = { // PG_ARMING_CONFIG { "auto_disarm_delay", VAR_UINT8 | MASTER_VALUE, .config.minmaxUnsigned = { 0, 60 }, PG_ARMING_CONFIG, offsetof(armingConfig_t, auto_disarm_delay) }, { PARAM_NAME_GYRO_CAL_ON_FIRST_ARM, VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_ARMING_CONFIG, offsetof(armingConfig_t, gyro_cal_on_first_arm) }, - + { PARAM_NAME_PREARM_ALLOW_REARM, VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_OFF_ON }, PG_ARMING_CONFIG, offsetof(armingConfig_t, prearm_allow_rearm) }, // PG_GPS_CONFIG #ifdef USE_GPS { PARAM_NAME_GPS_PROVIDER, VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_GPS_PROVIDER }, PG_GPS_CONFIG, offsetof(gpsConfig_t, provider) }, diff --git a/src/main/fc/core.c b/src/main/fc/core.c index fd6b50a807e..889204938bd 100644 --- a/src/main/fc/core.c +++ b/src/main/fc/core.c @@ -373,7 +373,7 @@ void updateArmingStatus(void) } if (isModeActivationConditionPresent(BOXPREARM)) { - if (IS_RC_MODE_ACTIVE(BOXPREARM) && !ARMING_FLAG(WAS_ARMED_WITH_PREARM)) { + if (IS_RC_MODE_ACTIVE(BOXPREARM) && (!ARMING_FLAG(WAS_ARMED_WITH_PREARM) || armingConfig()->prearm_allow_rearm) ) { unsetArmingDisabled(ARMING_DISABLED_NOPREARM); } else { setArmingDisabled(ARMING_DISABLED_NOPREARM); diff --git a/src/main/fc/parameter_names.h b/src/main/fc/parameter_names.h index 6eb5adc395c..930a8ee9e27 100644 --- a/src/main/fc/parameter_names.h +++ b/src/main/fc/parameter_names.h @@ -90,6 +90,7 @@ #define PARAM_NAME_THROTTLE_LIMIT_TYPE "throttle_limit_type" #define PARAM_NAME_THROTTLE_LIMIT_PERCENT "throttle_limit_percent" #define PARAM_NAME_GYRO_CAL_ON_FIRST_ARM "gyro_cal_on_first_arm" +#define PARAM_NAME_PREARM_ALLOW_REARM "prearm_allow_rearm" #define PARAM_NAME_DEADBAND "deadband" #define PARAM_NAME_YAW_DEADBAND "yaw_deadband" #define PARAM_NAME_PID_PROCESS_DENOM "pid_process_denom" diff --git a/src/main/fc/rc_controls.c b/src/main/fc/rc_controls.c index fba35472acb..fdaa20e6b8f 100644 --- a/src/main/fc/rc_controls.c +++ b/src/main/fc/rc_controls.c @@ -81,11 +81,12 @@ PG_RESET_TEMPLATE(rcControlsConfig_t, rcControlsConfig, .yaw_control_reversed = false, ); -PG_REGISTER_WITH_RESET_TEMPLATE(armingConfig_t, armingConfig, PG_ARMING_CONFIG, 1); +PG_REGISTER_WITH_RESET_TEMPLATE(armingConfig_t, armingConfig, PG_ARMING_CONFIG, 2); PG_RESET_TEMPLATE(armingConfig_t, armingConfig, .gyro_cal_on_first_arm = 0, - .auto_disarm_delay = 5 + .auto_disarm_delay = 5, + .prearm_allow_rearm = 0, ); PG_REGISTER_WITH_RESET_TEMPLATE(flight3DConfig_t, flight3DConfig, PG_MOTOR_3D_CONFIG, 0); diff --git a/src/main/fc/rc_controls.h b/src/main/fc/rc_controls.h index 1af3349721b..52ffce90f4f 100644 --- a/src/main/fc/rc_controls.h +++ b/src/main/fc/rc_controls.h @@ -131,6 +131,7 @@ PG_DECLARE(flight3DConfig_t, flight3DConfig); typedef struct armingConfig_s { uint8_t gyro_cal_on_first_arm; // calibrate the gyro right before the first arm uint8_t auto_disarm_delay; // allow automatically disarming multicopters after auto_disarm_delay seconds of zero throttle. Disabled when 0 + uint8_t prearm_allow_rearm; } armingConfig_t; PG_DECLARE(armingConfig_t, armingConfig);