1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-23 08:15:26 +03:00

Cleanup rc_modes.c

- Replace usages of 25 as a magic number with CHANNEL_RANGE_STEP_WIDTH
- Remove constrain() call from isRangeActive(), since it's not needed

Should slightly improve performance and saves 24 bytes of flash.
This commit is contained in:
Alberto García Hierro 2018-06-25 16:08:20 +01:00
parent 6a9cf337e2
commit 59eac2b046
2 changed files with 11 additions and 6 deletions

View file

@ -99,9 +99,12 @@ bool isRangeActive(uint8_t auxChannelIndex, const channelRange_t *range)
return false;
}
uint16_t channelValue = constrain(rcData[auxChannelIndex + NON_AUX_CHANNEL_COUNT], CHANNEL_RANGE_MIN, CHANNEL_RANGE_MAX - 1);
return (channelValue >= 900 + (range->startStep * 25) &&
channelValue < 900 + (range->endStep * 25));
// No need to constrain() here, since we're testing for a closed range defined
// by the channelRange_t. If channelValue has an invalid value, the test will
// be false anyway.
uint16_t channelValue = rcData[auxChannelIndex + NON_AUX_CHANNEL_COUNT];
return (channelValue >= CHANNEL_RANGE_MIN + (range->startStep * CHANNEL_RANGE_STEP_WIDTH) &&
channelValue < CHANNEL_RANGE_MIN + (range->endStep * CHANNEL_RANGE_STEP_WIDTH));
}
void updateActivatedModes(void)