# rtlopez/esp-fc architecture

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

- Interactive diagram: https://gitdiagram.com/rtlopez/esp-fc
- Repository: https://github.com/rtlopez/esp-fc

## Overview

ESP-FC is embedded flight-controller firmware for ESP-family and experimental RP2040 boards. Its principal runtime purpose is to turn receiver and sensor inputs into controlled motor outputs; the README also highlights configuration, telemetry, logging, and wireless capabilities. The sampled serial manager shows dispatch to MSP, GPS, telemetry, VTX, and optional wireless components, while the controller excerpt shows PID processing. Several domain links are documented only as capabilities, so unverified workflow edges are dashed. Unsampled subsystem internals are represented by their exact source directories.

Main entry points: [`lib/Espfc/src/SerialManager.cpp`](https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/SerialManager.cpp) (Serial dispatch), [`lib/CmsisDsp/Include/dsp/controller_functions.h`](https://github.com/rtlopez/esp-fc/blob/master/lib/CmsisDsp/Include/dsp/controller_functions.h) (DSP primitives), [`lib/Espfc/src/Control/Controller.cpp`](https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Control/Controller.cpp) (Flight controller), [`lib/Espfc/src/Sensor`](https://github.com/rtlopez/esp-fc/tree/master/lib/Espfc/src/Sensor) (Sensor processing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Firmware Runtime"]
  node_firmware["Firmware entry<br/>[main.cpp]"]
  node_model["Runtime model<br/>[Model.h]"]
  node_model_config["Configuration model<br/>[ModelConfig.h]"]
  node_config_storage[("Config persistence<br/>[Storage.cpp]")]
  node_hal_storage["Platform storage<br/>[ConfigStorage.hpp]"]
end

subgraph group_flight["Flight Control"]
  node_control["Flight controller<br/>[Controller.cpp]"]
  node_fusion["Attitude fusion<br/>[Fusion.cpp]"]
  node_pid["PID and rates<br/>[Pid.cpp]"]
  node_mixer["Motor mixing<br/>[Mixer.cpp]"]
  node_esc["ESC drivers<br/>[EscDriverBase.cpp]"]
end

subgraph group_io["Devices and I/O"]
  node_sensor_devices["Sensor drivers"]
  node_sensors["Sensor processing"]
  node_sensor_manager["Sensor manager<br/>[SensorManager.cpp]"]
  node_receivers["Receiver inputs"]
  node_input["Input handling<br/>[Input.cpp]"]
end

subgraph group_connect["Configuration and Telemetry"]
  node_serial_manager["Serial dispatch<br/>[SerialManager.cpp]"]
  node_msp["MSP and CLI<br/>[MspProcessor.cpp]"]
  node_cli["CLI commands<br/>[Cli.hpp]"]
  node_wireless["Wi-Fi / ESP-NOW<br/>[Wireless.cpp]"]
  node_gps["GPS parsing<br/>[GpsProtocol.hpp]"]
  node_telemetry["Telemetry"]
  node_serial_link["Serial stream<br/>[ReadWritable.hpp]"]
  node_printer["Formatted output<br/>[Printer.hpp]"]
end

subgraph group_support["Libraries and Logging"]
  node_blackbox["Blackbox logging<br/>[Blackbox.cpp]"]
  node_blackbox_format["Log format<br/>[blackbox.c]"]
  node_dsp["DSP primitives"]
  node_dsp_types["DSP types<br/>[arm_math_types.h]"]
  node_dsp_memory["DSP memory API<br/>[arm_math_memory.h]"]
  node_dsp_none["DSP fallbacks<br/>[none.h]"]
  node_dsp_tables["DSP tables<br/>[arm_mve_tables.c]"]
  node_printf["Printf formatter<br/>[printf.h]"]
  node_bf_platform["Betaflight compatibility<br/>[platform.h]"]
  node_esc_bootloader["ESC bootloader protocol"]
end

node_operator(("Pilot / operator"))

node_operator -.->|"operates"| node_firmware
node_firmware -.->|"runs with"| node_model
node_receivers -.->|"supply controls"| node_input
node_sensor_devices -.->|"provide readings"| node_sensors
node_sensor_manager -->|"manages"| node_sensors
node_input -.->|"sets commands"| node_control
node_sensors -.->|"inform attitude"| node_fusion
node_fusion -.->|"provides attitude"| node_control
node_control -.->|"uses control loops"| node_pid
node_control -.->|"produces motor commands"| node_mixer
node_mixer -.->|"drives outputs"| node_esc
node_serial_manager -->|"dispatches commands"| node_msp
node_serial_manager -->|"updates GPS"| node_gps
node_serial_manager -->|"processes telemetry"| node_telemetry
node_serial_manager -->|"updates wireless"| node_wireless
node_serial_manager -->|"reads and writes"| node_serial_link
node_serial_manager -->|"initializes debug output"| node_printer
node_operator -.->|"configures firmware"| node_msp
node_operator -.->|"configures wirelessly"| node_wireless
node_model_config -->|"persists settings"| node_config_storage
node_config_storage -->|"reads and writes"| node_hal_storage
node_blackbox -.->|"writes compatible logs"| node_blackbox_format
node_pid -.->|"may use DSP routines"| node_dsp
node_dsp -->|"uses types"| node_dsp_types
node_dsp -->|"uses memory API"| node_dsp_memory
node_dsp -->|"includes fallbacks"| node_dsp_none
node_printf -.->|"formats output"| node_printer
node_blackbox_format -->|"uses platform definitions"| node_bf_platform
node_esc_bootloader -->|"uses platform definitions"| node_bf_platform

click node_firmware "https://github.com/rtlopez/esp-fc/blob/master/src/main.cpp"
click node_model "https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Model.h"
click node_model_config "https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/ModelConfig.h"
click node_sensor_devices "https://github.com/rtlopez/esp-fc/tree/master/lib/Espfc/src/Device"
click node_sensors "https://github.com/rtlopez/esp-fc/tree/master/lib/Espfc/src/Sensor"
click node_sensor_manager "https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/SensorManager.cpp"
click node_receivers "https://github.com/rtlopez/esp-fc/tree/master/lib/Espfc/src/Device/Input"
click node_input "https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Input.cpp"
click node_control "https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Control/Controller.cpp"
click node_fusion "https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Control/Fusion.cpp"
click node_pid "https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Control/Pid.cpp"
click node_mixer "https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Output/Mixer.cpp"
click node_esc "https://github.com/rtlopez/esp-fc/blob/master/lib/EscDriver/src/EscDriverBase.cpp"
click node_serial_manager "https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/SerialManager.cpp"
click node_msp "https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Connect/MspProcessor.cpp"
click node_cli "https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Connect/Cli.hpp"
click node_wireless "https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Wireless.cpp"
click node_gps "https://github.com/rtlopez/esp-fc/blob/master/lib/Gps/src/GpsProtocol.hpp"
click node_telemetry "https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/TelemetryManager.cpp"
click node_config_storage "https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Utils/Storage.cpp"
click node_hal_storage "https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Hal/ConfigStorage.hpp"
click node_blackbox "https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Blackbox/Blackbox.cpp"
click node_blackbox_format "https://github.com/rtlopez/esp-fc/blob/master/lib/betaflight/src/blackbox/blackbox.c"
click node_serial_link "https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Stream/ReadWritable.hpp"
click node_printer "https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Stream/Printer.hpp"
click node_dsp "https://github.com/rtlopez/esp-fc/blob/master/lib/CmsisDsp/Include/dsp/controller_functions.h"
click node_dsp_types "https://github.com/rtlopez/esp-fc/blob/master/lib/CmsisDsp/Include/arm_math_types.h"
click node_dsp_memory "https://github.com/rtlopez/esp-fc/blob/master/lib/CmsisDsp/Include/arm_math_memory.h"
click node_dsp_none "https://github.com/rtlopez/esp-fc/blob/master/lib/CmsisDsp/Include/dsp/none.h"
click node_dsp_tables "https://github.com/rtlopez/esp-fc/blob/master/lib/CmsisDsp/Source/CommonTables/arm_mve_tables.c"
click node_printf "https://github.com/rtlopez/esp-fc/blob/master/lib/printf/src/printf.h"
click node_bf_platform "https://github.com/rtlopez/esp-fc/blob/master/lib/betaflight/src/platform.h"
click node_esc_bootloader "https://github.com/rtlopez/esp-fc/blob/master/lib/betaflight/src/io/serial_4way_avrootloader.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_firmware,node_model,node_model_config,node_config_storage,node_hal_storage toneBlue
class node_control,node_fusion,node_pid,node_mixer,node_esc toneAmber
class node_sensor_devices,node_sensors,node_sensor_manager,node_receivers,node_input toneMint
class node_serial_manager,node_msp,node_cli,node_wireless,node_gps,node_telemetry,node_serial_link,node_printer toneRose
class node_blackbox,node_blackbox_format,node_dsp,node_dsp_types,node_dsp_memory,node_dsp_none,node_dsp_tables,node_printf,node_bf_platform,node_esc_bootloader,node_operator toneIndigo
```

## Components

### Firmware Runtime

- [Firmware entry](https://github.com/rtlopez/esp-fc/blob/master/src/main.cpp): `src/main.cpp`
- [Runtime model](https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Model.h): `lib/Espfc/src/Model.h`
- [Configuration model](https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/ModelConfig.h): `lib/Espfc/src/ModelConfig.h`
- [Config persistence](https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Utils/Storage.cpp): `lib/Espfc/src/Utils/Storage.cpp`
- [Platform storage](https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Hal/ConfigStorage.hpp): `lib/Espfc/src/Hal/ConfigStorage.hpp`

### Flight Control

- [Flight controller](https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Control/Controller.cpp): `lib/Espfc/src/Control/Controller.cpp`
- [Attitude fusion](https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Control/Fusion.cpp): `lib/Espfc/src/Control/Fusion.cpp`
- [PID and rates](https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Control/Pid.cpp): `lib/Espfc/src/Control/Pid.cpp`
- [Motor mixing](https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Output/Mixer.cpp): `lib/Espfc/src/Output/Mixer.cpp`
- [ESC drivers](https://github.com/rtlopez/esp-fc/blob/master/lib/EscDriver/src/EscDriverBase.cpp): `lib/EscDriver/src/EscDriverBase.cpp`

### Devices and I/O

- [Sensor drivers](https://github.com/rtlopez/esp-fc/tree/master/lib/Espfc/src/Device): `lib/Espfc/src/Device`
- [Sensor processing](https://github.com/rtlopez/esp-fc/tree/master/lib/Espfc/src/Sensor): `lib/Espfc/src/Sensor`
- [Sensor manager](https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/SensorManager.cpp): `lib/Espfc/src/SensorManager.cpp`
- [Receiver inputs](https://github.com/rtlopez/esp-fc/tree/master/lib/Espfc/src/Device/Input): `lib/Espfc/src/Device/Input`
- [Input handling](https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Input.cpp): `lib/Espfc/src/Input.cpp`

### Configuration and Telemetry

- [Serial dispatch](https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/SerialManager.cpp): `lib/Espfc/src/SerialManager.cpp`
- [MSP and CLI](https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Connect/MspProcessor.cpp): `lib/Espfc/src/Connect/MspProcessor.cpp`
- [CLI commands](https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Connect/Cli.hpp): `lib/Espfc/src/Connect/Cli.hpp`
- [Wi-Fi / ESP-NOW](https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Wireless.cpp): `lib/Espfc/src/Wireless.cpp`
- [GPS parsing](https://github.com/rtlopez/esp-fc/blob/master/lib/Gps/src/GpsProtocol.hpp): `lib/Gps/src/GpsProtocol.hpp`
- [Telemetry](https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/TelemetryManager.cpp): `lib/Espfc/src/TelemetryManager.cpp`
- [Serial stream](https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Stream/ReadWritable.hpp): `lib/Espfc/src/Stream/ReadWritable.hpp`
- [Formatted output](https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Stream/Printer.hpp): `lib/Espfc/src/Stream/Printer.hpp`

### Libraries and Logging

- [Blackbox logging](https://github.com/rtlopez/esp-fc/blob/master/lib/Espfc/src/Blackbox/Blackbox.cpp): `lib/Espfc/src/Blackbox/Blackbox.cpp`
- [Log format](https://github.com/rtlopez/esp-fc/blob/master/lib/betaflight/src/blackbox/blackbox.c): `lib/betaflight/src/blackbox/blackbox.c`
- [DSP primitives](https://github.com/rtlopez/esp-fc/blob/master/lib/CmsisDsp/Include/dsp/controller_functions.h): `lib/CmsisDsp/Include/dsp/controller_functions.h`
- [DSP types](https://github.com/rtlopez/esp-fc/blob/master/lib/CmsisDsp/Include/arm_math_types.h): `lib/CmsisDsp/Include/arm_math_types.h`
- [DSP memory API](https://github.com/rtlopez/esp-fc/blob/master/lib/CmsisDsp/Include/arm_math_memory.h): `lib/CmsisDsp/Include/arm_math_memory.h`
- [DSP fallbacks](https://github.com/rtlopez/esp-fc/blob/master/lib/CmsisDsp/Include/dsp/none.h): `lib/CmsisDsp/Include/dsp/none.h`
- [DSP tables](https://github.com/rtlopez/esp-fc/blob/master/lib/CmsisDsp/Source/CommonTables/arm_mve_tables.c): `lib/CmsisDsp/Source/CommonTables/arm_mve_tables.c`
- [Printf formatter](https://github.com/rtlopez/esp-fc/blob/master/lib/printf/src/printf.h): `lib/printf/src/printf.h`
- [Betaflight compatibility](https://github.com/rtlopez/esp-fc/blob/master/lib/betaflight/src/platform.h): `lib/betaflight/src/platform.h`
- [ESC bootloader protocol](https://github.com/rtlopez/esp-fc/blob/master/lib/betaflight/src/io/serial_4way_avrootloader.c): `lib/betaflight/src/io/serial_4way_avrootloader.c`

### Other components

- **Pilot / operator**

## Connections

- Pilot / operator → Firmware entry: operates (evidence: `README.md`)
- Firmware entry → Runtime model: runs with
- Receiver inputs → Input handling: supply controls (evidence: `README.md`)
- Sensor drivers → Sensor processing: provide readings (evidence: `README.md`)
- Sensor manager → Sensor processing: manages (evidence: `lib/Espfc/src/SensorManager.cpp`)
- Input handling → Flight controller: sets commands (evidence: `README.md`)
- Sensor processing → Attitude fusion: inform attitude (evidence: `README.md`)
- Attitude fusion → Flight controller: provides attitude
- Flight controller → PID and rates: uses control loops (evidence: `lib/Espfc/src/Control/Controller.cpp`)
- Flight controller → Motor mixing: produces motor commands (evidence: `README.md`)
- Motor mixing → ESC drivers: drives outputs (evidence: `README.md`)
- Serial dispatch → MSP and CLI: dispatches commands (evidence: `lib/Espfc/src/SerialManager.cpp`)
- Serial dispatch → GPS parsing: updates GPS (evidence: `lib/Espfc/src/SerialManager.cpp`)
- Serial dispatch → Telemetry: processes telemetry (evidence: `lib/Espfc/src/SerialManager.cpp`)
- Serial dispatch → Wi-Fi / ESP-NOW: updates wireless (evidence: `lib/Espfc/src/SerialManager.cpp`)
- Serial dispatch → Serial stream: reads and writes (evidence: `lib/Espfc/src/SerialManager.cpp`)
- Serial dispatch → Formatted output: initializes debug output (evidence: `lib/Espfc/src/SerialManager.cpp`)
- Pilot / operator → MSP and CLI: configures firmware (evidence: `README.md`)
- Pilot / operator → Wi-Fi / ESP-NOW: configures wirelessly (evidence: `README.md`)
- Configuration model → Config persistence: persists settings (evidence: `lib/Espfc/src/Utils/Storage.cpp`)
- Config persistence → Platform storage: reads and writes (evidence: `lib/Espfc/src/Utils/Storage.cpp`)
- Blackbox logging → Log format: writes compatible logs (evidence: `README.md`)
- PID and rates → DSP primitives: may use DSP routines
- DSP primitives → DSP types: uses types (evidence: `lib/CmsisDsp/Include/dsp/controller_functions.h`)
- DSP primitives → DSP memory API: uses memory API (evidence: `lib/CmsisDsp/Include/dsp/controller_functions.h`)
- DSP primitives → DSP fallbacks: includes fallbacks (evidence: `lib/CmsisDsp/Include/dsp/controller_functions.h`)
- Printf formatter → Formatted output: formats output
- Log format → Betaflight compatibility: uses platform definitions (evidence: `lib/betaflight/src/blackbox/blackbox.c`)
- ESC bootloader protocol → Betaflight compatibility: uses platform definitions (evidence: `lib/betaflight/src/io/serial_4way_avrootloader.c`)
