# ddrboxman/picodeck architecture

> Architecture diagram of the GitHub repository ddrboxman/picodeck, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ddrboxman/picodeck
- Repository: https://github.com/ddrboxman/picodeck

## Overview

Picodeck is Raspberry Pi Pico firmware that emulates an Elgato Stream Deck Pedal over USB HID. Its principal workflow is: Stream Deck software queries device identity, sends pedal commands such as LED color changes, and receives button reports; firmware also reads physical switches and drives an optional NeoPixel. USB descriptors define the device interface, while the main firmware handles USB events and hardware behavior. SEGGER RTT provides a separate debugging output layer. Some main-loop and HID callback code was omitted from the excerpts, so those internal links are not inferred beyond documented behavior.

Main entry points: [`src/main.c`](https://github.com/ddrboxman/picodeck/blob/main/src/main.c) (Firmware Runtime), [`RTT/SEGGER_RTT.c`](https://github.com/ddrboxman/picodeck/blob/main/RTT/SEGGER_RTT.c) (RTT Buffer API), [`generated/ws2812.pio.h`](https://github.com/ddrboxman/picodeck/blob/main/generated/ws2812.pio.h) (Generated PIO Header), [`RTT/SEGGER_RTT.h`](https://github.com/ddrboxman/picodeck/blob/main/RTT/SEGGER_RTT.h) (RTT API Declarations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_usb["USB HID Device"]
  node_firmware["Firmware Runtime<br/>[main.c]"]
  node_descriptors["HID Descriptors<br/>[usb_descriptors.c]"]
  node_tusbconfig["TinyUSB Settings<br/>[tusb_config.h]"]
end

subgraph group_io["Pedal I/O"]
  node_switches(("Pedal Switches"))
  node_pixels(("NeoPixel Strip"))
  node_pio["WS2812 Program<br/>[ws2812.pio]"]
  node_pioheader["Generated PIO Header<br/>[ws2812.pio.h]"]
end

subgraph group_debug["RTT Debugging"]
  node_rttapi["RTT Buffer API<br/>[SEGGER_RTT.c]"]
  node_rttheader["RTT API Declarations<br/>[SEGGER_RTT.h]"]
  node_rttconfig["RTT Configuration<br/>[SEGGER_RTT_Conf.h]"]
  node_rttprintf["RTT Formatting"]
end

node_streamdeck(("Stream Deck Software"))

node_streamdeck -->|"queries and commands"| node_firmware
node_firmware -->|"sends button reports"| node_streamdeck
node_descriptors -->|"defines HID interface"| node_streamdeck
node_firmware -.->|"reads switch inputs"| node_switches
node_firmware -->|"updates LED color"| node_pixels
node_firmware -->|"writes pixel data"| node_pioheader
node_pioheader -.->|"implements PIO program"| node_pio
node_firmware -->|"writes debug text"| node_rttapi
node_rttprintf -->|"writes formatted output"| node_rttapi
node_rttapi -->|"implements API"| node_rttheader
node_rttheader -->|"uses configuration"| node_rttconfig

click node_firmware "https://github.com/ddrboxman/picodeck/blob/main/src/main.c"
click node_descriptors "https://github.com/ddrboxman/picodeck/blob/main/src/usb_descriptors.c"
click node_tusbconfig "https://github.com/ddrboxman/picodeck/blob/main/src/tusb_config.h"
click node_pio "https://github.com/ddrboxman/picodeck/blob/main/src/ws2812.pio"
click node_pioheader "https://github.com/ddrboxman/picodeck/blob/main/generated/ws2812.pio.h"
click node_rttapi "https://github.com/ddrboxman/picodeck/blob/main/RTT/SEGGER_RTT.c"
click node_rttheader "https://github.com/ddrboxman/picodeck/blob/main/RTT/SEGGER_RTT.h"
click node_rttconfig "https://github.com/ddrboxman/picodeck/blob/main/Config/SEGGER_RTT_Conf.h"
click node_rttprintf "https://github.com/ddrboxman/picodeck/blob/main/RTT/SEGGER_RTT_printf.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_firmware,node_descriptors,node_tusbconfig toneBlue
class node_switches,node_pixels,node_pio,node_pioheader toneAmber
class node_rttapi,node_rttheader,node_rttconfig,node_rttprintf toneMint
class node_streamdeck toneIndigo
```

## Components

### USB HID Device

- [Firmware Runtime](https://github.com/ddrboxman/picodeck/blob/main/src/main.c): `src/main.c`
- [HID Descriptors](https://github.com/ddrboxman/picodeck/blob/main/src/usb_descriptors.c): `src/usb_descriptors.c`
- [TinyUSB Settings](https://github.com/ddrboxman/picodeck/blob/main/src/tusb_config.h): `src/tusb_config.h`

### Pedal I/O

- **Pedal Switches**
- **NeoPixel Strip**
- [WS2812 Program](https://github.com/ddrboxman/picodeck/blob/main/src/ws2812.pio): `src/ws2812.pio`
- [Generated PIO Header](https://github.com/ddrboxman/picodeck/blob/main/generated/ws2812.pio.h): `generated/ws2812.pio.h`

### RTT Debugging

- [RTT Buffer API](https://github.com/ddrboxman/picodeck/blob/main/RTT/SEGGER_RTT.c): `RTT/SEGGER_RTT.c`
- [RTT API Declarations](https://github.com/ddrboxman/picodeck/blob/main/RTT/SEGGER_RTT.h): `RTT/SEGGER_RTT.h`
- [RTT Configuration](https://github.com/ddrboxman/picodeck/blob/main/Config/SEGGER_RTT_Conf.h): `Config/SEGGER_RTT_Conf.h`
- [RTT Formatting](https://github.com/ddrboxman/picodeck/blob/main/RTT/SEGGER_RTT_printf.c): `RTT/SEGGER_RTT_printf.c`

### Other components

- **Stream Deck Software**

## Connections

- Stream Deck Software → Firmware Runtime: queries and commands (evidence: `README.md`)
- Firmware Runtime → Stream Deck Software: sends button reports (evidence: `README.md`)
- HID Descriptors → Stream Deck Software: defines HID interface (evidence: `src/usb_descriptors.c`)
- Firmware Runtime → Pedal Switches: reads switch inputs
- Firmware Runtime → NeoPixel Strip: updates LED color (evidence: `src/main.c`)
- Firmware Runtime → Generated PIO Header: writes pixel data (evidence: `src/main.c`)
- Generated PIO Header → WS2812 Program: implements PIO program
- Firmware Runtime → RTT Buffer API: writes debug text (evidence: `src/main.c`)
- RTT Formatting → RTT Buffer API: writes formatted output (evidence: `RTT/SEGGER_RTT_printf.c`)
- RTT Buffer API → RTT API Declarations: implements API (evidence: `RTT/SEGGER_RTT.c`)
- RTT API Declarations → RTT Configuration: uses configuration (evidence: `RTT/SEGGER_RTT.h`)
