Merge pull request #7 from jamadagni/limit-refresh-rate

Limit refresh rate and don't update on every cycle
pull/365/head
Gergely Nagy 6 years ago committed by GitHub
commit 36a38b23b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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);
}

@ -29,6 +29,9 @@ class LEDBreatheEffect : public LEDMode {
protected:
void update(void) final;
private:
uint16_t last_update = 0;
};
}

Loading…
Cancel
Save