# do-gongil/vl53l8cx-tof architecture

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

- Interactive diagram: https://gitdiagram.com/do-gongil/vl53l8cx-tof
- Repository: https://github.com/do-gongil/vl53l8cx-tof

## Overview

This repository is an ESP32-S3 firmware and PC viewer for live 8×8 VL53L8CX distance measurements. The main workflow acquires sensor data over I2C, emits one serial frame per measurement, then reads, validates, and displays the latest valid frame as a heatmap. The viewer also reports status lines and marks invalid cells. Relationships are supported by the sampled firmware and viewer source and the README; build, test, and demo assets are omitted.

Main entry points: [`tools/tof_viewer.py`](https://github.com/do-gongil/vl53l8cx-tof/blob/main/tools/tof_viewer.py) (Read serial frames), [`src/main.cpp`](https://github.com/do-gongil/vl53l8cx-tof/blob/main/src/main.cpp) (Acquire measurements)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_firmware["Sensor firmware"]
  node_acquire["Acquire measurements<br/>[main.cpp]"]
  node_serialize["Serialize frames<br/>[main.cpp]"]
end

subgraph group_viewer_io["Viewer input"]
  node_serial_read["Read serial frames<br/>[tof_viewer.py]"]
  node_parse["Validate frame<br/>[tof_viewer.py]"]
end

subgraph group_viewer_display["Viewer display"]
  node_heatmap["Render heatmap<br/>[tof_viewer.py]"]
end

node_sensor(("VL53L8CX sensor"))
node_user(("Viewer user"))

node_sensor -->|"provides readings"| node_acquire
node_acquire -->|"formats measurements"| node_serialize
node_serialize -->|"streams frames"| node_serial_read
node_user -->|"starts viewer"| node_serial_read
node_serial_read -->|"validates lines"| node_parse
node_parse -->|"updates display"| node_heatmap

click node_acquire "https://github.com/do-gongil/vl53l8cx-tof/blob/main/src/main.cpp"
click node_serialize "https://github.com/do-gongil/vl53l8cx-tof/blob/main/src/main.cpp"
click node_serial_read "https://github.com/do-gongil/vl53l8cx-tof/blob/main/tools/tof_viewer.py"
click node_parse "https://github.com/do-gongil/vl53l8cx-tof/blob/main/tools/tof_viewer.py"
click node_heatmap "https://github.com/do-gongil/vl53l8cx-tof/blob/main/tools/tof_viewer.py"

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_acquire,node_serialize,node_user toneBlue
class node_serial_read,node_parse toneAmber
class node_heatmap toneMint
class node_sensor toneIndigo
```

## Components

### Sensor firmware

- [Acquire measurements](https://github.com/do-gongil/vl53l8cx-tof/blob/main/src/main.cpp): `src/main.cpp`
- [Serialize frames](https://github.com/do-gongil/vl53l8cx-tof/blob/main/src/main.cpp): `src/main.cpp`

### Viewer input

- [Read serial frames](https://github.com/do-gongil/vl53l8cx-tof/blob/main/tools/tof_viewer.py): `tools/tof_viewer.py`
- [Validate frame](https://github.com/do-gongil/vl53l8cx-tof/blob/main/tools/tof_viewer.py): `tools/tof_viewer.py`

### Viewer display

- [Render heatmap](https://github.com/do-gongil/vl53l8cx-tof/blob/main/tools/tof_viewer.py): `tools/tof_viewer.py`

### Other components

- **VL53L8CX sensor**
- **Viewer user**

## Connections

- VL53L8CX sensor → Acquire measurements: provides readings (evidence: `README.md`)
- Acquire measurements → Serialize frames: formats measurements (evidence: `src/main.cpp`)
- Serialize frames → Read serial frames: streams frames (evidence: `README.md`)
- Viewer user → Read serial frames: starts viewer (evidence: `README.md`)
- Read serial frames → Validate frame: validates lines (evidence: `tools/tof_viewer.py`)
- Validate frame → Render heatmap: updates display (evidence: `tools/tof_viewer.py`)
