proper rounding of FPS

This commit is contained in:
Frank 2023-07-13 12:49:19 +02:00 committed by GitHub
parent 4766666913
commit 72a72dbc88
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1275,7 +1275,7 @@ void WS2812FX::show(void) {
size_t diff = now - _lastShow; size_t diff = now - _lastShow;
size_t fpsCurr = 200; size_t fpsCurr = 200;
if (diff > 0) fpsCurr = 1000 / diff; 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)
_lastShow = now; _lastShow = now;
} }