Skip to content
Snippets Groups Projects
Commit 33e4f444 authored by Kirill A. Kornilov's avatar Kirill A. Kornilov Committed by Andrew Tridgell
Browse files

RC_Channel: added set_radio_trimmed()

take into account trim value in set_radio()
parent 8d543686
No related branches found
No related tags found
No related merge requests found
......@@ -162,6 +162,24 @@ RC_Channel_aux::set_radio(RC_Channel_aux::Aux_servo_function_t function, int16_t
}
}
/*
set radio_out for all channels matching the given function type, allow radio_trim to center servo
*/
void
RC_Channel_aux::set_radio_trimmed(RC_Channel_aux::Aux_servo_function_t function, int16_t value)
{
if (!function_assigned(function)) {
return;
}
for (uint8_t i = 0; i < RC_AUX_MAX_CHANNELS; i++) {
if (_aux_channels[i] && _aux_channels[i]->function.get() == function) {
int16_t value2 = value - 1500 + _aux_channels[i]->radio_trim;
_aux_channels[i]->radio_out = constrain_int16(value2,_aux_channels[i]->radio_min,_aux_channels[i]->radio_max);
_aux_channels[i]->output();
}
}
}
/*
set and save the trim value to radio_in for all channels matching
the given function type
......
......@@ -82,6 +82,9 @@ public:
// set radio_out for a function channel
static void set_radio(Aux_servo_function_t function, int16_t value);
// set radio_out for all channels matching the given function type, allow radio_trim to center servo
static void set_radio_trimmed(Aux_servo_function_t function, int16_t value);
// set and save the trim for a function channel to radio_in
static void set_radio_trim(Aux_servo_function_t function);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment