mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +01:00
Fixed the bounding of servo outputs for the case when max < min
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1444 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
00cad250ea
commit
3530428982
@ -448,9 +448,17 @@ static int16_t scaleChannel(float value, int16_t max, int16_t min, int16_t neutr
|
||||
valueScaled = (int16_t)(value*((float)(neutral-min))) + neutral;
|
||||
}
|
||||
|
||||
if( valueScaled > max ) valueScaled = max;
|
||||
if( valueScaled < min ) valueScaled = min;
|
||||
|
||||
if (max>min)
|
||||
{
|
||||
if( valueScaled > max ) valueScaled = max;
|
||||
if( valueScaled < min ) valueScaled = min;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( valueScaled < max ) valueScaled = max;
|
||||
if( valueScaled > min ) valueScaled = min;
|
||||
}
|
||||
|
||||
return valueScaled;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user