Skip to content

feat: per-pixel control and named color shortcuts - #21

Open
iksaif wants to merge 6 commits into
pimoroni:masterfrom
iksaif:feature-per-button-control
Open

feat: per-pixel control and named color shortcuts#21
iksaif wants to merge 6 commits into
pimoroni:masterfrom
iksaif:feature-per-button-control

Conversation

@iksaif

@iksaif iksaif commented Aug 22, 2026

Copy link
Copy Markdown

feat: per-pixel control and named color shortcuts

Stacked PR 2 of 3 — builds on top of #20.
Review in order: #20#21#22.

Add a simple pipe protocol for external apps to control individual LEDs without crafting PNG patterns.

New pipe commands

Command Description
set <index> <r> <g> <b> Set a single pixel to an RGB color
set <index> <color> Set a single pixel to a named or hex color
unset <index> Clear a per-pixel override
clear Clear all per-pixel overrides
off Turn all LEDs off
<color_name> Set all LEDs to a named color (red, blue, etc.)

Named colors: off, black, white, red, green, blue, yellow, cyan, purple, magenta, orange, dim_white
Also supports hex colors: #ff0000

plasmactl updates

  • --set <index> <color|rgb> — set individual pixels
  • --unset <index> — clear per-pixel override
  • --clear — clear all overrides
  • --off — turn all LEDs off
  • --color — alias for --colour
  • Named colors accepted as arguments to --set and --colour

Includes from #20

  • Skip redundant plasma.show() for static colors
  • Skip pattern re-rendering when animation row hasn't advanced
  • Replace FIFO readline busy-wait with select.select()
  • Cache loaded PNG patterns

Tests

15 new unit tests covering parse_color (named/hex/integer/invalid), per-pixel set/unset/clear/off, out-of-range pixel guard, and plasmactl Color() / send() writes to FIFO. All pass alongside the existing test suite.

iksaif added 2 commits August 25, 2026 14:18
- Skip redundant plasma.show() calls when color/brightness hasn't
  changed (solid colors now only update once instead of every frame)
- Skip pattern re-rendering when the animation row hasn't advanced
- Replace FIFO readline busy-wait (time.time() polling loop) with
  select.select() for proper blocking I/O
- Cache loaded PNG patterns instead of re-parsing on every switch
Clearing the flag inside the set_all() branch meant the buffer was
written but never latched to the hardware, so solid colours never
displayed. Patterns were unaffected because that branch leaves the
flag set.
@iksaif
iksaif force-pushed the feature-per-button-control branch from 347afe6 to e829f2c Compare August 25, 2026 12:21
iksaif added 3 commits August 25, 2026 14:58
Tests cover:
- FIFO.readline uses select.select for blocking I/O
- Pattern caching avoids re-reading from disk
- needs_update flag ensures show() only fires on state changes
- Static color: show() called once, not every frame
- Color/brightness changes trigger show()
- FPS clamped to minimum 1
Add pipe protocol for external apps to control individual LEDs:
- set <index> <r> <g> <b> / set <index> <color> — set a single pixel
- unset <index> — clear a per-pixel override
- clear — clear all per-pixel overrides
- off — turn all LEDs off
- <color_name> — set all LEDs to a named color

Named colors: off, black, white, red, green, blue, yellow, cyan,
purple, magenta, orange, dim_white. Hex colors (#ff0000) also supported.

plasmactl gains --set, --unset, --clear, --off, --color (alias for --colour).
Tests cover:
- parse_color: named colors, hex colors, integer colors, invalid inputs
- Per-pixel overrides: set, unset, clear, off, out-of-range indices
- plasmactl: NAMED_COLORS, Color function, send writes to FIFO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant