From 780da9003789bf3d1f5e5bbe3442d82f34fcced1 Mon Sep 17 00:00:00 2001 From: Bruce Luckcuck Date: Fri, 13 Mar 2020 10:50:41 -0400 Subject: [PATCH] Reduce gyro temperature read rate from 250hz to every 3 seconds If the gyro supports it, the temperature is read as part of the telemetry task to be supplied in several protocols. There's absolutely no reason to read the gyro temperature at 250hz for this purpose and the temperature shouldn't be changing rapidly anyway. Revise to read a new temperature every 3 seconds which should be more than sufficient. Has no impact at the moment as no actively used gyro supports temperature reads but may be used in the future. --- src/main/fc/core.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/fc/core.c b/src/main/fc/core.c index c8428bdc9..9bc9f0abb 100644 --- a/src/main/fc/core.c +++ b/src/main/fc/core.c @@ -1157,12 +1157,16 @@ static FAST_CODE_NOINLINE void subTaskPidSubprocesses(timeUs_t currentTimeUs) } #ifdef USE_TELEMETRY +#define GYRO_TEMP_READ_DELAY_US 3e6 // Only read the gyro temp every 3 seconds void subTaskTelemetryPollSensors(timeUs_t currentTimeUs) { - UNUSED(currentTimeUs); + static timeUs_t lastGyroTempTimeUs = 0; - // Read out gyro temperature if used for telemmetry - gyroReadTemperature(); + if (cmpTimeUs(currentTimeUs, lastGyroTempTimeUs) >= GYRO_TEMP_READ_DELAY_US) { + // Read out gyro temperature if used for telemmetry + gyroReadTemperature(); + lastGyroTempTimeUs = currentTimeUs; + } } #endif