diff --git a/libraries/SRV_Channel/SRV_Channel.h b/libraries/SRV_Channel/SRV_Channel.h index e4778b2773..acb6021b89 100644 --- a/libraries/SRV_Channel/SRV_Channel.h +++ b/libraries/SRV_Channel/SRV_Channel.h @@ -373,6 +373,9 @@ public: // set output value for a specific function channel as a pwm value static void set_output_pwm_chan(uint8_t chan, uint16_t value); + // get output value for a specific channel as a pwm value + static bool get_output_pwm_chan(uint8_t chan, uint16_t &value); + // set output value for a specific function channel as a pwm value for specified override time in ms static void set_output_pwm_chan_timeout(uint8_t chan, uint16_t value, uint16_t timeout_ms); diff --git a/libraries/SRV_Channel/SRV_Channels.cpp b/libraries/SRV_Channel/SRV_Channels.cpp index c1fda6226c..292aa2bcac 100644 --- a/libraries/SRV_Channel/SRV_Channels.cpp +++ b/libraries/SRV_Channel/SRV_Channels.cpp @@ -434,6 +434,16 @@ void SRV_Channels::set_output_pwm_chan(uint8_t chan, uint16_t value) } } +// get output value for a specific channel as a pwm value +bool SRV_Channels::get_output_pwm_chan(uint8_t chan, uint16_t &value) +{ + if (chan >= NUM_SERVO_CHANNELS) { + return false; + } + value = channels[chan].get_output_pwm(); + return true; +} + #if AP_SCRIPTING_ENABLED && AP_SCHEDULER_ENABLED // set output value for a specific function channel as a pwm value with loop based timeout // timeout_ms of zero will clear override of the channel