Speed can now be changed on-the-fly by setting `speedup`.

This commit is contained in:
Fabian Schlenz 2021-01-10 16:27:49 +01:00
parent 8fe03313ac
commit 7651e46ee0
3 changed files with 5 additions and 1 deletions

View File

@ -32,3 +32,4 @@ extern AnimationMode mode;
extern AnimationMode temp_mode;
extern unsigned long temp_mode_until;
extern int return_to_brightness;
extern uint8_t speedup;

View File

@ -21,6 +21,7 @@ AnimationMode mode = AM_CORNERS;
AnimationMode temp_mode;
unsigned long temp_mode_until;
int return_to_brightness = -1;
uint8_t speedup = SPEEDUP;
unsigned long last_loop = 0;
@ -156,7 +157,7 @@ void loop() {
mqtt_loop();
ArduinoOTA.handle();
EVERY_N_MILLISECONDS(20 / SPEEDUP) {
if (speedup > 0 && (millis() - last_loop > (20 / speedup) || last_loop > millis())) {
looping = false;
AnimationMode active_mode = mode;

View File

@ -67,6 +67,8 @@ void callback(char* topic, byte* pl, unsigned int length) {
else if (value.equals("yellow")) { color = CRGB::Yellow; }
else if (value.equals("orange")) { color = CRGB::Orange; }
else { LOGln("Unknown color name %s.", value.c_str());}
} else if (key.equals("speedup")) {
speedup = value.toInt();
} else {
LOGln("Unknown key '%s'. (For reference: Value is '%s'.)", key.c_str(), value.c_str());
}