diff --git a/src/Kaleidoscope-LEDEffect-Breathe.cpp b/src/Kaleidoscope-LEDEffect-Breathe.cpp index c3ba8432..debcb0b4 100644 --- a/src/Kaleidoscope-LEDEffect-Breathe.cpp +++ b/src/Kaleidoscope-LEDEffect-Breathe.cpp @@ -15,9 +15,15 @@ */ #include "Kaleidoscope-LEDEffect-Breathe.h" +#define UPDATE_INTERVAL 50 // milliseconds between two LED updates to avoid overloading; 20 fps namespace kaleidoscope { void LEDBreatheEffect::update(void) { + uint16_t now = millis(); + if ((now - last_update) < UPDATE_INTERVAL) + return; + last_update = now; + cRGB color = breath_compute(hue, saturation); ::LEDControl.set_all_leds_to(color); } diff --git a/src/Kaleidoscope-LEDEffect-Breathe.h b/src/Kaleidoscope-LEDEffect-Breathe.h index 8eef07ba..39fc2a55 100644 --- a/src/Kaleidoscope-LEDEffect-Breathe.h +++ b/src/Kaleidoscope-LEDEffect-Breathe.h @@ -29,6 +29,9 @@ class LEDBreatheEffect : public LEDMode { protected: void update(void) final; + + private: + uint16_t last_update = 0; }; }