From e6e30abfeb038e919a694cade0f02731cd1b93df Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Fri, 25 Aug 2023 16:51:07 +0200 Subject: [PATCH] 8266: improve accuracy of FPS calculation based on a similar correction I made in upstream recently. --- wled00/FX_fcn.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 51c4889f..6b45977f 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -1775,16 +1775,18 @@ void WS2812FX::show(void) { estimateCurrentAndLimitBri(); + #if defined(ARDUINO_ARCH_ESP32) && defined(WLEDMM_FASTPATH) + unsigned long b4show = millis(); // WLEDMM the time before calling "show" + #endif // some buses send asynchronously and this method will return before // all of the data has been sent. // See https://github.com/Makuna/NeoPixelBus/wiki/ESP32-NeoMethods#neoesp32rmt-methods - unsigned long b4show = millis(); // WLEDMM the time before calling "show" busses.show(); unsigned long now = millis(); unsigned long diff = now - _lastShow; uint16_t fpsCurr = 200; if (diff > 0) fpsCurr = 1000 / diff; - _cumulativeFps = (3 * _cumulativeFps + fpsCurr) >> 2; + _cumulativeFps = (3 * _cumulativeFps + fpsCurr +2) >> 2; // "+2" for proper rounding (2/4 = 0.5) #if defined(ARDUINO_ARCH_ESP32) && defined(WLEDMM_FASTPATH) _lastShow = b4show; // WLEDMM this is more accurate, however it also icreases CPU load - strip.service will run more frequently #else