diff --git a/libraries/SRV_Channel/SRV_Channel.h b/libraries/SRV_Channel/SRV_Channel.h index c5c2e05d89..ffed4315b5 100644 --- a/libraries/SRV_Channel/SRV_Channel.h +++ b/libraries/SRV_Channel/SRV_Channel.h @@ -288,9 +288,9 @@ public: // set output for all channels matching the given function type, allow radio_trim to center servo static void set_output_pwm_trimmed(SRV_Channel::Aux_servo_function_t function, int16_t value); - // set and save the trim for a function channel to radio_in on matching input channel - static void set_trim_to_radio_in_for(SRV_Channel::Aux_servo_function_t function); - + // set and save the trim for a function channel to the output value + static void set_trim_to_servo_out_for(SRV_Channel::Aux_servo_function_t function); + // set the trim for a function channel to min of the channel static void set_trim_to_min_for(SRV_Channel::Aux_servo_function_t function); diff --git a/libraries/SRV_Channel/SRV_Channel_aux.cpp b/libraries/SRV_Channel/SRV_Channel_aux.cpp index ff6c20ac23..b27b216744 100644 --- a/libraries/SRV_Channel/SRV_Channel_aux.cpp +++ b/libraries/SRV_Channel/SRV_Channel_aux.cpp @@ -211,22 +211,18 @@ SRV_Channels::set_output_pwm_trimmed(SRV_Channel::Aux_servo_function_t function, } /* - set and save the trim value to radio_in for all channels matching + set and save the trim value to current output for all channels matching the given function type */ void -SRV_Channels::set_trim_to_radio_in_for(SRV_Channel::Aux_servo_function_t function) +SRV_Channels::set_trim_to_servo_out_for(SRV_Channel::Aux_servo_function_t function) { if (!function_assigned(function)) { return; } for (uint8_t i = 0; i < NUM_SERVO_CHANNELS; i++) { if (channels[i].function.get() == function) { - RC_Channel *rc = RC_Channels::rc_channel(channels[i].ch_num); - if (rc && rc->get_radio_in() != 0) { - rc->set_radio_trim(rc->get_radio_in()); - rc->save_radio_trim(); - } + channels[i].servo_trim.set_and_save_ifchanged(channels[i].output_pwm); } } }