# mrmeizongo/xpilot architecture

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

- Interactive diagram: https://gitdiagram.com/mrmeizongo/xpilot
- Repository: https://github.com/mrmeizongo/xpilot

## Overview

Xpilot is an Arduino flight-stabilization system. Radio input and MPU6050 measurements feed selectable passthrough, rate, or stabilize control; outputs drive aircraft servos, with failsafe and arming behavior managed by the firmware. A serial interface and xp_serial.py support configuration and calibration. The workflow and capabilities are taken from the README; source excerpts also show EEPROM-backed configuration and the interfaces among key modules. Some implementation files were not sampled, so uncertain runtime links are omitted rather than inferred.

Main entry points: [`src/main.cpp`](https://github.com/mrmeizongo/xpilot/blob/main/src/main.cpp) (Flight controller), [`lib/Xpilot/src/Mode.cpp`](https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/Mode.cpp) (Flight modes), [`lib/Xpilot/src/XPDebug.cpp`](https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/XPDebug.cpp) (Debug reporting), [`lib/Xpilot/src/Radio.cpp`](https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/Radio.cpp) (Radio input)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Flight runtime"]
  node_firmware["Flight controller<br/>[main.cpp]"]
  node_mode["Flight modes<br/>[Mode.cpp]"]
  node_passthrough["Passthrough mode"]
  node_rate["Rate mode<br/>[RateMode.cpp]"]
  node_stabilize["Stabilize mode<br/>[StabilizeMode.cpp]"]
  node_mixer["Airplane mixer<br/>[AirplaneMixer.cpp]"]
  node_actuators["Servo outputs<br/>[Actuators.cpp]"]
  node_servo["Servo driver<br/>[Servo.cpp]"]
  node_scheduler["Task scheduler<br/>[Scheduler.cpp]"]
  node_led["LED notifier<br/>[LEDnotifier.cpp]"]
  node_debug["Debug reporting<br/>[XPDebug.cpp]"]
end

subgraph group_sensing["Inputs and sensing"]
  node_radio["Radio input<br/>[Radio.cpp]"]
  node_interrupts["Pin interrupts"]
  node_imu["IMU processing<br/>[IMU.cpp]"]
  node_mpu["MPU6050 driver<br/>[MPU6050.h]"]
end

subgraph group_config["Configuration"]
  node_configmgr["Configuration manager<br/>[ConfigManager.cpp]"]
  node_eeprom[("EEPROM")]
  node_configaccess["Config access"]
end

subgraph group_interface["Serial interface"]
  node_serial["Serial interface<br/>[XPInterface.cpp]"]
  node_serialtool["xp_serial tool<br/>[xp_serial.py]"]
end

node_pilot(("Pilot / transmitter"))
node_aircraft(("Aircraft servos"))
node_operator(("Configuration operator"))

node_pilot -->|"sends input"| node_radio
node_radio -.->|"provides channels"| node_firmware
node_firmware -.->|"selects mode"| node_mode
node_mode -->|"supports mode"| node_passthrough
node_mode -->|"supports mode"| node_rate
node_mode -->|"supports mode"| node_stabilize
node_imu -.->|"reads sensor"| node_mpu
node_firmware -->|"updates at 250Hz"| node_imu
node_mode -.->|"mixes surfaces"| node_mixer
node_firmware -->|"drives outputs"| node_actuators
node_actuators -.->|"uses driver"| node_servo
node_servo -->|"drives servos"| node_aircraft
node_radio -.->|"captures pulses"| node_interrupts
node_firmware -.->|"runs periodic tasks"| node_scheduler
node_firmware -.->|"uses configuration"| node_configmgr
node_configmgr -->|"reads and writes"| node_eeprom
node_configaccess -->|"exposes config"| node_configmgr
node_operator -->|"configures aircraft"| node_serialtool
node_serialtool -->|"communicates with"| node_serial
node_serial -.->|"sets configuration"| node_configmgr
node_serialtool -->|"supports calibration"| node_imu
node_firmware -.->|"signals status"| node_led
node_debug -->|"reports task stats"| node_scheduler
node_debug -->|"reports channel values"| node_radio
node_debug -->|"reports mode values"| node_mode
node_debug -->|"reports output values"| node_actuators

click node_firmware "https://github.com/mrmeizongo/xpilot/blob/main/src/main.cpp"
click node_mode "https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/Mode.cpp"
click node_passthrough "https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/PassthroughMode.cpp"
click node_rate "https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/RateMode.cpp"
click node_stabilize "https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/StabilizeMode.cpp"
click node_mixer "https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/AirplaneMixer.cpp"
click node_actuators "https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/Actuators.cpp"
click node_servo "https://github.com/mrmeizongo/xpilot/blob/main/lib/Servo/src/avr/Servo.cpp"
click node_scheduler "https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/Scheduler.cpp"
click node_radio "https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/Radio.cpp"
click node_interrupts "https://github.com/mrmeizongo/xpilot/blob/main/lib/PinChangeInterrupt/src/PinChangeInterrupt.cpp"
click node_imu "https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/IMU.cpp"
click node_mpu "https://github.com/mrmeizongo/xpilot/blob/main/lib/MPU6050/src/MPU6050.h"
click node_configmgr "https://github.com/mrmeizongo/xpilot/blob/main/lib/Config/src/ConfigManager.cpp"
click node_configaccess "https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/FlightConfigAccess.cpp"
click node_serial "https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/XPInterface.cpp"
click node_serialtool "https://github.com/mrmeizongo/xpilot/blob/main/xp_serial.py"
click node_led "https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/LEDnotifier.cpp"
click node_debug "https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/XPDebug.cpp"

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_mode,node_passthrough,node_rate,node_stabilize,node_mixer,node_actuators,node_servo,node_scheduler,node_led,node_debug toneBlue
class node_radio,node_interrupts,node_imu,node_mpu toneAmber
class node_configmgr,node_eeprom,node_configaccess toneMint
class node_serial,node_serialtool toneRose
class node_pilot,node_aircraft,node_operator toneIndigo
```

## Components

### Flight runtime

- [Flight controller](https://github.com/mrmeizongo/xpilot/blob/main/src/main.cpp): `src/main.cpp`
- [Flight modes](https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/Mode.cpp): `lib/Xpilot/src/Mode.cpp`
- [Passthrough mode](https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/PassthroughMode.cpp): `lib/Xpilot/src/PassthroughMode.cpp`
- [Rate mode](https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/RateMode.cpp): `lib/Xpilot/src/RateMode.cpp`
- [Stabilize mode](https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/StabilizeMode.cpp): `lib/Xpilot/src/StabilizeMode.cpp`
- [Airplane mixer](https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/AirplaneMixer.cpp): `lib/Xpilot/src/AirplaneMixer.cpp`
- [Servo outputs](https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/Actuators.cpp): `lib/Xpilot/src/Actuators.cpp`
- [Servo driver](https://github.com/mrmeizongo/xpilot/blob/main/lib/Servo/src/avr/Servo.cpp): `lib/Servo/src/avr/Servo.cpp`
- [Task scheduler](https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/Scheduler.cpp): `lib/Xpilot/src/Scheduler.cpp`
- [LED notifier](https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/LEDnotifier.cpp): `lib/Xpilot/src/LEDnotifier.cpp`
- [Debug reporting](https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/XPDebug.cpp): `lib/Xpilot/src/XPDebug.cpp`

### Inputs and sensing

- [Radio input](https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/Radio.cpp): `lib/Xpilot/src/Radio.cpp`
- [Pin interrupts](https://github.com/mrmeizongo/xpilot/blob/main/lib/PinChangeInterrupt/src/PinChangeInterrupt.cpp): `lib/PinChangeInterrupt/src/PinChangeInterrupt.cpp`
- [IMU processing](https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/IMU.cpp): `lib/Xpilot/src/IMU.cpp`
- [MPU6050 driver](https://github.com/mrmeizongo/xpilot/blob/main/lib/MPU6050/src/MPU6050.h): `lib/MPU6050/src/MPU6050.h`

### Configuration

- [Configuration manager](https://github.com/mrmeizongo/xpilot/blob/main/lib/Config/src/ConfigManager.cpp): `lib/Config/src/ConfigManager.cpp`
- **EEPROM**
- [Config access](https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/FlightConfigAccess.cpp): `lib/Xpilot/src/FlightConfigAccess.cpp`

### Serial interface

- [Serial interface](https://github.com/mrmeizongo/xpilot/blob/main/lib/Xpilot/src/XPInterface.cpp): `lib/Xpilot/src/XPInterface.cpp`
- [xp_serial tool](https://github.com/mrmeizongo/xpilot/blob/main/xp_serial.py): `xp_serial.py`

### Other components

- **Pilot / transmitter**
- **Aircraft servos**
- **Configuration operator**

## Connections

- Pilot / transmitter → Radio input: sends input
- Radio input → Flight controller: provides channels
- Flight controller → Flight modes: selects mode
- Flight modes → Passthrough mode: supports mode
- Flight modes → Rate mode: supports mode
- Flight modes → Stabilize mode: supports mode
- IMU processing → MPU6050 driver: reads sensor
- Flight controller → IMU processing: updates at 250Hz
- Flight modes → Airplane mixer: mixes surfaces
- Flight controller → Servo outputs: drives outputs
- Servo outputs → Servo driver: uses driver
- Servo driver → Aircraft servos: drives servos
- Radio input → Pin interrupts: captures pulses
- Flight controller → Task scheduler: runs periodic tasks
- Flight controller → Configuration manager: uses configuration
- Configuration manager → EEPROM: reads and writes (evidence: `lib/Config/src/ConfigManager.cpp`)
- Config access → Configuration manager: exposes config
- Configuration operator → xp_serial tool: configures aircraft
- xp_serial tool → Serial interface: communicates with
- Serial interface → Configuration manager: sets configuration
- xp_serial tool → IMU processing: supports calibration
- Flight controller → LED notifier: signals status
- Debug reporting → Task scheduler: reports task stats (evidence: `lib/Xpilot/src/XPDebug.cpp`)
- Debug reporting → Radio input: reports channel values (evidence: `lib/Xpilot/src/XPDebug.cpp`)
- Debug reporting → Flight modes: reports mode values (evidence: `lib/Xpilot/src/XPDebug.cpp`)
- Debug reporting → Servo outputs: reports output values (evidence: `lib/Xpilot/src/XPDebug.cpp`)
