Browse Source

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
zr-v5.1
Andrew Tridgell 4 years ago
parent
commit
dff6a5bff9
  1. 18
      libraries/AP_HAL_Empty/RCOutput.cpp
  2. 2
      libraries/AP_HAL_Empty/RCOutput.h

18
libraries/AP_HAL_Empty/RCOutput.cpp

@ -1,5 +1,6 @@ @@ -1,5 +1,6 @@
#include "RCOutput.h"
#include <AP_Math/AP_Math.h>
using namespace Empty;
@ -18,12 +19,23 @@ void RCOutput::disable_ch(uint8_t chan) @@ -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]));
}

2
libraries/AP_HAL_Empty/RCOutput.h

@ -13,4 +13,6 @@ class Empty::RCOutput : public AP_HAL::RCOutput { @@ -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];
};

Loading…
Cancel
Save