RC_Channel: add method to get current radio out for a function

This commit is contained in:
Peter Barker 2016-11-18 14:13:32 +11:00
parent 23480a92ad
commit 319cfa766b
2 changed files with 21 additions and 0 deletions

View File

@ -208,6 +208,24 @@ RC_Channel_aux::set_radio(RC_Channel_aux::Aux_servo_function_t function, int16_t
}
}
/*
get radio_out for *first* channel matching the given function type.
Returns true if a value was found.
*/
bool RC_Channel_aux::get_radio(RC_Channel_aux::Aux_servo_function_t function, int16_t &value)
{
if (!function_assigned(function)) {
return false;
}
for (uint8_t i = 0; i < RC_AUX_MAX_CHANNELS; i++) {
if (_aux_channels[i] && _aux_channels[i]->function.get() == function) {
value = _aux_channels[i]->get_radio_out();
return true;
}
}
return false;
}
/*
set radio_out for all channels matching the given function type, allow radio_trim to center servo
*/

View File

@ -107,6 +107,9 @@ public:
// set radio_out for a function channel
static void set_radio(Aux_servo_function_t function, int16_t value);
// get radio_out for *first* channel matching the given function type.
static bool get_radio(RC_Channel_aux::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);