The friendly WS2812B library for the CMoz ESP32-S3 Mini — running live below. This page executes the library's actual math: same gamma curve, same power budgeting, same effects, same error messages. Twenty pixels, zero soldering. TinkerTailor.ca · CMozMaker · made in Canada
Golden rule on the CMoz board: NUM_LEDS counts the onboard pixel plus your strip — so 20 means onboard + a 19-LED strip, all on one pin. The strip above is illustrative; your real count, pin and board drive the generated code and the power estimate.
loop() laps/sec: — (manual mode — your loop() shares time with the LEDs)
The current estimate uses the library's model: ~20 mA per fully-lit channel + ~1 mA idle per chip. Blow the budget and CMozGlow quietly dims the frame — try full-white Solid at max brightness.
why it's different
Other LED libraries assume a desk, a bench supply and a serial monitor. CMozGlow assumes a costume that's already sewn shut.
Every failing call returns false and errorText() tells you exactly what to fix — "pixel index is past the end of the strip." Try it in the playground below.
setPowerBudgetmA(250) and the library estimates every frame's draw and auto-dims to keep your LiPo safe. Watch the gauge above do it in real time.
The onboard pixel becomes a live health light — green means happy, red means an error happened. Debugging for garments you can't plug in.
One line — autoUpdate(true) — moves the LEDs to the S3's second CPU core. Your loop() stays 100% free for sensors, touch and Bluetooth. Thread-safe throughout.
show() hands frames to the RMT peripheral and returns in ~100 µs — even on long strips. The latch gap is encoded in hardware. No busy-waiting anywhere.
Colours look the way you mixed them. Toggle it above and watch the mids shift — that's the 2.6 curve this page shares with the silicon.
the collection
Named for fabric, runways and northern skies — not test patterns. Click any card to run it in the simulator.
plus four for the holidays
Built for Halloween and Christmas, but far too much fun to pack away in January. Run them whenever — or hit the 🎃 and 🎄 themes up top to see them all dressed up.
interactive
Make real mistakes, get the library's real answers — the exact strings compiled into v1.3.0. Turn on the status pixel first and watch pixel 0 go red.
hardware
source of truth
Grouped the way you'll reach for it. Everything returns honestly: false means check errorText().
CMozGlow glow(numLeds); // GPIO 3 by default CMozGlow glow(numLeds, pin); // or any valid ESP32-S3 output pin bool begin(); // once in setup(); false → errorText() void end(); // lands AutoPilot, waits for hardware, frees memory bool setPixel(i, r, g, b); // bounds-checked, always bool setPixel(i, color); // packed 0xRRGGBB uint32_t getPixel(i); void fill(color); void clear(); bool show(); // async: hands the frame to hardware, returns in ~µs uint16_t numPixels();
void setBrightness(0-255); // non-destructive master dimmer void setGamma(true/false); // 2.6 curve, on by default void setPowerBudgetmA(mA); // 0 = unlimited uint16_t estimatedCurrentmA(); // what the last frame drew (model) bool powerLimited(); // did the library auto-dim?
bool setEffect(0-9); // or CMOZ_FX_… constants void setEffectColor(color); bool setEffectSpeed(1-10); bool setMorseMessage("TEXT 123"); // A-Z, 0-9, spaces, ≤63 chars bool update(); // every loop(); true when a frame drew static const char* effectName(id);
bool autoUpdate(true); // ✈ LEDs move to core 0; loop() is yours bool autoUpdate(false); // lands cleanly — never force-kills a task bool autoRunning();
All calls stay thread-safe mid-flight: a recursive mutex guards the whole library. Landing waits for the task to confirm exit and for the in-flight frame to finish before any memory moves — no dangling tasks, no use-after-free.
CMozError lastError(); const char* errorText(); void clearError(); void statusPixel(true); // pixel 0: green = happy, red = error
| code | meaning |
|---|---|
CMOZ_OK | everything is fine |
CMOZ_ERR_NOT_BEGUN | begin() wasn't called or failed |
CMOZ_ERR_BAD_PIN | use GPIO 0–21 or 33–48 (26–32 are the flash pins) |
CMOZ_ERR_BAD_COUNT | LED count must be 1–2000 |
CMOZ_ERR_ALLOC | out of memory (very long strip) |
CMOZ_ERR_RMT | the LED peripheral failed or timed out |
CMOZ_ERR_INDEX | pixel index past the end of the strip |
CMOZ_ERR_BAD_EFFECT | effect number doesn't exist (0–9) |
CMOZ_ERR_BAD_ARG | argument out of range |
CMOZ_ERR_TASK | AutoPilot's task couldn't start or stop |
| power source | budget |
|---|---|
| USB port | setPowerBudgetmA(450) |
| small LiPo (400 mAh) | setPowerBudgetmA(250) |
| dedicated 5 V / 2 A supply | setPowerBudgetmA(1500) |
The estimate is a model (~20 mA per fully-lit channel + ~1 mA idle per chip) — always leave headroom.