diff --git a/libraries/SRV_Channel/SRV_Channel.cpp b/libraries/SRV_Channel/SRV_Channel.cpp index bd3e866acd..46a779d299 100644 --- a/libraries/SRV_Channel/SRV_Channel.cpp +++ b/libraries/SRV_Channel/SRV_Channel.cpp @@ -114,8 +114,10 @@ void SRV_Channel::calc_pwm(int16_t output_scaled) } // check for E - stop + bool force = false; if (SRV_Channel::should_e_stop(get_function()) && SRV_Channels::emergency_stop) { output_scaled = 0; + force = true; } uint16_t pwm; @@ -124,13 +126,15 @@ void SRV_Channel::calc_pwm(int16_t output_scaled) } else { pwm = pwm_from_range(output_scaled); } - set_output_pwm(pwm); + set_output_pwm(pwm,force); } -void SRV_Channel::set_output_pwm(uint16_t pwm) +void SRV_Channel::set_output_pwm(uint16_t pwm, bool force) { - output_pwm = pwm; - have_pwm_mask |= (1U<read_last_sent(c.ch_num); - if (last_pwm == c.output_pwm) { + if (last_pwm == c.get_output_pwm()) { continue; } uint16_t max_change = (c.get_output_max() - c.get_output_min()) * slew_rate * dt * 0.01f; @@ -666,7 +666,7 @@ void SRV_Channels::limit_slew_rate(SRV_Channel::Aux_servo_function_t function, f // change for this loop max_change = 1; } - c.output_pwm = constrain_int16(c.output_pwm, last_pwm-max_change, last_pwm+max_change); + c.set_output_pwm(constrain_int16(c.get_output_pwm(), last_pwm-max_change, last_pwm+max_change)); } } } @@ -708,7 +708,7 @@ void SRV_Channels::constrain_pwm(SRV_Channel::Aux_servo_function_t function) for (uint8_t i=0; i