How torvalds/scrollwheel works
This is RP2350 firmware for a DIY rotary control: an AS5600 magnetic angle sensor and switches become USB HID scroll, volume, and keyboard events, with a WS2812 LED providing visual feedback. The main loop initializes hardware and USB, samples the angle, updates the LED, services TinyUSB, and periodically processes switches and angle changes. The README documents board-dependent GPIOs and the optional LED. PIO implementation details were not sampled, so their specific behavior is based on the firmware’s use and README descriptions.
Main entry points: blink.c Main loop · hid-device.c USB HID device · ws2812.pio WS2812 PIO · tinyusb TinyUSB stack
Components 18
Physical inputs
- I2C setup
blink.c - Angle acquisition
blink.c - Switch setup
blink.c - PIO debounce
debounce.pio
Control firmware
- Main loop
blink.c - Angle tracking
blink.c - Switch events
blink.c - Button mapping
blink.c - Rotation mapping
blink.c - LED color mapping
blink.c
USB and feedback
- WS2812 PIO
ws2812.pio - USB HID device
hid-device.c - HID send API
hid-device.c - TinyUSB stack
tinyusb
Other components
- Knob and switches
- AS5600 sensor
- WS2812 LED
- USB host
Connections 23
- Knob and switches → AS5600 sensor: rotates magnet
README.md - Main loop → I2C setup: initializes
blink.c - I2C setup → AS5600 sensor: configures bus
blink.c - Main loop → Angle acquisition: samples
blink.c - Angle acquisition → AS5600 sensor: reads angle
blink.c - Angle acquisition → Angle tracking: unwraps readings
blink.c - Main loop → Switch setup: initializes
blink.c - Switch setup → PIO debounce: starts program
blink.c - Knob and switches → Switch events: presses switches
README.md - Main loop → Switch events: polls
blink.c - Switch events → Button mapping: returns states
blink.c - Main loop → Button mapping: processes
blink.c - Main loop → Rotation mapping: processes angle
blink.c - Rotation mapping → HID send API: sends scroll or volume
blink.c - Button mapping → HID send API: sends keycodes
blink.c - Main loop → LED color mapping: updates periodically
blink.c - LED color mapping → WS2812 PIO: encodes color
blink.c - WS2812 PIO → WS2812 LED: drives LED
README.md - Main loop → USB HID device: initializes USB
blink.c - Main loop → TinyUSB stack: services tasks
blink.c - USB HID device → TinyUSB stack: initializes stack
hid-device.c - HID send API → USB HID device: submits reports
hid-device.c - USB HID device → USB host: provides HID reports
hid-device.c