# ne9n/new-timer architecture

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

- Interactive diagram: https://gitdiagram.com/ne9n/new-timer
- Repository: https://github.com/ne9n/new-timer

## Overview

Cheesehead Timer is a control-line model-aircraft throttle sequencer with Arduino firmware and a Python desktop companion. The main workflow is to configure or monitor the controller, then run a flight sequence whose state machine drives throttle while gyro sensing adjusts it and enforces safety and lap limits. The graph also preserves the documented serial-menu, calibration, LED, and desktop flashing capabilities. Internal links follow the shown firmware excerpts; desktop details and hardware links rely on README statements, since desktop source was read but not excerpted.

Main entry points: [`cheesehead_timer/gyro.cpp`](https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/gyro.cpp) (Gyro Engine), [`cheesehead_timer/cheesehead_timer.ino`](https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/cheesehead_timer.ino) (Firmware Loop), [`cheesehead_timer/term.cpp`](https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/term.cpp) (Serial Terminal), [`cheesehead_timer/state_machine.cpp`](https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/state_machine.cpp) (Flight Sequencer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop Companion"]
  node_desktop_app["Desktop App<br/>[desktop_app.py]"]
end

subgraph group_control["Flight Control"]
  node_firmware["Firmware Loop"]
  node_sequencer["Flight Sequencer<br/>[state_machine.cpp]"]
  node_config["Timer Configuration<br/>[cheesehead_timer.h]"]
end

subgraph group_motion["Motion and Safety"]
  node_gyro["Gyro Engine<br/>[gyro.cpp]"]
  node_gyro_api["Gyro Interface<br/>[gyro.h]"]
end

subgraph group_interface["Operator Interface"]
  node_terminal["Serial Terminal<br/>[term.cpp]"]
  node_terminal_api["Terminal Interface<br/>[term.h]"]
  node_buttons["Button Controls<br/>[ButMenu.cpp]"]
  node_leds["State LEDs<br/>[led.cpp]"]
  node_led_helpers["LED Helpers<br/>[led2.cpp]"]
end

subgraph group_hardware["Controller Hardware"]
  node_eeprom[("EEPROM")]
  node_mpu["MPU6050"]
  node_esc["Motor ESC"]
  node_switches["Switches and Buttons"]
end

node_modeler(("Modeler"))
node_aircraft(("Model Aircraft"))

node_modeler -->|"configures and monitors"| node_desktop_app
node_desktop_app -->|"communicates serially"| node_firmware
node_desktop_app -.->|"flashes firmware"| node_firmware
node_firmware -.->|"runs flight control"| node_sequencer
node_firmware -.->|"updates sensing"| node_gyro
node_firmware -.->|"serves serial menu"| node_terminal
node_buttons -->|"sets run state"| node_firmware
node_sequencer -->|"reads settings"| node_config
node_sequencer -->|"sets state indication"| node_leds
node_sequencer -->|"writes throttle PWM"| node_esc
node_gyro -->|"implements"| node_gyro_api
node_gyro -->|"reads motion"| node_mpu
node_gyro -->|"checks flight state"| node_sequencer
node_gyro -->|"cuts throttle on lap limit"| node_esc
node_terminal -->|"implements"| node_terminal_api
node_terminal -->|"requests safety check"| node_gyro
node_terminal -->|"edits settings"| node_config
node_terminal -->|"saves configuration"| node_eeprom
node_gyro -->|"persists calibration"| node_eeprom
node_firmware -->|"reads inputs"| node_switches
node_led_helpers -->|"provides LED class"| node_leds
node_esc -->|"controls motor"| node_aircraft

click node_desktop_app "https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/desktop_app.py"
click node_firmware "https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/cheesehead_timer.ino"
click node_sequencer "https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/state_machine.cpp"
click node_config "https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/cheesehead_timer.h"
click node_gyro "https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/gyro.cpp"
click node_gyro_api "https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/gyro.h"
click node_terminal "https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/term.cpp"
click node_terminal_api "https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/term.h"
click node_buttons "https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/ButMenu.cpp"
click node_leds "https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/led.cpp"
click node_led_helpers "https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/led2.cpp"

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_desktop_app toneBlue
class node_firmware,node_sequencer,node_config toneAmber
class node_gyro,node_gyro_api toneMint
class node_terminal,node_terminal_api,node_buttons,node_leds,node_led_helpers toneRose
class node_eeprom,node_mpu,node_esc,node_switches,node_modeler,node_aircraft toneIndigo
```

## Components

### Desktop Companion

- [Desktop App](https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/desktop_app.py): `cheesehead_timer/desktop_app.py`

### Flight Control

- [Firmware Loop](https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/cheesehead_timer.ino): `cheesehead_timer/cheesehead_timer.ino`
- [Flight Sequencer](https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/state_machine.cpp): `cheesehead_timer/state_machine.cpp`
- [Timer Configuration](https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/cheesehead_timer.h): `cheesehead_timer/cheesehead_timer.h`

### Motion and Safety

- [Gyro Engine](https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/gyro.cpp): `cheesehead_timer/gyro.cpp`
- [Gyro Interface](https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/gyro.h): `cheesehead_timer/gyro.h`

### Operator Interface

- [Serial Terminal](https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/term.cpp): `cheesehead_timer/term.cpp`
- [Terminal Interface](https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/term.h): `cheesehead_timer/term.h`
- [Button Controls](https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/ButMenu.cpp): `cheesehead_timer/ButMenu.cpp`
- [State LEDs](https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/led.cpp): `cheesehead_timer/led.cpp`
- [LED Helpers](https://github.com/ne9n/new-timer/blob/dev/cheesehead_timer/led2.cpp): `cheesehead_timer/led2.cpp`

### Controller Hardware

- **EEPROM**
- **MPU6050**
- **Motor ESC**
- **Switches and Buttons**

### Other components

- **Modeler**
- **Model Aircraft**

## Connections

- Modeler → Desktop App: configures and monitors (evidence: `README.md`)
- Desktop App → Firmware Loop: communicates serially (evidence: `README.md`)
- Desktop App → Firmware Loop: flashes firmware (evidence: `README.md`)
- Firmware Loop → Flight Sequencer: runs flight control
- Firmware Loop → Gyro Engine: updates sensing
- Firmware Loop → Serial Terminal: serves serial menu
- Button Controls → Firmware Loop: sets run state (evidence: `cheesehead_timer/ButMenu.cpp`)
- Flight Sequencer → Timer Configuration: reads settings (evidence: `cheesehead_timer/state_machine.cpp`)
- Flight Sequencer → State LEDs: sets state indication (evidence: `cheesehead_timer/state_machine.cpp`)
- Flight Sequencer → Motor ESC: writes throttle PWM (evidence: `README.md`)
- Gyro Engine → Gyro Interface: implements (evidence: `cheesehead_timer/gyro.cpp`)
- Gyro Engine → MPU6050: reads motion (evidence: `README.md`)
- Gyro Engine → Flight Sequencer: checks flight state (evidence: `cheesehead_timer/gyro.cpp`)
- Gyro Engine → Motor ESC: cuts throttle on lap limit (evidence: `cheesehead_timer/gyro.cpp`)
- Serial Terminal → Terminal Interface: implements (evidence: `cheesehead_timer/term.cpp`)
- Serial Terminal → Gyro Engine: requests safety check (evidence: `cheesehead_timer/term.cpp`)
- Serial Terminal → Timer Configuration: edits settings (evidence: `cheesehead_timer/term.cpp`)
- Serial Terminal → EEPROM: saves configuration (evidence: `cheesehead_timer/term.cpp`)
- Gyro Engine → EEPROM: persists calibration (evidence: `cheesehead_timer/gyro.cpp`)
- Firmware Loop → Switches and Buttons: reads inputs (evidence: `README.md`)
- LED Helpers → State LEDs: provides LED class (evidence: `cheesehead_timer/led2.cpp`)
- Motor ESC → Model Aircraft: controls motor (evidence: `README.md`)
