# sstaub/timer architecture

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

- Interactive diagram: https://gitdiagram.com/sstaub/timer
- Repository: https://github.com/sstaub/timer
- Video tour (about a minute): https://gitdiagram.com/sstaub/timer/video

## Overview

This is a small Arduino timing library: a sketch creates a Timer, controls its running or paused state, and reads elapsed time in milliseconds or microseconds. The public header declares the API; Timer.cpp implements it using Arduino’s millis() and micros() clock functions. The excerpts show those clock calls and API declarations, while the README documents how sketches use the timer. The graph stays focused on runtime behavior; the example sketch is illustrative rather than a separate subsystem.

Main entry points: [`Timer.h`](https://github.com/sstaub/timer/blob/main/Timer.h) (Timer API), [`Timer.cpp`](https://github.com/sstaub/timer/blob/main/Timer.cpp) (Timer runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_sketch(("Arduino sketch"))
node_timer_api["Timer API<br/>[Timer.h]"]
node_timer_runtime["Timer runtime<br/>[Timer.cpp]"]
node_arduino_clock["Arduino clock"]

node_sketch -->|"uses"| node_timer_api
node_timer_runtime -->|"implements"| node_timer_api
node_timer_runtime -->|"reads ticks"| node_arduino_clock
node_timer_api -->|"returns elapsed time"| node_sketch

click node_timer_api "https://github.com/sstaub/timer/blob/main/Timer.h"
click node_timer_runtime "https://github.com/sstaub/timer/blob/main/Timer.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_sketch,node_arduino_clock toneIndigo
class node_timer_api toneMint
class node_timer_runtime toneTeal
```

## Components

### Other components

- **Arduino sketch**
- [Timer API](https://github.com/sstaub/timer/blob/main/Timer.h): `Timer.h`
- [Timer runtime](https://github.com/sstaub/timer/blob/main/Timer.cpp): `Timer.cpp`
- **Arduino clock**

## Connections

- Arduino sketch → Timer API: uses (evidence: `README.md`)
- Timer runtime → Timer API: implements (evidence: `Timer.cpp`)
- Timer runtime → Arduino clock: reads ticks (evidence: `Timer.cpp`)
- Timer API → Arduino sketch: returns elapsed time (evidence: `README.md`)
