From 024e5c3cc7c9965f43e44a779761f57d5d253b12 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 31 Oct 2012 12:38:26 +1100 Subject: [PATCH] RC_Channel: added set_radio() and set_radio_to_trim() functions --- libraries/RC_Channel/RC_Channel_aux.cpp | 26 +++++++++++++++++++++++++ libraries/RC_Channel/RC_Channel_aux.h | 6 ++++++ 2 files changed, 32 insertions(+) diff --git a/libraries/RC_Channel/RC_Channel_aux.cpp b/libraries/RC_Channel/RC_Channel_aux.cpp index a6488a5de3..c5cc14b951 100644 --- a/libraries/RC_Channel/RC_Channel_aux.cpp +++ b/libraries/RC_Channel/RC_Channel_aux.cpp @@ -99,6 +99,19 @@ enable_aux_servos() } } +/* + set radio_out for all channels matching the given function type + */ +void +RC_Channel_aux::set_radio(RC_Channel_aux::Aux_servo_function_t function, int16_t value) +{ + for (uint8_t i = 0; i < 7; i++) { + if (_aux_channels[i] && _aux_channels[i]->function.get() == function) { + _aux_channels[i]->radio_out = value; + } + } +} + /* set and save the trim value to radio_in for all channels matching @@ -141,6 +154,19 @@ RC_Channel_aux::set_radio_to_max(RC_Channel_aux::Aux_servo_function_t function) } } +/* + set the radio_out value for any channel with the given function to radio_trim + */ +void +RC_Channel_aux::set_radio_to_trim(RC_Channel_aux::Aux_servo_function_t function) +{ + for (uint8_t i = 0; i < 7; i++) { + if (_aux_channels[i] && _aux_channels[i]->function.get() == function) { + _aux_channels[i]->radio_out = _aux_channels[i]->radio_trim; + } + } +} + /* copy radio_in to radio_out for a given function */ diff --git a/libraries/RC_Channel/RC_Channel_aux.h b/libraries/RC_Channel/RC_Channel_aux.h index c4cb4433bc..4bbd9148d0 100644 --- a/libraries/RC_Channel/RC_Channel_aux.h +++ b/libraries/RC_Channel/RC_Channel_aux.h @@ -50,6 +50,9 @@ public: void output_ch(unsigned char ch_nr); + // set radio_out for a function channel + static void set_radio(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); @@ -59,6 +62,9 @@ public: // set radio_out to radio_max static void set_radio_to_max(Aux_servo_function_t function); + // set radio_out to radio_trim + static void set_radio_to_trim(Aux_servo_function_t function); + // copy radio_in to radio_out static void copy_radio_in_out(Aux_servo_function_t function);