From d53c0a31e96d63f66d4805b14d29608d4350ed79 Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Wed, 6 Nov 2024 13:18:33 +0100 Subject: [PATCH] FPS calculation minor improvement seems to work better without rounding --- wled00/FX_fcn.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 66c787a6..4ac95069 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -2086,7 +2086,7 @@ void WS2812FX::show(void) { #ifdef ARDUINO_ARCH_ESP32 // WLEDMM more accurate FPS measurement for ESP32 int64_t diff500 = now500 - _lastShow500; - if ((diff500 > 300) && (diff500 < 800000)) { // exclude stupid values (timer rollover, major hickups) + if ((diff500 > 1) && (diff500 < 800000)) { // exclude stupid values (timer rollover, major hickups) float fpcCurr500 = 500000.0f / float(diff500); if (fpcCurr500 > 2) _cumulativeFps500 = (3 * _cumulativeFps500 + (500.0 * fpcCurr500)) / 4; // average for some smoothing @@ -2118,7 +2118,8 @@ uint16_t WS2812FX::getFps() const { void WS2812FX::setTargetFps(uint8_t fps) { if (fps <= 251) _targetFps = fps; // WLEDMM allow higher framerates - if (fps > 0) _frametime = ((2000 / _targetFps) +1) /2; // with rounding + //if (fps > 0) _frametime = ((2000 / _targetFps) +1) /2; // with rounding + if (fps > 0) _frametime = 1000 / _targetFps; else _frametime = 2; // AC WLED compatibility if (fps >= FPS_UNLIMITED) _frametime = 2; // WLEDMM unlimited mode }