Skip to content

Commit a6207a1

Browse files
authored
Merge pull request #11468 from daleckystepan/fix_rc_smoothing
Fix compilation without RC smoothing enabled
2 parents 61f43fe + d296853 commit a6207a1

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/main/fc/rc.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ float rcCommandDelta[XYZ_AXIS_COUNT];
6464
#endif
6565
static float rawSetpoint[XYZ_AXIS_COUNT];
6666
static float setpointRate[3], rcDeflection[3], rcDeflectionAbs[3];
67-
static float rcDeflectionSmoothed[3];
6867
static bool reverseMotors = false;
6968
static applyRatesFn *applyRates;
7069
static uint16_t currentRxRefreshRate;
@@ -90,13 +89,15 @@ enum {
9089
#define RC_SMOOTHING_FILTER_TRAINING_DELAY_MS 1000 // Additional time to wait after receiving first valid rx frame before initial training starts
9190
#define RC_SMOOTHING_FILTER_RETRAINING_DELAY_MS 2000 // Guard time to wait after retraining to prevent retraining again too quickly
9291
#define RC_SMOOTHING_RX_RATE_CHANGE_PERCENT 20 // Look for samples varying this much from the current detected frame rate to initiate retraining
93-
#define RC_SMOOTHING_RX_RATE_MIN_US 950 // 0.950ms to fit 1kHz without an issue
94-
#define RC_SMOOTHING_RX_RATE_MAX_US 65500 // 65.5ms or 15.26hz
9592
#define RC_SMOOTHING_FEEDFORWARD_INITIAL_HZ 100 // The value to use for "auto" when interpolated feedforward is enabled
9693

9794
static FAST_DATA_ZERO_INIT rcSmoothingFilter_t rcSmoothingData;
95+
static float rcDeflectionSmoothed[3];
9896
#endif // USE_RC_SMOOTHING_FILTER
9997

98+
#define RC_RX_RATE_MIN_US 950 // 0.950ms to fit 1kHz without an issue
99+
#define RC_RX_RATE_MAX_US 65500 // 65.5ms or 15.26hz
100+
100101
bool getShouldUpdateFeedforward()
101102
// only used in pid.c, when feedforward is enabled, to initiate a new FF value
102103
{
@@ -302,8 +303,8 @@ void updateRcRefreshRate(timeUs_t currentTimeUs)
302303
refreshRateUs = cmpTimeUs(currentTimeUs, lastRxTimeUs); // calculate a delta here if not supplied by the protocol
303304
}
304305
lastRxTimeUs = currentTimeUs;
305-
isRxRateValid = (refreshRateUs >= RC_SMOOTHING_RX_RATE_MIN_US && refreshRateUs <= RC_SMOOTHING_RX_RATE_MAX_US);
306-
currentRxRefreshRate = constrain(refreshRateUs, RC_SMOOTHING_RX_RATE_MIN_US, RC_SMOOTHING_RX_RATE_MAX_US);
306+
isRxRateValid = (refreshRateUs >= RC_RX_RATE_MIN_US && refreshRateUs <= RC_RX_RATE_MAX_US);
307+
currentRxRefreshRate = constrain(refreshRateUs, RC_RX_RATE_MIN_US, RC_RX_RATE_MAX_US);
307308
}
308309

309310
uint16_t getCurrentRxRefreshRate(void)

0 commit comments

Comments
 (0)