From 7ec0cad04db10adba5beb1cca092362e7574eea1 Mon Sep 17 00:00:00 2001 From: proddy Date: Sat, 5 Sep 2020 21:31:27 +0200 Subject: [PATCH] fix codacy from complaining about "The scope of the variable 'sum_' can be reduced." --- src/system.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/system.cpp b/src/system.cpp index b22300498..de2484925 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -243,7 +243,6 @@ void System::send_heartbeat() { // measure and moving average adc void System::measure_analog() { static uint32_t measure_last_ = 0; - static uint32_t sum_ = 0; if (!measure_last_ || (uint32_t)(uuid::get_uptime() - measure_last_) >= SYSTEM_MEASURE_ANALOG_INTERVAL) { measure_last_ = uuid::get_uptime(); @@ -252,6 +251,8 @@ void System::measure_analog() { #elif defined(ESP32) uint16_t a = analogRead(36); #endif + static uint32_t sum_ = 0; + if (!analog_) { // init first time analog_ = a; sum_ = a * 256;