diff --git a/src/main/blackbox/blackbox.c b/src/main/blackbox/blackbox.c index cfa333db7a..d1b732d13a 100644 --- a/src/main/blackbox/blackbox.c +++ b/src/main/blackbox/blackbox.c @@ -1474,6 +1474,10 @@ static bool blackboxWriteSysinfo(void) BLACKBOX_PRINT_HEADER_LINE("vbat_sag_compensation", "%d", currentPidProfile->vbat_sag_compensation); #endif +#if defined(USE_DYN_IDLE) + BLACKBOX_PRINT_HEADER_LINE("dynamic_idle_offset", "%d", currentPidProfile->idle_min_rpm ? lrintf(getDynamicIdleOffset()) : 0); +#endif + default: return true; } diff --git a/src/main/flight/mixer.c b/src/main/flight/mixer.c index b5aa884da8..79fd6eb9be 100644 --- a/src/main/flight/mixer.c +++ b/src/main/flight/mixer.c @@ -65,8 +65,6 @@ #define DYN_LPF_THROTTLE_STEPS 100 #define DYN_LPF_THROTTLE_UPDATE_DELAY_US 5000 // minimum of 5ms between updates -#define RC_COMMAND_THROTTLE_RANGE (PWM_RANGE_MAX - PWM_RANGE_MIN) - static FAST_DATA_ZERO_INIT float motorMixRange; float FAST_DATA_ZERO_INIT motor[MAX_SUPPORTED_MOTORS]; @@ -227,7 +225,7 @@ static void calculateThrottleAndCurrentMotorEndpoints(timeUs_t currentTimeUs) const float pidSum = constrainf(mixerRuntime.idleP * error, -currentPidProfile->idle_pid_limit, currentPidProfile->idle_pid_limit); motorRangeMinIncrease = constrainf(motorRangeMinIncrease + pidSum * pidGetDT(), 0.0f, maxIncrease); mixerRuntime.oldMinRps = minRps; - throttle += mixerRuntime.idleThrottleOffset * RC_COMMAND_THROTTLE_RANGE; + throttle += mixerRuntime.idleThrottleOffset; DEBUG_SET(DEBUG_DYN_IDLE, 0, motorRangeMinIncrease * 1000); DEBUG_SET(DEBUG_DYN_IDLE, 1, targetRpsChangeRate); @@ -254,7 +252,7 @@ static void calculateThrottleAndCurrentMotorEndpoints(timeUs_t currentTimeUs) motorRangeMax = mixerRuntime.motorOutputHigh; #endif - currentThrottleInputRange = RC_COMMAND_THROTTLE_RANGE; + currentThrottleInputRange = PWM_RANGE; motorRangeMin = mixerRuntime.motorOutputLow + motorRangeMinIncrease * (mixerRuntime.motorOutputHigh - mixerRuntime.motorOutputLow); motorOutputMin = motorRangeMin; motorOutputRange = motorRangeMax - motorRangeMin; diff --git a/src/main/flight/mixer.h b/src/main/flight/mixer.h index 61e4785d86..454675d1a9 100644 --- a/src/main/flight/mixer.h +++ b/src/main/flight/mixer.h @@ -117,3 +117,4 @@ bool isFixedWing(void); float getMotorOutputLow(void); float getMotorOutputHigh(void); +float getDynamicIdleOffset(void); diff --git a/src/main/flight/mixer_init.c b/src/main/flight/mixer_init.c index 67b336008a..db6674dd8a 100644 --- a/src/main/flight/mixer_init.c +++ b/src/main/flight/mixer_init.c @@ -396,6 +396,11 @@ static void mixerConfigureOutput(void) } #endif // USE_QUAD_MIXER_ONLY +float getDynamicIdleOffset(void) +{ + return motorConfig()->digitalIdleOffsetValue * 0.0001f * PWM_RANGE; +} + void mixerInit(mixerMode_e mixerMode) { currentMixerMode = mixerMode; @@ -410,7 +415,7 @@ void mixerInit(mixerMode_e mixerMode) #endif #ifdef USE_DYN_IDLE - mixerRuntime.idleThrottleOffset = motorConfig()->digitalIdleOffsetValue * 0.0001f; + mixerRuntime.idleThrottleOffset = getDynamicIdleOffset(); #endif mixerConfigureOutput(); diff --git a/src/main/rx/rx.h b/src/main/rx/rx.h index da5d400378..54540967af 100644 --- a/src/main/rx/rx.h +++ b/src/main/rx/rx.h @@ -31,7 +31,8 @@ #define PWM_RANGE_MIN 1000 #define PWM_RANGE_MAX 2000 -#define PWM_RANGE_MIDDLE (PWM_RANGE_MIN + ((PWM_RANGE_MAX - PWM_RANGE_MIN) / 2)) +#define PWM_RANGE (PWM_RANGE_MAX - PWM_RANGE_MIN) +#define PWM_RANGE_MIDDLE (PWM_RANGE_MIN + (PWM_RANGE / 2)) #define PWM_PULSE_MIN 750 // minimum PWM pulse width which is considered valid #define PWM_PULSE_MAX 2250 // maximum PWM pulse width which is considered valid