# maujabur/harpa_vl53l1x architecture

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

- Interactive diagram: https://gitdiagram.com/maujabur/harpa_vl53l1x
- Repository: https://github.com/maujabur/harpa_vl53l1x

## Overview

This is embedded firmware for a laser harp: it initializes a configured array of VL53L1X sensors, refreshes cached measurements without waiting for each sample, applies per-sensor press/release thresholds, and reports transitions and optional telemetry. The sampled source configures ten sensors and emits USB keyboard events; this conflicts with the README’s claims of twelve sensors and no keyboard output. The graph follows the sampled implementation where evidence is available and retains documented calibration and diagnostic capabilities. Relationships are limited to shown calls and data use; unsampled details are omitted.

Main entry points: [`src/main.cpp`](https://github.com/maujabur/harpa_vl53l1x/blob/main/src/main.cpp) (Firmware loop), [`src/harpa_controller.cpp`](https://github.com/maujabur/harpa_vl53l1x/blob/main/src/harpa_controller.cpp) (Harp controller), [`src/lidar_array.cpp`](https://github.com/maujabur/harpa_vl53l1x/blob/main/src/lidar_array.cpp) (Sensor array), [`src/lidar_sensor.cpp`](https://github.com/maujabur/harpa_vl53l1x/blob/main/src/lidar_sensor.cpp) (Sensor driver)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_acquisition["Sensor acquisition"]
  node_array["Sensor array<br/>[lidar_array.cpp]"]
  node_sensor["Sensor driver<br/>[lidar_sensor.cpp]"]
  node_configuration["Sensor configuration<br/>[lidar_config.h]"]
  node_cache["Reading cache<br/>[lidar_reading.h]"]
  node_fixed_array["Fixed-size array<br/>[harpa_array.h]"]
end

subgraph group_interaction["Harp interaction"]
  node_controller["Harp controller"]
  node_frame["Harp state frame<br/>[harpa_controller.h]"]
end

subgraph group_outputs["Firmware outputs"]
  node_entry["Firmware loop<br/>[main.cpp]"]
  node_keymap["Sensor keymap<br/>[harpa_keymap.h]"]
end

node_sensor_hardware(("ToF sensors"))
node_keyboard["USB keyboard output"]
node_serial["Serial diagnostics"]

node_entry -->|"services"| node_array
node_array -->|"initializes and services"| node_sensor
node_sensor -->|"reads distances"| node_sensor_hardware
node_sensor -->|"uses settings"| node_configuration
node_array -->|"copies readings"| node_cache
node_entry -->|"updates from readings"| node_controller
node_controller -->|"checks validity and distance"| node_cache
node_controller -->|"applies thresholds"| node_configuration
node_controller -->|"produces transitions"| node_frame
node_entry -->|"looks up keys"| node_keymap
node_entry -->|"emits key events"| node_keyboard
node_entry -->|"prints status and telemetry"| node_serial

click node_entry "https://github.com/maujabur/harpa_vl53l1x/blob/main/src/main.cpp"
click node_array "https://github.com/maujabur/harpa_vl53l1x/blob/main/src/lidar_array.cpp"
click node_sensor "https://github.com/maujabur/harpa_vl53l1x/blob/main/src/lidar_sensor.cpp"
click node_configuration "https://github.com/maujabur/harpa_vl53l1x/blob/main/include/lidar_config.h"
click node_cache "https://github.com/maujabur/harpa_vl53l1x/blob/main/include/lidar_reading.h"
click node_fixed_array "https://github.com/maujabur/harpa_vl53l1x/blob/main/include/harpa_array.h"
click node_controller "https://github.com/maujabur/harpa_vl53l1x/blob/main/src/harpa_controller.cpp"
click node_frame "https://github.com/maujabur/harpa_vl53l1x/blob/main/include/harpa_controller.h"
click node_keymap "https://github.com/maujabur/harpa_vl53l1x/blob/main/include/harpa_keymap.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_array,node_sensor,node_configuration,node_cache,node_fixed_array toneBlue
class node_controller,node_frame toneAmber
class node_entry,node_keymap toneMint
class node_sensor_hardware,node_keyboard,node_serial toneIndigo
```

## Components

### Sensor acquisition

- [Sensor array](https://github.com/maujabur/harpa_vl53l1x/blob/main/src/lidar_array.cpp): `src/lidar_array.cpp`
- [Sensor driver](https://github.com/maujabur/harpa_vl53l1x/blob/main/src/lidar_sensor.cpp): `src/lidar_sensor.cpp`
- [Sensor configuration](https://github.com/maujabur/harpa_vl53l1x/blob/main/include/lidar_config.h): `include/lidar_config.h`
- [Reading cache](https://github.com/maujabur/harpa_vl53l1x/blob/main/include/lidar_reading.h): `include/lidar_reading.h`
- [Fixed-size array](https://github.com/maujabur/harpa_vl53l1x/blob/main/include/harpa_array.h): `include/harpa_array.h`

### Harp interaction

- [Harp controller](https://github.com/maujabur/harpa_vl53l1x/blob/main/src/harpa_controller.cpp): `src/harpa_controller.cpp`
- [Harp state frame](https://github.com/maujabur/harpa_vl53l1x/blob/main/include/harpa_controller.h): `include/harpa_controller.h`

### Firmware outputs

- [Firmware loop](https://github.com/maujabur/harpa_vl53l1x/blob/main/src/main.cpp): `src/main.cpp`
- [Sensor keymap](https://github.com/maujabur/harpa_vl53l1x/blob/main/include/harpa_keymap.h): `include/harpa_keymap.h`

### Other components

- **ToF sensors**
- **USB keyboard output**
- **Serial diagnostics**

## Connections

- Firmware loop → Sensor array: services (evidence: `src/main.cpp`)
- Sensor array → Sensor driver: initializes and services (evidence: `src/lidar_array.cpp`)
- Sensor driver → ToF sensors: reads distances (evidence: `src/lidar_sensor.cpp`)
- Sensor driver → Sensor configuration: uses settings (evidence: `src/lidar_sensor.cpp`)
- Sensor array → Reading cache: copies readings (evidence: `src/lidar_array.cpp`)
- Firmware loop → Harp controller: updates from readings (evidence: `src/main.cpp`)
- Harp controller → Reading cache: checks validity and distance (evidence: `src/harpa_controller.cpp`)
- Harp controller → Sensor configuration: applies thresholds (evidence: `src/harpa_controller.cpp`)
- Harp controller → Harp state frame: produces transitions (evidence: `src/harpa_controller.cpp`)
- Firmware loop → Sensor keymap: looks up keys (evidence: `src/main.cpp`)
- Firmware loop → USB keyboard output: emits key events (evidence: `src/main.cpp`)
- Firmware loop → Serial diagnostics: prints status and telemetry (evidence: `src/main.cpp`)
