SRV_Channel: use set_and_default method

This commit is contained in:
Iampete1 2022-07-05 02:47:21 +01:00 committed by Andrew Tridgell
parent c87d46e24d
commit 7ee330d12d
1 changed files with 7 additions and 7 deletions

View File

@ -280,12 +280,12 @@ void SRV_Channels::set_digital_outputs(uint32_t dig_mask, uint32_t rev_mask) {
for (uint8_t i = 0; i < NUM_SERVO_CHANNELS; i++) { for (uint8_t i = 0; i < NUM_SERVO_CHANNELS; i++) {
SRV_Channel &c = channels[i]; SRV_Channel &c = channels[i];
if (digital_mask & (1U<<i)) { if (digital_mask & (1U<<i)) {
c.servo_min.set(1000); c.servo_min.set_and_default(1000);
c.servo_max.set(2000); c.servo_max.set_and_default(2000);
if (reversible_mask & (1U<<i)) { if (reversible_mask & (1U<<i)) {
c.servo_trim.set(1500); c.servo_trim.set_and_default(1500);
} else { } else {
c.servo_trim.set(1000); c.servo_trim.set_and_default(1000);
} }
} }
} }
@ -518,7 +518,7 @@ bool SRV_Channels::set_aux_channel_default(SRV_Channel::Aux_servo_function_t fun
return false; return false;
} }
channels[channel].type_setup = false; channels[channel].type_setup = false;
channels[channel].function.set(function); channels[channel].function.set_and_default(function);
channels[channel].aux_servo_function_setup(); channels[channel].aux_servo_function_setup();
function_mask.set((uint16_t)function); function_mask.set((uint16_t)function);
if (SRV_Channel::valid_function(function)) { if (SRV_Channel::valid_function(function)) {
@ -612,7 +612,7 @@ void SRV_Channels::set_trim_to_pwm_for(SRV_Channel::Aux_servo_function_t functio
{ {
for (uint8_t i=0; i<NUM_SERVO_CHANNELS; i++) { for (uint8_t i=0; i<NUM_SERVO_CHANNELS; i++) {
if (channels[i].function == function) { if (channels[i].function == function) {
channels[i].servo_trim.set(pwm); channels[i].servo_trim.set_and_default(pwm);
} }
} }
} }
@ -622,7 +622,7 @@ void SRV_Channels::set_trim_to_min_for(SRV_Channel::Aux_servo_function_t functio
{ {
for (uint8_t i=0; i<NUM_SERVO_CHANNELS; i++) { for (uint8_t i=0; i<NUM_SERVO_CHANNELS; i++) {
if (channels[i].function == function) { if (channels[i].function == function) {
channels[i].servo_trim.set((channels[i].get_reversed() && !ignore_reversed)?channels[i].servo_max:channels[i].servo_min); channels[i].servo_trim.set_and_default((channels[i].get_reversed() && !ignore_reversed)?channels[i].servo_max:channels[i].servo_min);
} }
} }
} }