feat(uno-q): add comet effect to the matrix sampler

A pixel that bounces off the walls trailing its last 5 cells (a diagonal
streak that bends on each bounce). Wired into the cycle between the
knight-rider sweep and ripple. Compiled + flashed E2E (1637 bytes).

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Omar Sobh
2026-07-08 14:49:52 -07:00
co-authored by Claude Opus 4.8
parent 2683c64c34
commit 45a8feb8b4
2 changed files with 23 additions and 2 deletions
@@ -1,6 +1,6 @@
// Matrix animation sampler for the Arduino Uno Q's 13x8 blue LED matrix.
// Cycles through several frame-based effects: rain -> knight-rider sweep ->
// ripple -> sparkle -> wipe, then repeats. All monochrome (pixels are on/off;
// comet -> ripple -> sparkle -> wipe, then repeats. All monochrome (pixels are on/off;
// the LEDs are physically blue — there is no colour or brightness control).
//
// Shared pattern: each effect fills the 8x13 `grid`, then show() packs it into
@@ -119,6 +119,26 @@ void wipe(uint8_t reps) {
}
}
// --- comet: a pixel bounces around the edges, trailing its last few cells ---
void comet(uint16_t frames) {
const uint8_t TRAIL = 5;
int hx[TRAIL], hy[TRAIL];
int x = random(0, W), y = random(0, H), dx = 1, dy = 1;
for (uint8_t i = 0; i < TRAIL; i++) { hx[i] = x; hy[i] = y; }
for (uint16_t f = 0; f < frames; f++) {
for (int i = TRAIL - 1; i > 0; i--) { hx[i] = hx[i - 1]; hy[i] = hy[i - 1]; }
hx[0] = x; hy[0] = y;
clearGrid();
for (uint8_t i = 0; i < TRAIL; i++) grid[hy[i]][hx[i]] = true;
show(70);
x += dx; y += dy; // advance, then reflect off walls
if (x < 0) { x = 1; dx = 1; }
else if (x > W - 1) { x = W - 2; dx = -1; }
if (y < 0) { y = 1; dy = 1; }
else if (y > H - 1) { y = H - 2; dy = -1; }
}
}
void setup() {
matrix.begin();
randomSeed(micros());
@@ -127,6 +147,7 @@ void setup() {
void loop() {
rain(70);
knight(2);
comet(120);
ripple(2);
sparkle(40);
wipe(2);