From dff6a5bff9469086f9801e54bb624109b8c7fdc2 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Fri, 15 Jan 2021 08:44:28 +1100 Subject: [PATCH] HAL_Empty: allow return of last value in RCOutput this is needed for linux boards with no native RCOutput that use SBUS out on a serial port to ensure they can display the servo values in the GCS --- libraries/AP_HAL_Empty/RCOutput.cpp | 18 +++++++++++++++--- libraries/AP_HAL_Empty/RCOutput.h | 2 ++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/libraries/AP_HAL_Empty/RCOutput.cpp b/libraries/AP_HAL_Empty/RCOutput.cpp index e83047bd3e..51747942cb 100644 --- a/libraries/AP_HAL_Empty/RCOutput.cpp +++ b/libraries/AP_HAL_Empty/RCOutput.cpp @@ -1,5 +1,6 @@ #include "RCOutput.h" +#include using namespace Empty; @@ -18,12 +19,23 @@ void RCOutput::disable_ch(uint8_t chan) {} void RCOutput::write(uint8_t chan, uint16_t period_us) -{} +{ + if (chan < ARRAY_SIZE(value)) { + value[chan] = period_us; + } +} -uint16_t RCOutput::read(uint8_t chan) { +uint16_t RCOutput::read(uint8_t chan) +{ + if (chan < ARRAY_SIZE(value)) { + return value[chan]; + } return 900; } void RCOutput::read(uint16_t* period_us, uint8_t len) -{} +{ + len = MIN(len, ARRAY_SIZE(value)); + memcpy(period_us, value, len*sizeof(value[0])); +} diff --git a/libraries/AP_HAL_Empty/RCOutput.h b/libraries/AP_HAL_Empty/RCOutput.h index 18a823c3f5..8f26536e02 100644 --- a/libraries/AP_HAL_Empty/RCOutput.h +++ b/libraries/AP_HAL_Empty/RCOutput.h @@ -13,4 +13,6 @@ class Empty::RCOutput : public AP_HAL::RCOutput { void read(uint16_t* period_us, uint8_t len) override; void cork(void) override {} void push(void) override {} +private: + uint16_t value[16]; };