There was only a scroll-text template; add frame-based animations for the
Uno Q's built-in 13x8 monochrome-blue matrix. Both compiled (arduino:zephyr
0.51.0) and flashed E2E on hardware (OpenOCD @ 0x80F0000, per boards.txt).
- matrix_rain/ — digital rain: staggered per-column drops + trails.
- matrix_effects/ — sampler cycling rain / knight-rider / ripple / sparkle
/ wipe.
- README: the grid->uint32[4] packing pattern (row-major, MSB-first), how to
add an effect, and the compile/flash recipe (TMPDIR=/tmp trap + the correct
0x80F0000 address vs QClaw's stale 0x8100000).
Note: the matrix is physically blue + on/off only — no colour/brightness in
software.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
70 lines
2.3 KiB
Arduino
70 lines
2.3 KiB
Arduino
// Matrix-style "digital rain" for the Arduino Uno Q's 13x8 blue LED matrix.
|
|
// Frame-based animation: each loop builds an 8x13 pixel grid, packs it into the
|
|
// uint32_t[4] the Arduino_LED_Matrix driver expects, and pushes it with
|
|
// loadFrame(). The matrix is monochrome (pixels are on/off — no brightness), so
|
|
// each column's drop is drawn as a lit head plus a short trailing segment.
|
|
//
|
|
// Uno Q matrix API is deliberately tiny: matrix.begin() + matrix.loadFrame(frame).
|
|
// (No drawFrame/clear/setPixel — those do not exist here.)
|
|
//
|
|
// Compile: arduino-cli compile --fqbn arduino:zephyr:unoq --export-binaries
|
|
// Flash: arduino-flash <sketch>.ino.elf-zsk.bin (OpenOCD @ 0x80F0000)
|
|
|
|
#include "Arduino_LED_Matrix.h"
|
|
|
|
Arduino_LED_Matrix matrix;
|
|
|
|
static const uint8_t W = 13; // columns
|
|
static const uint8_t H = 8; // rows
|
|
|
|
int8_t head[W]; // row of each column's leading drop (starts above the top)
|
|
uint8_t len[W]; // length of the lit trail (head + tail)
|
|
uint8_t period[W]; // loops between downward steps (per-column speed)
|
|
uint8_t phase[W]; // step counter
|
|
uint32_t frame[4];
|
|
|
|
void reseed(uint8_t x) {
|
|
head[x] = -(int8_t)random(0, H); // stagger the start above the matrix
|
|
len[x] = random(2, 5); // 2..4 lit pixels
|
|
period[x] = random(1, 4); // 1 = fast, 3 = slow
|
|
phase[x] = 0;
|
|
}
|
|
|
|
void setup() {
|
|
matrix.begin();
|
|
randomSeed(micros());
|
|
for (uint8_t x = 0; x < W; x++) reseed(x);
|
|
}
|
|
|
|
void loop() {
|
|
bool grid[H][W];
|
|
for (uint8_t y = 0; y < H; y++)
|
|
for (uint8_t x = 0; x < W; x++) grid[y][x] = false;
|
|
|
|
for (uint8_t x = 0; x < W; x++) {
|
|
// draw the drop: head at head[x], tail extending upward
|
|
for (uint8_t t = 0; t < len[x]; t++) {
|
|
int y = head[x] - t;
|
|
if (y >= 0 && y < H) grid[y][x] = true;
|
|
}
|
|
// advance this column on its own cadence
|
|
if (++phase[x] >= period[x]) {
|
|
phase[x] = 0;
|
|
head[x]++;
|
|
if (head[x] - (int8_t)len[x] >= (int8_t)H) reseed(x); // fully off the bottom
|
|
}
|
|
}
|
|
|
|
// pack grid -> frame: row-major, MSB-first (pixel 0 = frame[0] bit 31)
|
|
frame[0] = frame[1] = frame[2] = frame[3] = 0;
|
|
uint16_t bit = 0;
|
|
for (uint8_t y = 0; y < H; y++)
|
|
for (uint8_t x = 0; x < W; x++) {
|
|
if (grid[y][x]) frame[bit >> 5] |= (1UL << (31 - (bit & 31)));
|
|
bit++;
|
|
}
|
|
|
|
matrix.loadFrame(frame);
|
|
delay(90);
|
|
}
|