KB2040 Macropad (TinyUSB HID)
Overview
A 9-key macropad with a fader slider, built on the Adafruit KB2040 board. Features a multi-layer keymap system, OLED display for layer and status indication, and Adafruit TinyUSB for native USB HID communication. The device includes custom PCB design, mechanical housing, and companion software for volume control.
Hardware
- PCB Design: Custom board layout designed in Altium
- Mechanical Design: Enclosure and mounting designed in OnShape
- Controller: Adafruit KB2040 (RP2040-based)
- Inputs: 9 mechanical keys, linear fader
- Display: OLED screen for real-time layer and status feedback
- RGB LEDs: Per-layer color indication
Firmware
The firmware is written primarily in C++ (with some C components) and implements a multi-layer keymap system where each layer can have different functions mapped to keys, encoders, and the fader. The codebase uses Adafruit TinyUSB for USB HID communication, eliminating the need for Arduino's Keyboard.h library and providing better cross-platform compatibility. The OLED display shows the current active layer and system status, while RGB LEDs provide visual feedback corresponding to each layer's color scheme.
The firmware handles layer-aware logic for all inputs, including rotary encoders and the potentiometer/fader, which behave differently depending on the active layer, enabling flexible control schemes for different applications.
Software
A companion Python program (listener) runs on the host computer to intercept HID messages from the
macropad's fader and translate them into system volume control commands. This allows the linear fader to directly
control the computer's master volume, providing tactile hardware control for audio levels.
Features
- Multi-layer keymap system with configurable per-layer functions
- Layer-aware encoder & potentiometer logic
- OLED layer indicator with per-layer LED colors
- USB HID via TinyUSB (native, no Keyboard.h dependency)
- Hardware volume control via fader slider with host-side listener program
- Custom PCB design for optimal component layout
- Modular mechanical design in OnShape
Gallery
Additional photos showing the OLED UI, encoder operation, and different layer configurations.