1
0
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:
andrew 2010-08-28 05:11:19 +00:00 committed by andrew
parent 00cad250ea
commit 3530428982

View File

@ -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;
}