# speeduino/ardu-stim architecture

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

- Interactive diagram: https://gitdiagram.com/speeduino/ardu-stim
- Repository: https://github.com/speeduino/ardu-stim

## Overview

Ardu-Stim combines an Electron desktop controller with Arduino firmware that generates simulated crank and cam signals for ECU testing. The user selects a serial port, configures a trigger pattern and RPM behavior, and can upload Nano firmware; the board then emits the selected signals. The GUI also provides wheel and scope visualization. Firmware storage and timing are separate internal concerns. Relationships are shown only where excerpts or the README support them; unsampled firmware entry-point connections are omitted.

Main entry points: [`ardustim/ardustim/comms.cpp`](https://github.com/speeduino/ardu-stim/blob/master/ardustim/ardustim/comms.cpp) (Command Protocol), [`UI/renderer.js`](https://github.com/speeduino/ardu-stim/blob/master/UI/renderer.js) (GUI Controller), [`UI/main.js`](https://github.com/speeduino/ardu-stim/blob/master/UI/main.js) (Firmware Uploader), [`ardustim/ardustim/ardustim.ino`](https://github.com/speeduino/ardu-stim/blob/master/ardustim/ardustim/ardustim.ino) (Firmware Runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_desktop["Desktop GUI"]
  node_window["Electron Window<br/>[main.js]"]
  node_renderer["GUI Controller<br/>[renderer.js]"]
  node_wheel_view["Wheel Visualizer<br/>[gear_generator.js]"]
  node_scope_view["Scope Visualizer<br/>[scope_generator.js]"]
  node_uploader["Firmware Uploader<br/>[main.js]"]
end

subgraph group_firmware["Arduino Firmware"]
  node_firmware_entry["Firmware Runtime<br/>[ardustim.ino]"]
  node_serial_commands["Command Protocol<br/>[comms.cpp]"]
  node_config["Runtime Configuration<br/>[globals.h]"]
  node_storage[("EEPROM Settings<br/>[storage.h]")]
  node_timing["RPM And Timing<br/>[ardustim.h]"]
end

subgraph group_patterns["Pattern Data"]
  node_wheel_defs["Trigger Patterns<br/>[wheel_defs.h]"]
end

subgraph group_hardware["Device I/O"]
  node_serial["Serial Device"]
  node_avrdude["AVRDUDE"]
  node_hex["Nano Firmware Image<br/>[nano.hex]"]
  node_output["Engine Signals"]
end

node_user(("Operator"))

node_user -->|"configures"| node_renderer
node_renderer -->|"reads and writes"| node_serial
node_renderer -->|"requests upload"| node_window
node_window -->|"handles upload"| node_uploader
node_uploader -->|"runs"| node_avrdude
node_uploader -->|"flashes"| node_hex
node_serial_commands -->|"saves settings"| node_storage
node_serial_commands -->|"reads and updates"| node_config
node_serial_commands -->|"reads selected pattern"| node_wheel_defs
node_firmware_entry -.->|"generates signals"| node_output
node_user -.->|"views pattern"| node_wheel_view
node_user -.->|"views waveform"| node_scope_view
node_firmware_entry -.->|"uses timing logic"| node_timing

click node_window "https://github.com/speeduino/ardu-stim/blob/master/UI/main.js"
click node_renderer "https://github.com/speeduino/ardu-stim/blob/master/UI/renderer.js"
click node_wheel_view "https://github.com/speeduino/ardu-stim/blob/master/UI/gear_generator.js"
click node_scope_view "https://github.com/speeduino/ardu-stim/blob/master/UI/scope_generator.js"
click node_uploader "https://github.com/speeduino/ardu-stim/blob/master/UI/main.js"
click node_hex "https://github.com/speeduino/ardu-stim/blob/master/UI/firmwares/nano.hex"
click node_firmware_entry "https://github.com/speeduino/ardu-stim/blob/master/ardustim/ardustim/ardustim.ino"
click node_serial_commands "https://github.com/speeduino/ardu-stim/blob/master/ardustim/ardustim/comms.cpp"
click node_config "https://github.com/speeduino/ardu-stim/blob/master/ardustim/ardustim/globals.h"
click node_storage "https://github.com/speeduino/ardu-stim/blob/master/ardustim/ardustim/storage.h"
click node_timing "https://github.com/speeduino/ardu-stim/blob/master/ardustim/ardustim/ardustim.h"
click node_wheel_defs "https://github.com/speeduino/ardu-stim/blob/master/ardustim/ardustim/wheel_defs.h"

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_window,node_renderer,node_wheel_view,node_scope_view,node_uploader toneBlue
class node_firmware_entry,node_serial_commands,node_config,node_storage,node_timing toneAmber
class node_wheel_defs toneMint
class node_serial,node_avrdude,node_hex,node_output toneRose
class node_user toneIndigo
```

## Components

### Desktop GUI

- [Electron Window](https://github.com/speeduino/ardu-stim/blob/master/UI/main.js): `UI/main.js`
- [GUI Controller](https://github.com/speeduino/ardu-stim/blob/master/UI/renderer.js): `UI/renderer.js`
- [Wheel Visualizer](https://github.com/speeduino/ardu-stim/blob/master/UI/gear_generator.js): `UI/gear_generator.js`
- [Scope Visualizer](https://github.com/speeduino/ardu-stim/blob/master/UI/scope_generator.js): `UI/scope_generator.js`
- [Firmware Uploader](https://github.com/speeduino/ardu-stim/blob/master/UI/main.js): `UI/main.js`

### Arduino Firmware

- [Firmware Runtime](https://github.com/speeduino/ardu-stim/blob/master/ardustim/ardustim/ardustim.ino): `ardustim/ardustim/ardustim.ino`
- [Command Protocol](https://github.com/speeduino/ardu-stim/blob/master/ardustim/ardustim/comms.cpp): `ardustim/ardustim/comms.cpp`
- [Runtime Configuration](https://github.com/speeduino/ardu-stim/blob/master/ardustim/ardustim/globals.h): `ardustim/ardustim/globals.h`
- [EEPROM Settings](https://github.com/speeduino/ardu-stim/blob/master/ardustim/ardustim/storage.h): `ardustim/ardustim/storage.h`
- [RPM And Timing](https://github.com/speeduino/ardu-stim/blob/master/ardustim/ardustim/ardustim.h): `ardustim/ardustim/ardustim.h`

### Pattern Data

- [Trigger Patterns](https://github.com/speeduino/ardu-stim/blob/master/ardustim/ardustim/wheel_defs.h): `ardustim/ardustim/wheel_defs.h`

### Device I/O

- **Serial Device**
- **AVRDUDE**
- [Nano Firmware Image](https://github.com/speeduino/ardu-stim/blob/master/UI/firmwares/nano.hex): `UI/firmwares/nano.hex`
- **Engine Signals**

### Other components

- **Operator**

## Connections

- Operator → GUI Controller: configures (evidence: `README.md`)
- GUI Controller → Serial Device: reads and writes (evidence: `UI/renderer.js`)
- GUI Controller → Electron Window: requests upload (evidence: `UI/renderer.js`)
- Electron Window → Firmware Uploader: handles upload (evidence: `UI/main.js`)
- Firmware Uploader → AVRDUDE: runs (evidence: `UI/main.js`)
- Firmware Uploader → Nano Firmware Image: flashes (evidence: `UI/main.js`)
- Command Protocol → EEPROM Settings: saves settings (evidence: `ardustim/ardustim/comms.cpp`)
- Command Protocol → Runtime Configuration: reads and updates (evidence: `ardustim/ardustim/comms.cpp`)
- Command Protocol → Trigger Patterns: reads selected pattern (evidence: `ardustim/ardustim/comms.cpp`)
- Firmware Runtime → Engine Signals: generates signals (evidence: `README.md`)
- Operator → Wheel Visualizer: views pattern (evidence: `README.md`)
- Operator → Scope Visualizer: views waveform
- Firmware Runtime → RPM And Timing: uses timing logic
