Adding loop function
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* A single button navigates between shows:
|
||||
* 1 tap — next show
|
||||
* 2 taps — previous show
|
||||
* hold — reset to show 0 (slow blue pulse)
|
||||
* hold — reset to show 0 (blue breath)
|
||||
*
|
||||
* To add or update shows:
|
||||
* 1. Add or edit a .txt file in converter/shows/
|
||||
@@ -66,10 +66,19 @@ static float step_progress(const Step& step) {
|
||||
return (t < 1.0f) ? t : 1.0f;
|
||||
}
|
||||
|
||||
// Complete the current step and advance to the next (loops at end of show).
|
||||
// Complete the current step and advance to the next.
|
||||
// SHOW_LOOP wraps back to step 0; SHOW_SINGLE loads the next show when the last step ends.
|
||||
static void advance_step(CRGB reached_color) {
|
||||
s_from_color = reached_color;
|
||||
s_step_index = (s_step_index + 1) % s_show.length;
|
||||
uint16_t next = s_step_index + 1;
|
||||
if (next >= s_show.length) {
|
||||
if (s_show.mode == SHOW_SINGLE) {
|
||||
load_show((s_show_index + 1) % SHOW_COUNT);
|
||||
return;
|
||||
}
|
||||
next = 0;
|
||||
}
|
||||
s_step_index = next;
|
||||
s_step_start = millis();
|
||||
}
|
||||
|
||||
@@ -78,7 +87,7 @@ static void advance_step(CRGB reached_color) {
|
||||
void setup() {
|
||||
leds_begin();
|
||||
button_begin(BUTTON_PIN);
|
||||
load_show(0); // start on show 0 — slow blue pulse
|
||||
load_show(0); // start on show 0 — blue breath
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@@ -93,7 +102,7 @@ void loop() {
|
||||
load_show((s_show_index + SHOW_COUNT - 1) % SHOW_COUNT);
|
||||
}
|
||||
if (evt == BTN_HOLD) {
|
||||
// Reset to show 0 (blue pulse) from any position.
|
||||
// Reset to show 0 (blue breath) from any position.
|
||||
load_show(0);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user