Skip to content

Commit

Permalink
PreArm allow Re-Arm (without resetting PreArm AUX) (betaflight#14013)
Browse files Browse the repository at this point in the history
* added prearm_until_first_arm setting

* Update src/main/cli/settings.c

space removed

Co-authored-by: Mark Haslinghuis <[email protected]>

* increased PG revision

* prearm_allow_rearm

* Update src/main/fc/rc_controls.c

Co-authored-by: Jan Post <[email protected]>

---------

Co-authored-by: sprv <[email protected]>
Co-authored-by: sprv <[email protected]>
Co-authored-by: Mark Haslinghuis <[email protected]>
Co-authored-by: Jan Post <[email protected]>
  • Loading branch information
5 people authored Dec 10, 2024
1 parent 9fc83c6 commit 17cef3b
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/main/cli/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand Down
2 changes: 1 addition & 1 deletion src/main/fc/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/main/fc/parameter_names.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions src/main/fc/rc_controls.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/main/fc/rc_controls.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 17cef3b

Please sign in to comment.