# tylerjohnsonunl/arcade_controller_rgb architecture

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

- Interactive diagram: https://gitdiagram.com/tylerjohnsonunl/arcade_controller_rgb
- Repository: https://github.com/tylerjohnsonunl/arcade_controller_rgb

## Overview

This is firmware for a motion-activated RGBW lighting controller. The main loop scans a button, updates controller state, checks the sensor, and selects a lighting mode; the mode selects LED colors/effects and hardware outputs. The sampled sources establish these calls and the button/display/LED behaviors, but sensor, SPI, clock, and display implementations were not sampled, so their internal wiring is left unspecified.

Main entry points: [`main.c`](https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/main.c) (Main loop), [`controller.c`](https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/controller.c) (Mode controller), [`led.c`](https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/led.c) (Color effects), [`button.c`](https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/button.c) (Button scanning)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_application["Application flow"]
  node_main["Main loop<br/>[main.c]"]
  node_controller["Mode controller<br/>[controller.c]"]
  node_mode["Mode selection<br/>[mode.c]"]
end

subgraph group_inputs["Inputs and timing"]
  node_button["Button scanning<br/>[button.c]"]
  node_sensor["Sensor checks<br/>[sensor.c]"]
  node_clock["Clock service<br/>[clock.c]"]
  node_spi["SPI interface<br/>[spi.c]"]
end

subgraph group_lighting["Lighting and display"]
  node_led["Color effects<br/>[led.c]"]
  node_display["Seven-segment display<br/>[sevenSegment.c]"]
end

subgraph group_hardware["Device support"]
  node_device["System initialization<br/>[mcc.c]"]
  node_pins["Pin configuration<br/>[pin_manager.c]"]
  node_pwm["PWM drivers<br/>[pwm1.c]"]
end

node_user(("Button user"))
node_motion(("Motion source"))
node_outputs(("Light outputs"))

node_user -->|"presses"| node_button
node_motion -->|"sensed by"| node_sensor
node_main -->|"initializes"| node_device
node_device -->|"configures"| node_pins
node_main -->|"initializes"| node_clock
node_main -->|"initializes"| node_led
node_main -->|"initializes"| node_sensor
node_main -->|"initializes"| node_spi
node_main -->|"initializes"| node_button
node_main -->|"initializes"| node_display
node_main -->|"initializes"| node_controller
node_main -->|"scans"| node_button
node_main -->|"runs"| node_controller
node_main -->|"checks"| node_sensor
node_main -->|"reads movement"| node_sensor
node_main -->|"reads mode"| node_controller
node_main -->|"dispatches mode"| node_mode
node_controller -->|"checks events"| node_button
node_controller -->|"reads time"| node_clock
node_controller -->|"updates digits"| node_display
node_controller -->|"sets brightness"| node_led
node_mode -->|"selects effect"| node_led
node_mode -->|"sets GPIO"| node_outputs
node_led -->|"sets color"| node_outputs
node_led -->|"writes PWM registers"| node_pwm

click node_main "https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/main.c"
click node_controller "https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/controller.c"
click node_mode "https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/mode.c"
click node_button "https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/button.c"
click node_sensor "https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/sensor.c"
click node_clock "https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/clock.c"
click node_spi "https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/spi.c"
click node_led "https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/led.c"
click node_display "https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/sevenSegment.c"
click node_device "https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/mcc_generated_files/mcc.c"
click node_pins "https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/mcc_generated_files/pin_manager.c"
click node_pwm "https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/mcc_generated_files/pwm1.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_main,node_controller,node_mode,node_user toneBlue
class node_button,node_sensor,node_clock,node_spi toneAmber
class node_led,node_display toneMint
class node_device,node_pins,node_pwm toneRose
class node_motion,node_outputs toneIndigo
```

## Components

### Application flow

- [Main loop](https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/main.c): `main.c`
- [Mode controller](https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/controller.c): `controller.c`
- [Mode selection](https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/mode.c): `mode.c`

### Inputs and timing

- [Button scanning](https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/button.c): `button.c`
- [Sensor checks](https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/sensor.c): `sensor.c`
- [Clock service](https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/clock.c): `clock.c`
- [SPI interface](https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/spi.c): `spi.c`

### Lighting and display

- [Color effects](https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/led.c): `led.c`
- [Seven-segment display](https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/sevenSegment.c): `sevenSegment.c`

### Device support

- [System initialization](https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/mcc_generated_files/mcc.c): `mcc_generated_files/mcc.c`
- [Pin configuration](https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/mcc_generated_files/pin_manager.c): `mcc_generated_files/pin_manager.c`
- [PWM drivers](https://github.com/tylerjohnsonunl/arcade_controller_rgb/blob/main/mcc_generated_files/pwm1.c): `mcc_generated_files/pwm1.c`

### Other components

- **Button user**
- **Motion source**
- **Light outputs**

## Connections

- Button user → Button scanning: presses
- Motion source → Sensor checks: sensed by
- Main loop → System initialization: initializes
- System initialization → Pin configuration: configures
- Main loop → Clock service: initializes
- Main loop → Color effects: initializes
- Main loop → Sensor checks: initializes
- Main loop → SPI interface: initializes
- Main loop → Button scanning: initializes
- Main loop → Seven-segment display: initializes
- Main loop → Mode controller: initializes
- Main loop → Button scanning: scans
- Main loop → Mode controller: runs
- Main loop → Sensor checks: checks
- Main loop → Sensor checks: reads movement
- Main loop → Mode controller: reads mode
- Main loop → Mode selection: dispatches mode
- Mode controller → Button scanning: checks events
- Mode controller → Clock service: reads time
- Mode controller → Seven-segment display: updates digits
- Mode controller → Color effects: sets brightness
- Mode selection → Color effects: selects effect
- Mode selection → Light outputs: sets GPIO
- Color effects → Light outputs: sets color
- Color effects → PWM drivers: writes PWM registers
