diff options
author | px4dev <px4@purgatory.org> | 2012-09-12 08:37:05 -0700 |
---|---|---|
committer | px4dev <px4@purgatory.org> | 2012-09-12 08:37:05 -0700 |
commit | 59b1402379124711a7a28e70dfe58352f9ae48ea (patch) | |
tree | 60ab5c5aabbdd7faf80de41966c7f24f2c2d724c /apps/sensors/sensors.cpp | |
parent | cab1fed3e94c79649a0a8321a33037342ce7d973 (diff) | |
download | px4-firmware-59b1402379124711a7a28e70dfe58352f9ae48ea.tar.gz px4-firmware-59b1402379124711a7a28e70dfe58352f9ae48ea.tar.bz2 px4-firmware-59b1402379124711a7a28e70dfe58352f9ae48ea.zip |
Compute the channel bound once before the loop runs.
Diffstat (limited to 'apps/sensors/sensors.cpp')
-rw-r--r-- | apps/sensors/sensors.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/apps/sensors/sensors.cpp b/apps/sensors/sensors.cpp index fae19b12a..19bceb842 100644 --- a/apps/sensors/sensors.cpp +++ b/apps/sensors/sensors.cpp @@ -950,11 +950,15 @@ Sensors::ppm_poll() if (ppm_decoded_channels < 4) return; + unsigned channel_limit = ppm_decoded_channels; + if (channel_limit > _rc_max_chan_count) + channel_limit = _rc_max_chan_count; + /* we are accepting this decode */ _ppm_last_valid = ppm_last_valid_decode; /* Read out values from HRT */ - for (unsigned int i = 0; (i < ppm_decoded_channels && i < 8); i++) { + for (unsigned int i = 0; channel_limit; i++) { _rc.chan[i].raw = ppm_buffer[i]; /* Set the range to +-, then scale up */ _rc.chan[i].scale = (ppm_buffer[i] - _rc.chan[i].mid) * _rc.chan[i].scaling_factor * 10000; |