# xinyuan-lilygo/lilygolib architecture

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

- Interactive diagram: https://gitdiagram.com/xinyuan-lilygo/lilygolib
- Repository: https://github.com/xinyuan-lilygo/lilygolib
- Video tour (about a minute): https://gitdiagram.com/xinyuan-lilygo/lilygolib/video

## Overview

LilyGoLib is an Arduino/ESP32 hardware library for several LilyGo boards. Its principal workflow is an application selecting a supported board API, initializing that board’s hardware, then using shared services for display, input, power, sensors, audio, and connectivity. The graph preserves the board-specific entry points and major documented service capabilities. Edges are limited to relationships visible in README statements or SOURCE INDEX references; unsampled implementation details are not inferred.

Main entry points: [`src/LilyGo_LoRa_Pager.cpp`](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/LilyGo_LoRa_Pager.cpp) (T-LoRa Pager), [`src/LilyGoWatchUltra.cpp`](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/LilyGoWatchUltra.cpp) (T-Watch Ultra), [`src/gps/GPS.cpp`](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/gps/GPS.cpp) (GPS Service), [`src/audio/AudioDevice.cpp`](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/audio/AudioDevice.cpp) (Audio Devices)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_boards["Board APIs"]
  node_watch["T-Watch<br/>[LilyGoWatch.cpp]"]
  node_watchv3["T-Watch V3<br/>[LilyGoWatch.cpp]"]
  node_watchs3["T-Watch S3<br/>[LilyGoWatchS3.cpp]"]
  node_watchultra["T-Watch Ultra"]
  node_pager["T-LoRa Pager"]
  node_tdeck["T-Deck<br/>[LilyGo_T_Deck.cpp]"]
end

subgraph group_runtime["Shared Runtime"]
  node_events["Event Dispatcher"]
  node_power["Power Management"]
end

subgraph group_io["Display and Input"]
  node_display["Display Interface"]
  node_brightness["Brightness Control"]
  node_keyboard["Keyboard Input<br/>[LilyGoKeyboard.cpp]"]
  node_keycombos["Key Combos"]
end

subgraph group_media["Audio and Sensors"]
  node_gps["GPS Service<br/>[GPS.cpp]"]
  node_nmea["NMEA Parser<br/>[minmea.c]"]
  node_audio["Audio Devices<br/>[AudioDevice.cpp]"]
  node_codec["Codec Support<br/>[esp_codec.cpp]"]
end

subgraph group_connectivity["Connectivity Services"]
  node_nfc["NFC Service"]
  node_usb["USB MSC and HID<br/>[USB_MSC.cpp]"]
  node_radio["Radio Helpers"]
  node_storage[("Board Storage")]
end

node_application(("Arduino Application"))

node_application -->|"uses board API"| node_watch
node_application -->|"uses board API"| node_watchv3
node_application -->|"uses board API"| node_watchs3
node_application -->|"uses board API"| node_watchultra
node_application -->|"uses board API"| node_pager
node_application -->|"uses board API"| node_tdeck
node_watchultra -->|"includes service"| node_gps
node_watchultra -->|"includes service"| node_audio
node_watchultra -->|"includes interface"| node_display
node_watchultra -->|"includes dispatcher"| node_events
node_watchultra -->|"includes interface"| node_power
node_watchultra -->|"includes control"| node_brightness
node_watchultra -->|"includes service"| node_nfc
node_pager -->|"includes interface"| node_power
node_pager -->|"includes interface"| node_display
node_pager -->|"includes service"| node_gps
node_pager -->|"includes input"| node_keyboard
node_pager -->|"includes service"| node_nfc
node_pager -->|"includes dispatcher"| node_events
node_pager -->|"includes service"| node_audio
node_pager -->|"includes helpers"| node_radio
node_audio -->|"uses codec"| node_codec
node_gps -->|"parses sentences"| node_nmea
node_usb -->|"exposes storage"| node_storage
node_application -->|"uses NFC service"| node_nfc

click node_watch "https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/LilyGoWatch.cpp"
click node_watchv3 "https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/LilyGoWatch.cpp"
click node_watchs3 "https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/LilyGoWatchS3.cpp"
click node_watchultra "https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/LilyGoWatchUltra.cpp"
click node_pager "https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/LilyGo_LoRa_Pager.cpp"
click node_tdeck "https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/LilyGo_T_Deck.cpp"
click node_events "https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/core/LilyGoEventManage.h"
click node_power "https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/core/LilyGoPowerManageInf.h"
click node_display "https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/display/LilyGoDispInterface.cpp"
click node_brightness "https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/display/BrightnessController.h"
click node_keyboard "https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/input/LilyGoKeyboard.cpp"
click node_keycombos "https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/input/KeyComboManager.cpp"
click node_gps "https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/gps/GPS.cpp"
click node_nmea "https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/gps/minmea.c"
click node_audio "https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/audio/AudioDevice.cpp"
click node_codec "https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/bsp_codec/esp_codec.cpp"
click node_nfc "https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/nfc/LilyGoNfcService.cpp"
click node_usb "https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/usb/USB_MSC.cpp"
click node_radio "https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/radio/LilyGoRadioHelper.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_watch,node_watchv3,node_watchs3,node_watchultra,node_pager,node_tdeck toneBlue
class node_events,node_power toneAmber
class node_display,node_brightness,node_keyboard,node_keycombos toneMint
class node_gps,node_nmea,node_audio,node_codec toneRose
class node_nfc,node_usb,node_radio,node_storage,node_application toneIndigo
```

## Components

### Board APIs

- [T-Watch](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/LilyGoWatch.cpp): `src/LilyGoWatch.cpp`
- [T-Watch V3](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/LilyGoWatch.cpp): `src/LilyGoWatch.cpp`
- [T-Watch S3](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/LilyGoWatchS3.cpp): `src/LilyGoWatchS3.cpp`
- [T-Watch Ultra](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/LilyGoWatchUltra.cpp): `src/LilyGoWatchUltra.cpp`
- [T-LoRa Pager](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/LilyGo_LoRa_Pager.cpp): `src/LilyGo_LoRa_Pager.cpp`
- [T-Deck](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/LilyGo_T_Deck.cpp): `src/LilyGo_T_Deck.cpp`

### Shared Runtime

- [Event Dispatcher](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/core/LilyGoEventManage.h): `src/core/LilyGoEventManage.h`
- [Power Management](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/core/LilyGoPowerManageInf.h): `src/core/LilyGoPowerManageInf.h`

### Display and Input

- [Display Interface](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/display/LilyGoDispInterface.cpp): `src/display/LilyGoDispInterface.cpp`
- [Brightness Control](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/display/BrightnessController.h): `src/display/BrightnessController.h`
- [Keyboard Input](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/input/LilyGoKeyboard.cpp): `src/input/LilyGoKeyboard.cpp`
- [Key Combos](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/input/KeyComboManager.cpp): `src/input/KeyComboManager.cpp`

### Audio and Sensors

- [GPS Service](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/gps/GPS.cpp): `src/gps/GPS.cpp`
- [NMEA Parser](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/gps/minmea.c): `src/gps/minmea.c`
- [Audio Devices](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/audio/AudioDevice.cpp): `src/audio/AudioDevice.cpp`
- [Codec Support](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/bsp_codec/esp_codec.cpp): `src/bsp_codec/esp_codec.cpp`

### Connectivity Services

- [NFC Service](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/nfc/LilyGoNfcService.cpp): `src/nfc/LilyGoNfcService.cpp`
- [USB MSC and HID](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/usb/USB_MSC.cpp): `src/usb/USB_MSC.cpp`
- [Radio Helpers](https://github.com/xinyuan-lilygo/lilygolib/blob/master/src/radio/LilyGoRadioHelper.h): `src/radio/LilyGoRadioHelper.h`
- **Board Storage**

### Other components

- **Arduino Application**

## Connections

- Arduino Application → T-Watch: uses board API
- Arduino Application → T-Watch V3: uses board API
- Arduino Application → T-Watch S3: uses board API
- Arduino Application → T-Watch Ultra: uses board API
- Arduino Application → T-LoRa Pager: uses board API
- Arduino Application → T-Deck: uses board API
- T-Watch Ultra → GPS Service: includes service
- T-Watch Ultra → Audio Devices: includes service
- T-Watch Ultra → Display Interface: includes interface
- T-Watch Ultra → Event Dispatcher: includes dispatcher
- T-Watch Ultra → Power Management: includes interface
- T-Watch Ultra → Brightness Control: includes control
- T-Watch Ultra → NFC Service: includes service
- T-LoRa Pager → Power Management: includes interface
- T-LoRa Pager → Display Interface: includes interface
- T-LoRa Pager → GPS Service: includes service
- T-LoRa Pager → Keyboard Input: includes input
- T-LoRa Pager → NFC Service: includes service
- T-LoRa Pager → Event Dispatcher: includes dispatcher
- T-LoRa Pager → Audio Devices: includes service
- T-LoRa Pager → Radio Helpers: includes helpers
- Audio Devices → Codec Support: uses codec
- GPS Service → NMEA Parser: parses sentences (evidence: `src/gps/GPS.cpp`)
- USB MSC and HID → Board Storage: exposes storage
- Arduino Application → NFC Service: uses NFC service
