Browse Source

AP_HAL_SITL: RCInput minor fix

fix style
make constructor explicit
remove unused _valid
correct read to return real length instead of fixed 8
correct implicit cast
mission-4.1.18
Pierre Kancir 8 years ago committed by Francisco Ferreira
parent
commit
ff46964d22
No known key found for this signature in database
GPG Key ID: F63C20A6773E787E
  1. 10
      libraries/AP_HAL_SITL/RCInput.cpp
  2. 7
      libraries/AP_HAL_SITL/RCInput.h

10
libraries/AP_HAL_SITL/RCInput.cpp

@ -37,10 +37,10 @@ uint8_t RCInput::read(uint16_t* periods, uint8_t len) @@ -37,10 +37,10 @@ uint8_t RCInput::read(uint16_t* periods, uint8_t len)
if (len > SITL_RC_INPUT_CHANNELS) {
len = SITL_RC_INPUT_CHANNELS;
}
for (uint8_t i=0; i<len; i++) {
for (uint8_t i=0; i < len; i++) {
periods[i] = read(i);
}
return 8;
return len;
}
bool RCInput::set_overrides(int16_t *overrides, uint8_t len)
@ -57,9 +57,11 @@ bool RCInput::set_overrides(int16_t *overrides, uint8_t len) @@ -57,9 +57,11 @@ bool RCInput::set_overrides(int16_t *overrides, uint8_t len)
bool RCInput::set_override(uint8_t channel, int16_t override)
{
if (override < 0) return false; /* -1: no change. */
if (override < 0) {
return false; /* -1: no change. */
}
if (channel < SITL_RC_INPUT_CHANNELS) {
_override[channel] = override;
_override[channel] = static_cast<uint16_t>(override);
if (override != 0) {
return true;
}

7
libraries/AP_HAL_SITL/RCInput.h

@ -9,11 +9,9 @@ @@ -9,11 +9,9 @@
class HALSITL::RCInput : public AP_HAL::RCInput {
public:
RCInput(SITL_State *sitlState) {
_sitlState = sitlState;
}
explicit RCInput(SITL_State *sitlState): _sitlState(sitlState) {}
void init() override;
bool new_input() override;
bool new_input() override;
uint8_t num_channels() override {
return SITL_RC_INPUT_CHANNELS;
}
@ -26,7 +24,6 @@ public: @@ -26,7 +24,6 @@ public:
private:
SITL_State *_sitlState;
bool _valid;
/* override state */
uint16_t _override[SITL_RC_INPUT_CHANNELS];

Loading…
Cancel
Save