Use standard timeout checker for LEDEffect-Rainbow

Also, change `rainbow_update_delay` from two bytes to one, and use a more
consistent interval by adding it to `rainbow_last_update` after each update,
rather than using the current time.

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/642/head
Michael Richters 6 years ago
parent 2bcfe8a0ea
commit f66415e34f

@ -23,11 +23,11 @@ void LEDRainbowEffect::TransientLEDMode::update(void) {
if (!Kaleidoscope.has_leds)
return;
uint16_t now = millis();
if ((now - rainbow_last_update) < parent_->rainbow_update_delay) {
if (!Kaleidoscope.hasTimeExpired(rainbow_last_update,
parent_->rainbow_update_delay)) {
return;
} else {
rainbow_last_update = now;
rainbow_last_update += parent_->rainbow_update_delay;
}
cRGB rainbow = hsvToRgb(rainbow_hue, rainbow_saturation, parent_->rainbow_value);
@ -54,11 +54,11 @@ void LEDRainbowWaveEffect::TransientLEDMode::update(void) {
if (!Kaleidoscope.has_leds)
return;
uint16_t now = millis();
if ((now - rainbow_last_update) < parent_->rainbow_update_delay) {
if (!Kaleidoscope.hasTimeExpired(rainbow_last_update,
parent_->rainbow_update_delay)) {
return;
} else {
rainbow_last_update = now;
rainbow_last_update += parent_->rainbow_update_delay;
}
for (int8_t i = 0; i < LED_COUNT; i++) {

@ -55,13 +55,13 @@ class LEDRainbowEffect : public Plugin,
uint16_t rainbow_hue = 0; // stores 0 to 614
uint8_t rainbow_steps = 1; // number of hues we skip in a 360 range per update
uint16_t rainbow_last_update = 0;
uint8_t rainbow_last_update = 0;
byte rainbow_saturation = 255;
};
private:
uint16_t rainbow_update_delay = 40; // delay between updates (ms)
uint8_t rainbow_update_delay = 40; // delay between updates (ms)
byte rainbow_value = 50;
};
@ -100,12 +100,12 @@ class LEDRainbowWaveEffect : public Plugin, public LEDModeInterface {
uint16_t rainbow_hue = 0; // stores 0 to 614
uint8_t rainbow_wave_steps = 1; // number of hues we skip in a 360 range per update
uint16_t rainbow_last_update = 0;
uint8_t rainbow_last_update = 0;
byte rainbow_saturation = 255;
};
uint16_t rainbow_update_delay = 40; // delay between updates (ms)
uint8_t rainbow_update_delay = 40; // delay between updates (ms)
byte rainbow_value = 50;
};
}

Loading…
Cancel
Save