Use standard timeout checker for LEDEffect-Breathe

Also, change the update interval value from a preprocessor macro to a static
constexpr uint8_t variable.

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/642/head
Michael Richters 6 years ago
parent 85b47caa73
commit c5b8eddaae

@ -16,18 +16,15 @@
#include "Kaleidoscope-LEDEffect-Breathe.h"
#define UPDATE_INTERVAL 50 // milliseconds between two LED updates to avoid overloading; 20 fps
namespace kaleidoscope {
namespace plugin {
void LEDBreatheEffect::TransientLEDMode::update(void) {
if (!Kaleidoscope.has_leds)
return;
uint16_t now = Kaleidoscope.millisAtCycleStart();
if ((now - last_update_) < UPDATE_INTERVAL)
if (!Kaleidoscope.hasTimeExpired(last_update_, update_interval_))
return;
last_update_ = now;
last_update_ += update_interval_;
cRGB color = breath_compute(parent_->hue, parent_->saturation);
::LEDControl.set_all_leds_to(color);

@ -46,7 +46,9 @@ class LEDBreatheEffect : public Plugin,
private:
const LEDBreatheEffect *parent_;
uint16_t last_update_ = 0;
static constexpr uint8_t update_interval_ = 50;
uint8_t last_update_ = 0;
};
};
}

Loading…
Cancel
Save