8266: improve accuracy of FPS calculation

based on a similar correction I made in upstream recently.
This commit is contained in:
Frank
2023-08-25 16:51:07 +02:00
parent 523893be02
commit e6e30abfeb

View File

@@ -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