diff --git a/src/kaleidoscope/plugin/LEDEffect-Rainbow.cpp b/src/kaleidoscope/plugin/LEDEffect-Rainbow.cpp index f063897c..cacf6caf 100644 --- a/src/kaleidoscope/plugin/LEDEffect-Rainbow.cpp +++ b/src/kaleidoscope/plugin/LEDEffect-Rainbow.cpp @@ -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++) { diff --git a/src/kaleidoscope/plugin/LEDEffect-Rainbow.h b/src/kaleidoscope/plugin/LEDEffect-Rainbow.h index cfff7d0f..750fe43e 100644 --- a/src/kaleidoscope/plugin/LEDEffect-Rainbow.h +++ b/src/kaleidoscope/plugin/LEDEffect-Rainbow.h @@ -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; }; }