From d180266f7d2fe255105e2e027d80f8a1e617f09a Mon Sep 17 00:00:00 2001 From: Martin Budden Date: Sat, 29 Jul 2017 17:35:43 +0100 Subject: [PATCH] Improved rx, failsafe and pid structure alignments --- src/main/flight/failsafe.c | 6 +++--- src/main/flight/failsafe.h | 4 ++-- src/main/flight/pid.c | 2 +- src/main/flight/pid.h | 1 - src/main/rx/rx.c | 6 +++--- src/main/rx/rx.h | 2 +- 6 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/main/flight/failsafe.c b/src/main/flight/failsafe.c index 3ae054adc..0a91f4532 100644 --- a/src/main/flight/failsafe.c +++ b/src/main/flight/failsafe.c @@ -55,13 +55,13 @@ static failsafeState_t failsafeState; -PG_REGISTER_WITH_RESET_TEMPLATE(failsafeConfig_t, failsafeConfig, PG_FAILSAFE_CONFIG, 1); +PG_REGISTER_WITH_RESET_TEMPLATE(failsafeConfig_t, failsafeConfig, PG_FAILSAFE_CONFIG, 2); PG_RESET_TEMPLATE(failsafeConfig_t, failsafeConfig, - .failsafe_delay = 10, // 1sec - .failsafe_off_delay = 10, // 1sec .failsafe_throttle = 1000, // default throttle off. .failsafe_throttle_low_delay = 100, // default throttle low delay for "just disarm" on failsafe condition + .failsafe_delay = 10, // 1sec + .failsafe_off_delay = 10, // 1sec .failsafe_kill_switch = 0, // default failsafe switch action is identical to rc link loss .failsafe_procedure = FAILSAFE_PROCEDURE_DROP_IT // default full failsafe procedure is 0: auto-landing ); diff --git a/src/main/flight/failsafe.h b/src/main/flight/failsafe.h index 82392e98e..3b2936bb8 100644 --- a/src/main/flight/failsafe.h +++ b/src/main/flight/failsafe.h @@ -30,10 +30,10 @@ typedef struct failsafeConfig_s { - uint8_t failsafe_delay; // Guard time for failsafe activation after signal lost. 1 step = 0.1sec - 1sec in example (10) - uint8_t failsafe_off_delay; // Time for Landing before motors stop in 0.1sec. 1 step = 0.1sec - 20sec in example (200) uint16_t failsafe_throttle; // Throttle level used for landing - specify value between 1000..2000 (pwm pulse width for slightly below hover). center throttle = 1500. uint16_t failsafe_throttle_low_delay; // Time throttle stick must have been below 'min_check' to "JustDisarm" instead of "full failsafe procedure". + uint8_t failsafe_delay; // Guard time for failsafe activation after signal lost. 1 step = 0.1sec - 1sec in example (10) + uint8_t failsafe_off_delay; // Time for Landing before motors stop in 0.1sec. 1 step = 0.1sec - 20sec in example (200) uint8_t failsafe_kill_switch; // failsafe switch action is 0: identical to rc link loss, 1: disarms instantly uint8_t failsafe_procedure; // selected full failsafe procedure is 0: auto-landing, 1: Drop it } failsafeConfig_t; diff --git a/src/main/flight/pid.c b/src/main/flight/pid.c index 565be6bfd..f3d5cffa5 100644 --- a/src/main/flight/pid.c +++ b/src/main/flight/pid.c @@ -69,7 +69,7 @@ PG_RESET_TEMPLATE(pidConfig_t, pidConfig, .pid_process_denom = PID_PROCESS_DENOM_DEFAULT ); -PG_REGISTER_ARRAY_WITH_RESET_FN(pidProfile_t, MAX_PROFILE_COUNT, pidProfiles, PG_PID_PROFILE, 0); +PG_REGISTER_ARRAY_WITH_RESET_FN(pidProfile_t, MAX_PROFILE_COUNT, pidProfiles, PG_PID_PROFILE, 1); void resetPidProfile(pidProfile_t *pidProfile) { diff --git a/src/main/flight/pid.h b/src/main/flight/pid.h index 70cce2112..ed887dfd7 100644 --- a/src/main/flight/pid.h +++ b/src/main/flight/pid.h @@ -82,7 +82,6 @@ typedef struct pidProfile_s { uint8_t itermWindupPointPercent; // Experimental ITerm windup threshold, percent motor saturation uint16_t pidSumLimit; uint16_t pidSumLimitYaw; - uint8_t dterm_average_count; // Configurable delta count for dterm uint8_t vbatPidCompensation; // Scale PIDsum to battery voltage uint8_t pidAtMinThrottle; // Disable/Enable pids on zero throttle. Normally even without airmode P and D would be active. uint8_t levelAngleLimit; // Max angle in degrees in level mode diff --git a/src/main/rx/rx.c b/src/main/rx/rx.c index 4f0868c0f..88dfaf171 100644 --- a/src/main/rx/rx.c +++ b/src/main/rx/rx.c @@ -117,7 +117,7 @@ static uint8_t rcSampleIndex = 0; #define BINDPLUG_PIN NONE #endif -PG_REGISTER_WITH_RESET_FN(rxConfig_t, rxConfig, PG_RX_CONFIG, 0); +PG_REGISTER_WITH_RESET_FN(rxConfig_t, rxConfig, PG_RX_CONFIG, 1); void pgResetFn_rxConfig(rxConfig_t *rxConfig) { RESET_CONFIG_2(rxConfig_t, rxConfig, @@ -141,8 +141,8 @@ void pgResetFn_rxConfig(rxConfig_t *rxConfig) .rcInterpolationChannels = 0, .rcInterpolationInterval = 19, .fpvCamAngleDegrees = 0, - .max_aux_channel = DEFAULT_AUX_CHANNEL_COUNT, - .airModeActivateThreshold = 1350 + .airModeActivateThreshold = 1350, + .max_aux_channel = DEFAULT_AUX_CHANNEL_COUNT ); #ifdef RX_CHANNELS_TAER diff --git a/src/main/rx/rx.h b/src/main/rx/rx.h index 2c8e21248..1b08a1b0a 100644 --- a/src/main/rx/rx.h +++ b/src/main/rx/rx.h @@ -136,11 +136,11 @@ typedef struct rxConfig_s { uint8_t rcInterpolationChannels; uint8_t rcInterpolationInterval; uint8_t fpvCamAngleDegrees; // Camera angle to be scaled into rc commands - uint8_t max_aux_channel; uint16_t airModeActivateThreshold; // Throttle setpoint where airmode gets activated uint16_t rx_min_usec; uint16_t rx_max_usec; + uint8_t max_aux_channel; } rxConfig_t; PG_DECLARE(rxConfig_t, rxConfig); -- 2.11.4.GIT