# lihaolun201003/air-firmware architecture

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

- Interactive diagram: https://gitdiagram.com/lihaolun201003/air-firmware
- Repository: https://github.com/lihaolun201003/air-firmware

## Overview

AIR is STM32-based air-monitor firmware for a PMS5003ST sensor, ILI9341 display and HC-06 Bluetooth link. Its principal workflow receives and parses sensor frames, tracks reading freshness/status, presents measurements and diagnostics on the display, and optionally streams telemetry over Bluetooth using Blinker JSON or the legacy ENV protocol. The current main loop and several implementation details are only partially excerpted; uncertain runtime links are shown as unverified rather than asserted.

Main entry points: [`AIR/src/main.cpp`](https://github.com/lihaolun201003/air-firmware/blob/main/AIR/src/main.cpp) (Firmware loop), [`AIR/src/air_bluetooth.cpp`](https://github.com/lihaolun201003/air-firmware/blob/main/AIR/src/air_bluetooth.cpp) (Bluetooth service), [`AIR/src/boot_animation.cpp`](https://github.com/lihaolun201003/air-firmware/blob/main/AIR/src/boot_animation.cpp) (Boot animation), [`AIR/include/pms5003st.h`](https://github.com/lihaolun201003/air-firmware/blob/main/AIR/include/pms5003st.h) (Frame parser)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_acquisition["Sensor acquisition"]
  node_parser["Frame parser<br/>[pms5003st.h]"]
  node_telemetry["Reading status<br/>[air_bluetooth.h]"]
end

subgraph group_presentation["Display experience"]
  node_display["Measurement display<br/>[main.cpp]"]
  node_bootanimation["Boot animation<br/>[boot_animation.cpp]"]
  node_bootasset["Character asset"]
  node_bootdisplay["Panel startup<br/>[boot_display.cpp]"]
end

subgraph group_connectivity["Bluetooth telemetry"]
  node_bluetooth["Bluetooth service<br/>[air_bluetooth.cpp]"]
  node_protocol["Telemetry formats<br/>[air_bluetooth.h]"]
end

node_operator(("Device operator"))
node_firmware["Firmware loop<br/>[main.cpp]"]
node_pms{{"PMS5003ST sensor"}}
node_hc06{{"HC-06 / Blinker app"}}

node_pms -.->|"sends frames"| node_firmware
node_firmware -.->|"feeds bytes"| node_parser
node_firmware -.->|"tracks readings"| node_telemetry
node_firmware -.->|"renders readings"| node_display
node_firmware -.->|"starts animation"| node_bootanimation
node_bootanimation -->|"uses pixels"| node_bootasset
node_firmware -.->|"initializes panel"| node_bootdisplay
node_firmware -.->|"polls link"| node_bluetooth
node_bluetooth -.->|"formats telemetry"| node_protocol
node_bluetooth -.->|"sends telemetry"| node_hc06
node_operator -.->|"views readings"| node_firmware

click node_firmware "https://github.com/lihaolun201003/air-firmware/blob/main/AIR/src/main.cpp"
click node_parser "https://github.com/lihaolun201003/air-firmware/blob/main/AIR/include/pms5003st.h"
click node_telemetry "https://github.com/lihaolun201003/air-firmware/blob/main/AIR/include/air_bluetooth.h"
click node_display "https://github.com/lihaolun201003/air-firmware/blob/main/AIR/src/main.cpp"
click node_bootanimation "https://github.com/lihaolun201003/air-firmware/blob/main/AIR/src/boot_animation.cpp"
click node_bootasset "https://github.com/lihaolun201003/air-firmware/blob/main/AIR/include/boot_character_data.h"
click node_bootdisplay "https://github.com/lihaolun201003/air-firmware/blob/main/AIR/src/boot_display.cpp"
click node_bluetooth "https://github.com/lihaolun201003/air-firmware/blob/main/AIR/src/air_bluetooth.cpp"
click node_protocol "https://github.com/lihaolun201003/air-firmware/blob/main/AIR/include/air_bluetooth.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_parser,node_telemetry toneBlue
class node_display,node_bootanimation,node_bootasset,node_bootdisplay toneAmber
class node_bluetooth,node_protocol toneMint
class node_operator,node_pms,node_hc06 toneIndigo
class node_firmware toneTeal
```

## Components

### Sensor acquisition

- [Frame parser](https://github.com/lihaolun201003/air-firmware/blob/main/AIR/include/pms5003st.h): `AIR/include/pms5003st.h`
- [Reading status](https://github.com/lihaolun201003/air-firmware/blob/main/AIR/include/air_bluetooth.h): `AIR/include/air_bluetooth.h`

### Display experience

- [Measurement display](https://github.com/lihaolun201003/air-firmware/blob/main/AIR/src/main.cpp): `AIR/src/main.cpp`
- [Boot animation](https://github.com/lihaolun201003/air-firmware/blob/main/AIR/src/boot_animation.cpp): `AIR/src/boot_animation.cpp`
- [Character asset](https://github.com/lihaolun201003/air-firmware/blob/main/AIR/include/boot_character_data.h): `AIR/include/boot_character_data.h`
- [Panel startup](https://github.com/lihaolun201003/air-firmware/blob/main/AIR/src/boot_display.cpp): `AIR/src/boot_display.cpp`

### Bluetooth telemetry

- [Bluetooth service](https://github.com/lihaolun201003/air-firmware/blob/main/AIR/src/air_bluetooth.cpp): `AIR/src/air_bluetooth.cpp`
- [Telemetry formats](https://github.com/lihaolun201003/air-firmware/blob/main/AIR/include/air_bluetooth.h): `AIR/include/air_bluetooth.h`

### Other components

- **Device operator**
- [Firmware loop](https://github.com/lihaolun201003/air-firmware/blob/main/AIR/src/main.cpp): `AIR/src/main.cpp`
- **PMS5003ST sensor**
- **HC-06 / Blinker app**

## Connections

- PMS5003ST sensor → Firmware loop: sends frames
- Firmware loop → Frame parser: feeds bytes (evidence: `AIR/src/main.cpp`)
- Firmware loop → Reading status: tracks readings (evidence: `AIR/src/main.cpp`)
- Firmware loop → Measurement display: renders readings (evidence: `AIR/src/main.cpp`)
- Firmware loop → Boot animation: starts animation
- Boot animation → Character asset: uses pixels (evidence: `AIR/src/boot_animation.cpp`)
- Firmware loop → Panel startup: initializes panel
- Firmware loop → Bluetooth service: polls link
- Bluetooth service → Telemetry formats: formats telemetry (evidence: `AIR/src/air_bluetooth.cpp`)
- Bluetooth service → HC-06 / Blinker app: sends telemetry
- Device operator → Firmware loop: views readings
