diff --git a/src/main/io/rc_controls.c b/src/main/io/rc_controls.c index fdde2cf..53464ef 100644 --- a/src/main/io/rc_controls.c +++ b/src/main/io/rc_controls.c @@ -67,6 +67,7 @@ static pidProfile_t *pidProfile; static bool isUsingSticksToArm = true;  int16_t rcCommand[4]; // interval [1000;2000] for THROTTLE and [-500;+500] for ROLL/PITCH/YAW +int16_t rcCommandSmooth[4]; // Smoothed RcCommand  uint32_t rcModeActivationMask; // one bit per mode defined in boxId_e  diff --git a/src/main/io/rc_controls.h b/src/main/io/rc_controls.h index eaec277..dd8afaf 100644 --- a/src/main/io/rc_controls.h +++ b/src/main/io/rc_controls.h @@ -147,6 +147,7 @@ typedef struct controlRateConfig_s { } controlRateConfig_t;  extern int16_t rcCommand[4]; +extern int16_t rcCommandSmooth[4]; // Smoothed RcCommand  typedef struct rcControlsConfig_s { uint8_t deadband; // introduce a deadband around the stick center for pitch and roll axis. Must be greater than zero. diff --git a/src/main/mw.c b/src/main/mw.c index 125674c..5da79cf 100644 --- a/src/main/mw.c +++ b/src/main/mw.c @@ -181,7 +181,7 @@ void filterRc(void)  if (isRXDataNew) { for (int channel=0; channel < 4; channel++) { - deltaRC[channel] = rcCommand[channel] - (lastCommand[channel] - deltaRC[channel] * factor / rcInterpolationFactor); + deltaRC[channel] = rcCommand[channel] - (lastCommand[channel] - deltaRC[channel] * factor / rcInterpolationFactor); lastCommand[channel] = rcCommand[channel]; }  @@ -194,7 +194,7 @@ void filterRc(void) // Interpolate steps of rcCommand if (factor > 0) { for (int channel=0; channel < 4; channel++) { - rcCommand[channel] = lastCommand[channel] - deltaRC[channel] * factor/rcInterpolationFactor; + rcCommandSmooth[channel] = lastCommand[channel] - deltaRC[channel] * factor/rcInterpolationFactor; } } else { factor = 0; @@ -649,8 +649,11 @@ void subTaskMainSubprocesses(void) {  const uint32_t startTime = micros();  + filterRc(); + if (masterConfig.rxConfig.rcSmoothing || flightModeFlags) { - filterRc(); + int axis; + for (axis = 0; axis <= 4; axis++) rcCommand[axis] = rcCommandSmooth[axis]; }  // Read out gyro temperature. can use it for something somewhere. maybe get MCU temperature instead? lots of fun possibilities.