RC_Channel: prevent a numerical exception with bad mount parameters

This commit is contained in:
Andrew Tridgell 2014-03-26 17:38:27 +11:00
parent bafc664750
commit 8c0c9c317e

View File

@ -325,6 +325,9 @@ RC_Channel::pwm_to_range()
int16_t
RC_Channel::range_to_pwm()
{
if (_high_out == _low_out) {
return radio_trim;
}
return ((long)(servo_out - _low_out) * (long)(radio_max - radio_min)) / (long)(_high_out - _low_out);
}