@ -345,7 +345,7 @@ void Plane::set_servos_manual_passthrough(void)
@@ -345,7 +345,7 @@ void Plane::set_servos_manual_passthrough(void)
/*
Scale the throttle to conpensate for battery voltage drop
*/
void Plane : : throttle_voltage_comp ( )
void Plane : : throttle_voltage_comp ( int8_t & min_throttle , int8_t & max_throttle )
{
// return if not enabled, or setup incorrectly
if ( g2 . fwd_thr_batt_voltage_min > = g2 . fwd_thr_batt_voltage_max | | ! is_positive ( g2 . fwd_thr_batt_voltage_max ) ) {
@ -370,6 +370,10 @@ void Plane::throttle_voltage_comp()
@@ -370,6 +370,10 @@ void Plane::throttle_voltage_comp()
// Ratio = 1 when voltage = voltage max, ratio increases as voltage drops
const float ratio = g2 . fwd_thr_batt_voltage_max / batt_voltage_resting_estimate ;
// Scale the throttle limits to prevent subsequent clipping
min_throttle = MAX ( ( int8_t ) ( ratio * ( float ) min_throttle ) , - 100 ) ;
max_throttle = MIN ( ( int8_t ) ( ratio * ( float ) max_throttle ) , 100 ) ;
SRV_Channels : : set_output_scaled ( SRV_Channel : : k_throttle ,
constrain_int16 ( SRV_Channels : : get_output_scaled ( SRV_Channel : : k_throttle ) * ratio , - 100 , 100 ) ) ;
}
@ -455,7 +459,7 @@ void Plane::set_servos_controlled(void)
@@ -455,7 +459,7 @@ void Plane::set_servos_controlled(void)
}
// conpensate for battery voltage drop
throttle_voltage_comp ( ) ;
throttle_voltage_comp ( min_throttle , max_throttle ) ;
// apply watt limiter
throttle_watt_limiter ( min_throttle , max_throttle ) ;