Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FastLED/FastLED.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kriegsman <1334634+kriegsman@users.noreply.github.com>2020-01-30 03:55:42 +0300
committerMark Kriegsman <1334634+kriegsman@users.noreply.github.com>2020-01-30 03:55:42 +0300
commit5608ecf7771274a9724d72bc848c33e0026dad7b (patch)
treed7870e2a04d3ee79592eb6ea3d3ae2ef84559afc
parent42441aaa2448c02480846ba6015180347ac61257 (diff)
Prevent divide-by-zero, fixes #881. Thanks to @limpens and @andjoeg for help with this.
-rw-r--r--FastLED.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/FastLED.cpp b/FastLED.cpp
index 94f23021..bfcb73c4 100644
--- a/FastLED.cpp
+++ b/FastLED.cpp
@@ -208,9 +208,12 @@ void CFastLED::countFPS(int nFrames) {
static uint32_t lastframe = 0; // millis();
if(br++ >= nFrames) {
- uint32_t now = millis();
- now -= lastframe;
- m_nFPS = (br * 1000) / now;
+ uint32_t now = millis();
+ now -= lastframe;
+ if( now == 0 ) {
+ now = 1; // prevent division by zero below
+ }
+ m_nFPS = (br * 1000) / now;
br = 0;
lastframe = millis();
}