From 1526adfb44ec33a5d65efe0f0d75b3fe9366446e Mon Sep 17 00:00:00 2001 From: Steve Evans Date: Mon, 10 Jan 2022 01:18:05 +0000 Subject: [PATCH] Ignore duration of calcActiveAdjustmentRanges() and optimize RX_TASK_DECAY_SHIFT --- src/main/fc/rc_adjustments.c | 4 ++++ src/main/fc/tasks.c | 2 +- src/test/unit/rc_controls_unittest.cc | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/fc/rc_adjustments.c b/src/main/fc/rc_adjustments.c index d8fb44a8b1..51b7a0e439 100644 --- a/src/main/fc/rc_adjustments.c +++ b/src/main/fc/rc_adjustments.c @@ -61,6 +61,8 @@ #include "rc_adjustments.h" +#include "scheduler/scheduler.h" + #define ADJUSTMENT_RANGE_COUNT_INVALID -1 PG_REGISTER_ARRAY(adjustmentRange_t, MAX_ADJUSTMENT_RANGE_COUNT, adjustmentRanges, PG_ADJUSTMENT_RANGE_CONFIG, 2); @@ -834,6 +836,8 @@ void processRcAdjustments(controlRateConfig_t *controlRateConfig) // Recalculate the new active adjustments if required if (stepwiseAdjustmentCount == ADJUSTMENT_RANGE_COUNT_INVALID) { + // This can take up to 30us and is only call when not armed so ignore this timing as it doesn't impact flight + schedulerIgnoreTaskExecTime(); calcActiveAdjustmentRanges(); } diff --git a/src/main/fc/tasks.c b/src/main/fc/tasks.c index a8a41c945e..7c9e7e11f9 100644 --- a/src/main/fc/tasks.c +++ b/src/main/fc/tasks.c @@ -115,7 +115,7 @@ // taskUpdateRxMain() has occasional peaks in execution time so normal moving average duration estimation doesn't work // Decay the estimated max task duration by 1/(1 << RX_TASK_DECAY_SHIFT) on every invocation -#define RX_TASK_DECAY_SHIFT 7 +#define RX_TASK_DECAY_SHIFT 6 // Add a margin to the task duration estimation #define RX_TASK_MARGIN 1 diff --git a/src/test/unit/rc_controls_unittest.cc b/src/test/unit/rc_controls_unittest.cc index 6de20d48ae..9ba4b80c54 100644 --- a/src/test/unit/rc_controls_unittest.cc +++ b/src/test/unit/rc_controls_unittest.cc @@ -656,4 +656,5 @@ void setLedProfile(uint8_t profile) { UNUSED(profile); } uint8_t getLedProfile(void) { return 0; } void compassStartCalibration(void) {} void pinioBoxTaskControl(void) {} +void schedulerIgnoreTaskExecTime(void) {} }