mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-01-18 03:52:11 +01:00
Flight/ManualControl Added support for reversing inputs
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@685 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
c22804e90a
commit
6414887dcc
@ -192,13 +192,27 @@ static float scaleChannel(int16_t value, int16_t max, int16_t min, int16_t neutr
|
||||
{
|
||||
float valueScaled;
|
||||
// Scale
|
||||
if ( value >= neutral)
|
||||
if ( (max > min && value >= neutral) || (min > max && value <= neutral) )
|
||||
{
|
||||
valueScaled = (float)(value-neutral)/(float)(max-neutral);
|
||||
if ( max != neutral )
|
||||
{
|
||||
valueScaled = (float)(value-neutral)/(float)(max-neutral);
|
||||
}
|
||||
else
|
||||
{
|
||||
valueScaled = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
valueScaled = (float)(value-neutral)/(float)(neutral-min);
|
||||
if ( min != neutral )
|
||||
{
|
||||
valueScaled = (float)(value-neutral)/(float)(neutral-min);
|
||||
}
|
||||
else
|
||||
{
|
||||
valueScaled = 0;
|
||||
}
|
||||
}
|
||||
// Bound
|
||||
if ( valueScaled > 1.0 )
|
||||
|
Loading…
x
Reference in New Issue
Block a user