sensors: rc refactored min max ifs to constrain

This commit is contained in:
Matthias Grob 2017-01-25 17:42:46 +01:00 committed by Lorenz Meier
parent 9527dd7714
commit a14dbdcfdb

View File

@ -161,16 +161,7 @@ RCUpdate::get_rc_value(uint8_t func, float min_value, float max_value)
{
if (_rc.function[func] >= 0) {
float value = _rc.channels[_rc.function[func]];
if (value < min_value) {
return min_value;
} else if (value > max_value) {
return max_value;
} else {
return value;
}
return math::constrain(value, min_value, max_value);
} else {
return 0.0f;