# wwrrj/hydrogenui architecture

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

- Interactive diagram: https://gitdiagram.com/wwrrj/hydrogenui
- Repository: https://github.com/wwrrj/hydrogenui

## Overview

HydrogenUI is an embedded C++ UI framework: an application loop updates widgets and a smoothed camera, renders through a hardware-independent graphics layer, then refreshes a display through a HAL. The README also documents adaptive scrolling lists, FPS monitoring, UTF-8 text, and a one-line U8g2 deployment helper. The sampled sources show list, widget, graphics, application, and U8g2 behavior; FPS implementation was not sampled, and the README’s Button capability is not evident in the supplied source.

Main entry points: [`src/core/app.cpp`](https://github.com/wwrrj/hydrogenui/blob/main/src/core/app.cpp) (Application Manager), [`src/ui/list.cpp`](https://github.com/wwrrj/hydrogenui/blob/main/src/ui/list.cpp) (Adaptive List), [`src/ui/widget.cpp`](https://github.com/wwrrj/hydrogenui/blob/main/src/ui/widget.cpp) (Widget Library), [`src/core/graphics.cpp`](https://github.com/wwrrj/hydrogenui/blob/main/src/core/graphics.cpp) (Graphics Engine)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application Core"]
  node_deploy["U8g2 Deploy<br/>[HydrogenUI.h]"]
  node_application["Application Manager<br/>[app.cpp]"]
  node_camera["Virtual Camera<br/>[camera.h]"]
end

subgraph group_ui["UI Components"]
  node_list["Adaptive List<br/>[list.cpp]"]
  node_widgets["Widget Library<br/>[widget.cpp]"]
  node_fps["FPS Counter<br/>[fps_counter.h]"]
end

subgraph group_render["Rendering"]
  node_graphics["Graphics Engine<br/>[graphics.cpp]"]
end

subgraph group_hardware["Display Hardware"]
  node_hal["Display HAL<br/>[hal.h]"]
  node_u8g2hal["U8g2 Adapter<br/>[hal_u8g2.h]"]
end

node_developer(("Application Developer"))
node_loop(("Embedded Main Loop"))
node_u8g2["U8g2 Driver"]
node_display["Embedded Display"]

node_developer -.->|"calls optionally"| node_deploy
node_deploy -->|"initializes"| node_application
node_developer -->|"adds widgets"| node_application
node_loop -->|"calls update"| node_application
node_application -->|"updates"| node_camera
node_application -->|"sets camera"| node_graphics
node_application -->|"clears and refreshes"| node_hal
node_application -->|"updates and draws"| node_widgets
node_application -->|"updates and draws"| node_list
node_list -->|"sets target and reads position"| node_camera
node_list -->|"draws and measures text"| node_graphics
node_list -->|"updates and draws items"| node_widgets
node_widgets -->|"draws controls"| node_graphics
node_fps -->|"extends widget API"| node_widgets
node_graphics -->|"draws pixels and text"| node_hal
node_hal -->|"implemented by"| node_u8g2hal
node_u8g2hal -->|"invokes driver"| node_u8g2
node_u8g2 -->|"updates display"| node_display

click node_deploy "https://github.com/wwrrj/hydrogenui/blob/main/src/HydrogenUI.h"
click node_application "https://github.com/wwrrj/hydrogenui/blob/main/src/core/app.cpp"
click node_camera "https://github.com/wwrrj/hydrogenui/blob/main/src/core/camera.h"
click node_list "https://github.com/wwrrj/hydrogenui/blob/main/src/ui/list.cpp"
click node_widgets "https://github.com/wwrrj/hydrogenui/blob/main/src/ui/widget.cpp"
click node_fps "https://github.com/wwrrj/hydrogenui/blob/main/src/ui/fps_counter.h"
click node_graphics "https://github.com/wwrrj/hydrogenui/blob/main/src/core/graphics.cpp"
click node_hal "https://github.com/wwrrj/hydrogenui/blob/main/src/hal/hal.h"
click node_u8g2hal "https://github.com/wwrrj/hydrogenui/blob/main/src/hal/hal_u8g2.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_deploy,node_application,node_camera toneBlue
class node_list,node_widgets,node_fps toneAmber
class node_graphics toneMint
class node_hal,node_u8g2hal toneRose
class node_developer,node_loop,node_u8g2,node_display toneIndigo
```

## Components

### Application Core

- [U8g2 Deploy](https://github.com/wwrrj/hydrogenui/blob/main/src/HydrogenUI.h): `src/HydrogenUI.h`
- [Application Manager](https://github.com/wwrrj/hydrogenui/blob/main/src/core/app.cpp): `src/core/app.cpp`
- [Virtual Camera](https://github.com/wwrrj/hydrogenui/blob/main/src/core/camera.h): `src/core/camera.h`

### UI Components

- [Adaptive List](https://github.com/wwrrj/hydrogenui/blob/main/src/ui/list.cpp): `src/ui/list.cpp`
- [Widget Library](https://github.com/wwrrj/hydrogenui/blob/main/src/ui/widget.cpp): `src/ui/widget.cpp`
- [FPS Counter](https://github.com/wwrrj/hydrogenui/blob/main/src/ui/fps_counter.h): `src/ui/fps_counter.h`

### Rendering

- [Graphics Engine](https://github.com/wwrrj/hydrogenui/blob/main/src/core/graphics.cpp): `src/core/graphics.cpp`

### Display Hardware

- [Display HAL](https://github.com/wwrrj/hydrogenui/blob/main/src/hal/hal.h): `src/hal/hal.h`
- [U8g2 Adapter](https://github.com/wwrrj/hydrogenui/blob/main/src/hal/hal_u8g2.h): `src/hal/hal_u8g2.h`

### Other components

- **Application Developer**
- **Embedded Main Loop**
- **U8g2 Driver**
- **Embedded Display**

## Connections

- Application Developer → U8g2 Deploy: calls optionally
- U8g2 Deploy → Application Manager: initializes
- Application Developer → Application Manager: adds widgets
- Embedded Main Loop → Application Manager: calls update
- Application Manager → Virtual Camera: updates
- Application Manager → Graphics Engine: sets camera
- Application Manager → Display HAL: clears and refreshes
- Application Manager → Widget Library: updates and draws
- Application Manager → Adaptive List: updates and draws
- Adaptive List → Virtual Camera: sets target and reads position
- Adaptive List → Graphics Engine: draws and measures text
- Adaptive List → Widget Library: updates and draws items
- Widget Library → Graphics Engine: draws controls
- FPS Counter → Widget Library: extends widget API
- Graphics Engine → Display HAL: draws pixels and text
- Display HAL → U8g2 Adapter: implemented by
- U8g2 Adapter → U8g2 Driver: invokes driver
- U8g2 Driver → Embedded Display: updates display
