Skip to content

Commit

Permalink
mavlink_receiver: improve rc channel ignore condition readability
Browse files Browse the repository at this point in the history
  • Loading branch information
MaEtUgR committed Jan 24, 2019
1 parent 8da5ad6 commit 9854166
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/modules/mavlink/mavlink_receiver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1863,11 +1863,10 @@ MavlinkReceiver::handle_message_rc_channels_override(mavlink_message_t *msg)

// check how many channels are valid
for (int i = 17; i >= 0; i--) {
// definition: ignore any channel with value UINT16_MAX and channel 8-18 with value 0
const bool ignore_channel = rc.values[i] == UINT16_MAX ||
(rc.values[i] == 0 && (i > 7));
const bool ignore_max = rc.values[i] == UINT16_MAX; // ignore any channel with value UINT16_MAX
const bool ignore_zero = (i > 7) && (rc.values[i] == 0); // ignore channel 8-18 if value is 0

if (ignore_channel) {
if (ignore_max || ignore_zero) {
// set all ignored values to zero
rc.values[i] = 0;

Expand Down

0 comments on commit 9854166

Please sign in to comment.