Files
bgrolleman ab2c1b34b4 Replace example shows with numbered production shows and add sparkle flag
- Rename all show .txt files with NNN_ numeric prefix so order is explicit
  and controlled by filename (001_heartbeat_red through 006_party)
- Drop HOME_SHOW special-casing from convert_all.py; show 0 is simply the
  lowest-numbered file
- Add SHOW_FLAG_SPARKLE support: shows can declare '// flags: sparkle' to
  overlay random white flashes on top of the base color each frame
- Wire sparkle into led_controller and config.h (SPARKLE_CHANCE/FRAMES)
- Replace old placeholder/example shows with the six production shows

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-24 13:59:25 +02:00

56 lines
1.9 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/*
* lightshow_format.h — Core data structures for show playback.
*
* All show data lives in PROGMEM (flash memory) to preserve the
* Arduino Uno's 2KB of RAM. The read_* helpers copy values out of
* PROGMEM so the rest of the code can work with them normally.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#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
// Show flags (bitfield for ShowDef.flags).
#define SHOW_FLAG_SPARKLE 0x01 // overlay random white sparkles on this 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.
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
uint8_t flags; // Bitfield: see SHOW_FLAG_* above
};
// Read one Step from PROGMEM into a regular struct.
// Direct pointer access does not work for PROGMEM on AVR — use this helper.
inline Step read_step(const Step* ptr) {
Step s;
s.r = pgm_read_byte(&ptr->r);
s.g = pgm_read_byte(&ptr->g);
s.b = pgm_read_byte(&ptr->b);
s.duration_ms = pgm_read_word(&ptr->duration_ms);
return s;
}
// Read one ShowDef from a PROGMEM ShowDef array.
// On AVR, pointers are 2 bytes wide, so pgm_read_word works for both fields.
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);
sd.flags = pgm_read_byte(&ptr->flags);
return sd;
}