From cba6d290dc9e3fc0ce74530ab67f40821dbc68d1 Mon Sep 17 00:00:00 2001 From: Ray Morris Date: Tue, 23 Dec 2025 09:31:02 -0600 Subject: [PATCH] Reduce CPU overhead by rate-limiting updateArmingStatus() to 200 Hz The updateArmingStatus() function performs 20+ safety checks (GPS fix, battery voltage, sensor health, LED updates, etc.) that don't need millisecond-level updates. Previously called every PID loop iteration (2000 Hz), now rate-limited to 200 Hz. Testing on AT32F435 hardware showed 10-13% PID loop performance improvement with no functional impact. 200 Hz (5ms response time) is well within human reaction time (~200ms) and exceeds the update rate of the sensors being checked (GPS: 5-10 Hz, battery: slow). --- src/main/fc/fc_core.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/fc/fc_core.c b/src/main/fc/fc_core.c index ce874c8aedc..c96979edd0f 100644 --- a/src/main/fc/fc_core.c +++ b/src/main/fc/fc_core.c @@ -943,7 +943,12 @@ void taskMainPidLoop(timeUs_t currentTimeUs) processPilotAndFailSafeActions(dT); - updateArmingStatus(); + // Check battery, GPS signal, arming status etc @ 200 Hz + static uint8_t armingStatusDivider = 0; + if (++armingStatusDivider >= 10) { + armingStatusDivider = 0; + updateArmingStatus(); + } if (rxConfig()->rcFilterFrequency) { rcInterpolationApply(isRXDataNew, currentTimeUs);