Skip to content

pixel_sim

pixel_sim

pixel_sim — desktop simulator for addressable-LED matrices (NeoPixel / DotStar).

Develop a pixeldisplay app without hardware. PixelDisplay draws into a pygraphics.FrameBuffer (RGB888, one cell per LED); on show() that framebuffer is scaled up and painted as an LED matrix onto the shared desktop / PyScript / notebook display from lib/board_config.py.

The board config for this simulator is just::

from pixel_sim import display_drv, runtime

Poll runtime each frame (runtime.poll() / runtime.quit_requested) so the desktop window stays closable — the simulator drives its own draw loop, so nothing polls for you.

Grid size defaults to 64x16; override with PIXEL_SIM_WIDTH / PIXEL_SIM_HEIGHT (honored on CPython and MicroPython).

Classes

SimPixelFramebuffer

SimPixelFramebuffer(width, height, backend)

RGB888 grid framebuffer that renders scaled LED blocks to a desktop display.

A drop-in for the pixel_buffer that :class:PixelDisplay wraps: it exposes width / height / rotation and a display() flush, but instead of pushing to a physical strip it paints each cell as a large square on backend (centered, square LEDs, dark gaps for a matrix look).

display() builds the scaled LED panel in a scratch RGB565 buffer, then performs one blit_rect on the host backend. Desktop backends (SDL/pygame) call render() after every fill_rect; painting each LED with fill_rect was ~1024 full compositor passes per frame.

Methods:
blit_rgb565_rect
blit_rgb565_rect(buf, x, y, w, h)

Bulk RGB565 -> RGB888 copy into the LED grid (avoids per-pixel pixel()).

SimPixelDisplay

PixelDisplay that uses fast bulk blits into :class:SimPixelFramebuffer.