Adding loop function

This commit is contained in:
2026-05-23 10:03:35 +02:00
parent 97e278ed3f
commit 23570b0dce
8 changed files with 86 additions and 47 deletions
+7 -1
View File
@@ -12,16 +12,21 @@
#include <avr/pgmspace.h>
#include <stdint.h>
// Show playback modes.
#define SHOW_LOOP 0 // repeat the show indefinitely
#define SHOW_SINGLE 1 // play once, then auto-advance to the next show
// One step in a lightshow: a target color and the time to reach it.
struct Step {
uint8_t r, g, b; // Target RGB color (0255 each)
uint16_t duration_ms; // Milliseconds to fade from the previous color (0 = instant)
};
// Descriptor for one complete show: a pointer to its PROGMEM Step array and its length.
// Descriptor for one complete show.
struct ShowDef {
const Step* steps; // Pointer to a PROGMEM Step array
uint16_t length; // Number of steps in the array
uint8_t mode; // SHOW_LOOP or SHOW_SINGLE
};
// Read one Step from PROGMEM into a regular struct.
@@ -41,5 +46,6 @@ inline ShowDef read_show_def(const ShowDef* ptr) {
ShowDef sd;
sd.steps = (const Step*)pgm_read_word(&ptr->steps);
sd.length = pgm_read_word(&ptr->length);
sd.mode = pgm_read_byte(&ptr->mode);
return sd;
}