diff --git a/src/main/blackbox/blackbox.c b/src/main/blackbox/blackbox.c index 7869a48ebf..2ac8a360eb 100644 --- a/src/main/blackbox/blackbox.c +++ b/src/main/blackbox/blackbox.c @@ -1333,6 +1333,7 @@ static bool blackboxWriteSysinfo(void) BLACKBOX_PRINT_HEADER_LINE("rc_smoothing_debug_axis", "%d", rxConfig()->rc_smoothing_debug_axis); BLACKBOX_PRINT_HEADER_LINE("rc_smoothing_cutoffs", "%d, %d", rxConfig()->rc_smoothing_input_cutoff, rxConfig()->rc_smoothing_derivative_cutoff); + BLACKBOX_PRINT_HEADER_LINE("rc_smoothing_auto_factor", "%d", rxConfig()->rc_smoothing_auto_factor); BLACKBOX_PRINT_HEADER_LINE("rc_smoothing_filter_type", "%d, %d", rxConfig()->rc_smoothing_input_type, rxConfig()->rc_smoothing_derivative_type); BLACKBOX_PRINT_HEADER_LINE("rc_smoothing_active_cutoffs", "%d, %d", rcSmoothingGetValue(RC_SMOOTHING_VALUE_INPUT_ACTIVE), diff --git a/src/main/fc/rc.c b/src/main/fc/rc.c index e76d0834d5..63fabb514d 100644 --- a/src/main/fc/rc.c +++ b/src/main/fc/rc.c @@ -288,8 +288,9 @@ FAST_CODE uint8_t processRcInterpolation(void) FAST_CODE_NOINLINE int calcRcSmoothingCutoff(int avgRxFrameTimeUs, bool pt1) { if (avgRxFrameTimeUs > 0) { + const float cutoffFactor = (100 - rxConfig()->rc_smoothing_auto_factor) / 100.0f; float cutoff = (1 / (avgRxFrameTimeUs * 1e-6f)) / 2; // calculate the nyquist frequency - cutoff = cutoff * 0.90f; // Use 90% of the calculated nyquist frequency + cutoff = cutoff * cutoffFactor; if (pt1) { cutoff = sq(cutoff) / RC_SMOOTHING_IDENTITY_FREQUENCY; // convert to a cutoff for pt1 that has similar characteristics diff --git a/src/main/interface/settings.c b/src/main/interface/settings.c index 1ffcf48abc..fccc576e5d 100644 --- a/src/main/interface/settings.c +++ b/src/main/interface/settings.c @@ -631,6 +631,7 @@ const clivalue_t valueTable[] = { { "rc_smoothing_debug_axis", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_RC_SMOOTHING_DEBUG }, PG_RX_CONFIG, offsetof(rxConfig_t, rc_smoothing_debug_axis) }, { "rc_smoothing_input_type", VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_RC_SMOOTHING_INPUT_TYPE }, PG_RX_CONFIG, offsetof(rxConfig_t, rc_smoothing_input_type) }, { "rc_smoothing_derivative_type",VAR_UINT8 | MASTER_VALUE | MODE_LOOKUP, .config.lookup = { TABLE_RC_SMOOTHING_DERIVATIVE_TYPE }, PG_RX_CONFIG, offsetof(rxConfig_t, rc_smoothing_derivative_type) }, + { "rc_smoothing_auto_smoothness",VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 50 }, PG_RX_CONFIG, offsetof(rxConfig_t, rc_smoothing_auto_factor) }, #endif // USE_RC_SMOOTHING_FILTER { "fpv_mix_degrees", VAR_UINT8 | MASTER_VALUE, .config.minmax = { 0, 90 }, PG_RX_CONFIG, offsetof(rxConfig_t, fpvCamAngleDegrees) }, diff --git a/src/main/pg/rx.c b/src/main/pg/rx.c index e106da5f09..8454e803d4 100644 --- a/src/main/pg/rx.c +++ b/src/main/pg/rx.c @@ -67,6 +67,7 @@ void pgResetFn_rxConfig(rxConfig_t *rxConfig) .rc_smoothing_debug_axis = ROLL, // default to debug logging for the roll axis .rc_smoothing_input_type = RC_SMOOTHING_INPUT_BIQUAD, .rc_smoothing_derivative_type = RC_SMOOTHING_DERIVATIVE_BIQUAD, + .rc_smoothing_auto_factor = 10, ); #ifdef RX_CHANNELS_TAER diff --git a/src/main/pg/rx.h b/src/main/pg/rx.h index b878f45f49..465ef91042 100644 --- a/src/main/pg/rx.h +++ b/src/main/pg/rx.h @@ -56,6 +56,7 @@ typedef struct rxConfig_s { uint8_t rc_smoothing_debug_axis; // Axis to log as debug values when debug_mode = RC_SMOOTHING uint8_t rc_smoothing_input_type; // Input filter type (0 = PT1, 1 = BIQUAD) uint8_t rc_smoothing_derivative_type; // Derivative filter type (0 = OFF, 1 = PT1, 2 = BIQUAD) + uint8_t rc_smoothing_auto_factor; // Used to adjust the "smoothness" determined by the auto cutoff calculations } rxConfig_t; PG_DECLARE(rxConfig_t, rxConfig);