SRV_Channel: add ignore reversed flag to set_trim_to_min_for

This commit is contained in:
Iampete1 2021-08-29 12:53:20 +01:00 committed by Randy Mackay
parent 950dcf9242
commit 0a41cdaa24
2 changed files with 5 additions and 5 deletions

View File

@ -396,8 +396,8 @@ public:
// 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);
// set the trim for a function channel to min of the channel honnoring reverse unless ignore_reversed is true
static void set_trim_to_min_for(SRV_Channel::Aux_servo_function_t function, bool ignore_reversed = false);
// set the trim for a function channel to given pwm
static void set_trim_to_pwm_for(SRV_Channel::Aux_servo_function_t function, int16_t pwm);

View File

@ -563,12 +563,12 @@ void SRV_Channels::set_trim_to_pwm_for(SRV_Channel::Aux_servo_function_t functio
}
}
// set the trim for a function channel to min output
void SRV_Channels::set_trim_to_min_for(SRV_Channel::Aux_servo_function_t function)
// set the trim for a function channel to min output of the channel honnoring reverse unless ignore_reversed is true
void SRV_Channels::set_trim_to_min_for(SRV_Channel::Aux_servo_function_t function, bool ignore_reversed)
{
for (uint8_t i=0; i<NUM_SERVO_CHANNELS; i++) {
if (channels[i].function == function) {
channels[i].servo_trim.set(channels[i].get_reversed()?channels[i].servo_max:channels[i].servo_min);
channels[i].servo_trim.set((channels[i].get_reversed() && !ignore_reversed)?channels[i].servo_max:channels[i].servo_min);
}
}
}