From 0833aab88664f83a834c2c496470b63d83da8afc Mon Sep 17 00:00:00 2001 From: ctzsnooze Date: Sun, 13 Sep 2020 12:11:09 +1000 Subject: [PATCH] maybe more efficient? --- src/main/flight/interpolated_setpoint.c | 26 +++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/main/flight/interpolated_setpoint.c b/src/main/flight/interpolated_setpoint.c index 296c44f8e6..5869dbe7e7 100644 --- a/src/main/flight/interpolated_setpoint.c +++ b/src/main/flight/interpolated_setpoint.c @@ -102,19 +102,21 @@ FAST_CODE_NOINLINE float interpolatedSpApply(int axis, bool newRcFrame, ffInterp } } else { // we have movement; let's consider what happened on previous packets, using ffStatus - if (ffStatus[axis] == 1) { - // was interpolated forward after previous dropped packet after small step - // this step is likely twice as tall as it should be - setpointSpeed = setpointSpeed / 2.0f; - } else if (ffStatus[axis] == 2) { - // we are doing nothing for these to avoid exaggerating the FrSky early packet problem - } else if (ffStatus[axis] == 3) { - // movement after nothing on previous two packets - // reduce boost when higher averaging is used to improve slow stick smoothness - setpointAccelerationModifier /= (averagingCount + 1); + if (ffStatus[axis] != 0) { + if (ffStatus[axis] == 1) { + // was interpolated forward after previous dropped packet after small step + // this step is likely twice as tall as it should be + setpointSpeed = setpointSpeed / 2.0f; + } else if (ffStatus[axis] == 2) { + // we are doing nothing for these to avoid exaggerating the FrSky early packet problem + } else if (ffStatus[axis] == 3) { + // movement after nothing on previous two packets + // reduce boost when higher averaging is used to improve slow stick smoothness + setpointAccelerationModifier /= (averagingCount + 1); + } + ffStatus[axis] = 0; + // all is normal } - ffStatus[axis] = 0; - // all is normal } float setpointAcceleration = setpointSpeed - prevSetpointSpeed[axis];