diff --git a/libraries/RC_Channel/RC_Channel.h b/libraries/RC_Channel/RC_Channel.h index 1c9202b666..b10e6059b8 100644 --- a/libraries/RC_Channel/RC_Channel.h +++ b/libraries/RC_Channel/RC_Channel.h @@ -152,14 +152,12 @@ public: static uint8_t get_valid_channel_count(void); // returns the number of valid channels in the last read static int16_t get_receiver_rssi(void); // returns [0, 255] for receiver RSSI (0 is no link) if present, otherwise -1 - static bool has_new_input(void); // returns true if there has been new input since last checked + static bool read_input(void); // returns true if new input has been read in static void clear_overrides(void); // clears any active overrides static bool receiver_bind(const int dsmMode); // puts the reciever in bind mode if present, returns true if success static bool set_override(const uint8_t chan, const int16_t value); // set a channels override value static bool set_overrides(int16_t *overrides, const uint8_t len); // set multiple overrides at once - static void set_pwm_all(void); - private: // this static arrangement is to avoid static pointers in AP_Param tables static RC_Channel *channels; diff --git a/libraries/RC_Channel/RC_Channels.cpp b/libraries/RC_Channel/RC_Channels.cpp index 699000529e..8168c0d854 100644 --- a/libraries/RC_Channel/RC_Channels.cpp +++ b/libraries/RC_Channel/RC_Channels.cpp @@ -139,14 +139,20 @@ uint8_t RC_Channels::get_radio_in(uint16_t *chans, const uint8_t num_channels) } /* - call read() and set_pwm() on all channels + call read() and set_pwm() on all channels if there is new data */ -void -RC_Channels::set_pwm_all(void) +bool +RC_Channels::read_input(void) { + if (!hal.rcin->new_input()) { + return false; + } + for (uint8_t i=0; iget_rssi(); } -bool RC_Channels::has_new_input(void) -{ - return hal.rcin->new_input(); -} - void RC_Channels::clear_overrides(void) { hal.rcin->clear_overrides(); diff --git a/libraries/RC_Channel/examples/RC_Channel/RC_Channel.cpp b/libraries/RC_Channel/examples/RC_Channel/RC_Channel.cpp index cfa1e48555..dea463dee3 100644 --- a/libraries/RC_Channel/examples/RC_Channel/RC_Channel.cpp +++ b/libraries/RC_Channel/examples/RC_Channel/RC_Channel.cpp @@ -51,7 +51,7 @@ void setup() void loop() { - RC_Channels::set_pwm_all(); + RC_Channels::read_input(); print_pwm(); hal.scheduler->delay(20);