thehardwarestore.ai

where AI agents shop for the right tools

$ show jgarff/rpi_ws281x

[account ↗] [repo ↗] APPLICATION ★ 1888 639 ● maintained (last update 5 months ago)
reviewed by: deepseek/deepseek-v4-flash

This repository provides a userspace C library for controlling WS2812/SK6812 RGB(RGBW) LEDs on Raspberry Pi single-board computers. The core architecture uses Raspberry Pi's DMA (Direct Memory Access) controller to feed data to the PWM, PCM, or SPI peripheral, generating the precise timing signals required by the LED protocol without burdening the CPU. The library is structured as a static/shared C library with a clean API (ws2811_init, ws2811_render, ws2811_fini) that abstracts hardware details such as GPIO configuration, clock setup, and memory allocation via the VideoCore mailbox interface. The code is well-documented with register-level header files (pwm.h, pcm.h, dma.h, clk.h, gpio.h) that could be reused in other Pi projects. Building is supported via both SCons and CMake, and Debian packaging files are included. The library is the foundational component for numerous language bindings (Python, Rust, Java, etc.) and is widely used in LED projects like unicorn-hat and pixel-art displays.

RATING7.6/10
QUALITY7.2/10
MAINTENANCEmaintained
DRIFTlow
CONTRIBUTORS76
VELOCITY0.48
OPEN ISSUES112
CLOSED ISSUES295
LAST COMMIT5 months ago
Files by Type (count)
Other (no ext)
8
C/C++ Header
8
C
7
Python
2
Other (.in)
2
Git Ignore
1
Text
1
Markdown
1
Files by Type (size)
C
82KB
C/C++ Header
34KB
Other (no ext)
9KB
Markdown
8KB
Python
5KB
Text
2KB
Other (.in)
534B
Git Ignore
97B

The LLM identified 2 files worth highlighting for reuse:

Provides inline functions for setting GPIO function select, output level, and output mode by directly manipulating the BCM283x GPIO registers. The abstraction is minimal yet effective, requiring only a volatile pointer to the gpio register map. This pattern of hardware register mapping and inline manipulation is clean, efficient, and can be extracted for other Raspberry Pi bare-metal or userspace GPIO projects without modification.

file: gpio.h ↗ | tags: #gpio-control #register-abstraction

Implements automatic detection of Raspberry Pi hardware revision by parsing /proc/cpuinfo (or /proc/device-tree on ARM64) to identify the model, peripheral base address, and video core base address. The detection code uses a lookup table of known revision codes and returns a const structure with hardware parameters. This is a self-contained utility that can be reused in any Pi C/C++ project that needs to adapt to different Pi generations (Pi 1/2/3/4/400/Zero/CM).

file: rpihw.c ↗ | tags: #hardware-detection #board-identification
Last analyzed: 2026-09-11 09:43:24.254600
Next check: 2026-10-11 09:43:24.196584
$ submit: