# phamhungcrab/it4210-he-nhung architecture

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

- Interactive diagram: https://gitdiagram.com/phamhungcrab/it4210-he-nhung
- Repository: https://github.com/phamhungcrab/it4210-he-nhung

## Overview

This repository is firmware for a short-range ultrasonic scanning radar on the STM32F429I-DISC1, with TouchGFX controls and display. The documented workflow sweeps an HC-SR04 on a servo, measures echo timing, classifies detections, and updates the screen and near-object alerts. The graph preserves the documented FreeRTOS/UI and user-control capabilities. Relationships are limited to README-described behavior and visible/indexed references; several UI screens and peripheral implementations were not sampled, so their detailed call paths are not asserted.

Main entry points: [`radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_app.c`](https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_app.c) (Scan and detection), [`radar_short_range_touchgfx/TouchGFX/gui/src/screenscan_screen/ScreenScanView.cpp`](https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/TouchGFX/gui/src/screenscan_screen/ScreenScanView.cpp) (Scan screen), [`radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_ui_bridge.c`](https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_ui_bridge.c) (UI data and controls), [`radar_short_range_touchgfx/Core/Src/main.c`](https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/Core/Src/main.c) (STM32 firmware)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_radar["Radar sensing"]
  node_radar_app["Scan and detection<br/>[radar_app.c]"]
  node_hcsr04["Echo measurement<br/>[hcsr04.c]"]
end

subgraph group_control["Firmware control"]
  node_firmware["STM32 firmware<br/>[main.c]"]
  node_config["Radar settings<br/>[radar_config.h]"]
  node_types["Radar data types<br/>[radar_types.h]"]
  node_debug["UART diagnostics<br/>[radar_debug.c]"]
end

subgraph group_interface["TouchGFX interface"]
  node_bridge["UI data and controls<br/>[radar_ui_bridge.c]"]
  node_scan_view["Scan screen<br/>[ScreenScanView.cpp]"]
  node_settings_view["Settings screen"]
  node_home_view["Home screen<br/>[ScreenHomeView.cpp]"]
  node_info_view["Info screen<br/>[ScreenInfoView.cpp]"]
  node_touch_controller["Touch input"]
end

subgraph group_hardware["Board I/O"]
  node_servo["Servo motion<br/>[servo_mg90s.c]"]
  node_alert["LED and buzzer<br/>[buzzer_led.c]"]
  node_touch_driver["STMPE811 driver<br/>[stmpe811.c]"]
end

node_operator(("Operator"))
node_obstacle(("Obstacle"))

node_operator -.->|"sets scan options"| node_settings_view
node_operator -.->|"presses USER button"| node_firmware
node_obstacle -.->|"returns echo"| node_hcsr04
node_firmware -.->|"starts radar task"| node_radar_app
node_radar_app -->|"uses thresholds"| node_config
node_radar_app -->|"measures distance"| node_hcsr04
node_radar_app -->|"sets scan angle"| node_servo
node_radar_app -->|"updates alerts"| node_alert
node_radar_app -->|"publishes radar data"| node_bridge
node_radar_app -->|"logs measurements"| node_debug
node_radar_app -->|"uses data model"| node_types
node_scan_view -->|"starts scanning"| node_radar_app
node_scan_view -->|"reads radar data"| node_bridge
node_scan_view -->|"logs UI state"| node_debug
node_settings_view -.->|"changes controls"| node_bridge
node_info_view -.->|"reads radar state"| node_bridge
node_touch_controller -->|"reads touch state"| node_touch_driver
node_touch_driver -.->|"receives touch"| node_operator
node_bridge -.->|"feeds display"| node_scan_view
node_radar_app -.->|"sends queue updates"| node_scan_view

click node_firmware "https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/Core/Src/main.c"
click node_radar_app "https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_app.c"
click node_config "https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_config.h"
click node_hcsr04 "https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/STM32CubeIDE/Application/User/hcsr04.c"
click node_servo "https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/STM32CubeIDE/Application/User/servo_mg90s.c"
click node_alert "https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/STM32CubeIDE/Application/User/buzzer_led.c"
click node_bridge "https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_ui_bridge.c"
click node_types "https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_types.h"
click node_debug "https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_debug.c"
click node_scan_view "https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/TouchGFX/gui/src/screenscan_screen/ScreenScanView.cpp"
click node_settings_view "https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/TouchGFX/gui/src/screensettings_screen/ScreenSettingsView.cpp"
click node_home_view "https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/TouchGFX/gui/src/screenhome_screen/ScreenHomeView.cpp"
click node_info_view "https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/TouchGFX/gui/src/screeninfo_screen/ScreenInfoView.cpp"
click node_touch_controller "https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/TouchGFX/target/STM32TouchController.cpp"
click node_touch_driver "https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/Drivers/BSP/Components/stmpe811/stmpe811.c"

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_radar_app,node_hcsr04 toneBlue
class node_firmware,node_config,node_types,node_debug toneAmber
class node_bridge,node_scan_view,node_settings_view,node_home_view,node_info_view,node_touch_controller toneMint
class node_servo,node_alert,node_touch_driver toneRose
class node_operator,node_obstacle toneIndigo
```

## Components

### Radar sensing

- [Scan and detection](https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_app.c): `radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_app.c`
- [Echo measurement](https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/STM32CubeIDE/Application/User/hcsr04.c): `radar_short_range_touchgfx/STM32CubeIDE/Application/User/hcsr04.c`

### Firmware control

- [STM32 firmware](https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/Core/Src/main.c): `radar_short_range_touchgfx/Core/Src/main.c`
- [Radar settings](https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_config.h): `radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_config.h`
- [Radar data types](https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_types.h): `radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_types.h`
- [UART diagnostics](https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_debug.c): `radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_debug.c`

### TouchGFX interface

- [UI data and controls](https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_ui_bridge.c): `radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_ui_bridge.c`
- [Scan screen](https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/TouchGFX/gui/src/screenscan_screen/ScreenScanView.cpp): `radar_short_range_touchgfx/TouchGFX/gui/src/screenscan_screen/ScreenScanView.cpp`
- [Settings screen](https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/TouchGFX/gui/src/screensettings_screen/ScreenSettingsView.cpp): `radar_short_range_touchgfx/TouchGFX/gui/src/screensettings_screen/ScreenSettingsView.cpp`
- [Home screen](https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/TouchGFX/gui/src/screenhome_screen/ScreenHomeView.cpp): `radar_short_range_touchgfx/TouchGFX/gui/src/screenhome_screen/ScreenHomeView.cpp`
- [Info screen](https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/TouchGFX/gui/src/screeninfo_screen/ScreenInfoView.cpp): `radar_short_range_touchgfx/TouchGFX/gui/src/screeninfo_screen/ScreenInfoView.cpp`
- [Touch input](https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/TouchGFX/target/STM32TouchController.cpp): `radar_short_range_touchgfx/TouchGFX/target/STM32TouchController.cpp`

### Board I/O

- [Servo motion](https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/STM32CubeIDE/Application/User/servo_mg90s.c): `radar_short_range_touchgfx/STM32CubeIDE/Application/User/servo_mg90s.c`
- [LED and buzzer](https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/STM32CubeIDE/Application/User/buzzer_led.c): `radar_short_range_touchgfx/STM32CubeIDE/Application/User/buzzer_led.c`
- [STMPE811 driver](https://github.com/phamhungcrab/it4210-he-nhung/blob/main/radar_short_range_touchgfx/Drivers/BSP/Components/stmpe811/stmpe811.c): `radar_short_range_touchgfx/Drivers/BSP/Components/stmpe811/stmpe811.c`

### Other components

- **Operator**
- **Obstacle**

## Connections

- Operator → Settings screen: sets scan options (evidence: `README.md`)
- Operator → STM32 firmware: presses USER button (evidence: `README.md`)
- Obstacle → Echo measurement: returns echo (evidence: `README.md`)
- STM32 firmware → Scan and detection: starts radar task (evidence: `README.md`)
- Scan and detection → Radar settings: uses thresholds (evidence: `radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_app.c`)
- Scan and detection → Echo measurement: measures distance (evidence: `radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_app.c`)
- Scan and detection → Servo motion: sets scan angle (evidence: `radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_app.c`)
- Scan and detection → LED and buzzer: updates alerts (evidence: `radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_app.c`)
- Scan and detection → UI data and controls: publishes radar data (evidence: `radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_app.c`)
- Scan and detection → UART diagnostics: logs measurements (evidence: `radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_app.c`)
- Scan and detection → Radar data types: uses data model (evidence: `radar_short_range_touchgfx/STM32CubeIDE/Application/User/radar_app.c`)
- Scan screen → Scan and detection: starts scanning (evidence: `radar_short_range_touchgfx/TouchGFX/gui/src/screenscan_screen/ScreenScanView.cpp`)
- Scan screen → UI data and controls: reads radar data (evidence: `radar_short_range_touchgfx/TouchGFX/gui/src/screenscan_screen/ScreenScanView.cpp`)
- Scan screen → UART diagnostics: logs UI state (evidence: `radar_short_range_touchgfx/TouchGFX/gui/src/screenscan_screen/ScreenScanView.cpp`)
- Settings screen → UI data and controls: changes controls (evidence: `radar_short_range_touchgfx/TouchGFX/gui/src/screensettings_screen/ScreenSettingsView.cpp`)
- Info screen → UI data and controls: reads radar state (evidence: `radar_short_range_touchgfx/TouchGFX/gui/src/screeninfo_screen/ScreenInfoView.cpp`)
- Touch input → STMPE811 driver: reads touch state (evidence: `radar_short_range_touchgfx/TouchGFX/target/STM32TouchController.cpp`)
- STMPE811 driver → Operator: receives touch (evidence: `README.md`)
- UI data and controls → Scan screen: feeds display (evidence: `README.md`)
- Scan and detection → Scan screen: sends queue updates (evidence: `README.md`)
