# dantiel/orniflight architecture

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

- Interactive diagram: https://gitdiagram.com/dantiel/orniflight
- Repository: https://github.com/dantiel/orniflight

## Overview

OrniFlight is documented as Betaflight-based ornithopter flight-control firmware. Its principal workflow is stabilization inputs and PID terms shaping a phase-locked wing trajectory, which drives oscillating wing servos to produce flapping flight. The README describes ONDAS’s eight modulation layers and damping anchor; their implementation paths are not present in the supplied tree, so those nodes have no asserted source path. The tree does show CMSIS DSP, CMSIS core headers, MAVLink message definitions, and USB mass-storage backends. Their product-level wiring is not established by the sampled excerpts, so uncertain connections are omitted.

Main entry points: [`src/main/msc`](https://github.com/dantiel/orniflight/tree/main/src/main/msc) (USB storage), [`src/main/msc/usbd_storage_sd_spi.c`](https://github.com/dantiel/orniflight/blob/main/src/main/msc/usbd_storage_sd_spi.c) (SD SPI backend), [`src/main/msc/usbd_storage_sdio.c`](https://github.com/dantiel/orniflight/blob/main/src/main/msc/usbd_storage_sdio.c) (SDIO backend)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["ONDAS Control"]
  node_stabilization["Stabilization inputs"]
  node_pid["PID terms"]
  node_cadence["Cadence"]
  node_ferocity["Ferocity"]
  node_balance["Balance"]
  node_warp["Warp"]
  node_resonance["Resonance"]
  node_prescience["Prescience"]
  node_espelho["Espelho"]
  node_saudade["Saudade"]
  node_anchor["Damping anchor"]
end

subgraph group_propulsion["Wing Actuation"]
  node_wing_model["Wing oscillator"]
  node_servos["Flapping servos"]
end

subgraph group_platform["Firmware Platform"]
  node_cmsis_core["CMSIS core"]
  node_cmsis_dsp["CMSIS DSP"]
end

subgraph group_interfaces["Device Interfaces"]
  node_mavlink["MAVLink messages"]
  node_usb_msc["USB storage"]
  node_sd_spi["SD SPI backend"]
  node_sdio["SDIO backend"]
end

node_pilot(("Pilot / config"))
node_flight(("Flapping flight"))
node_sd_card[("SD card")]

node_pilot -->|"sets inputs"| node_stabilization
node_stabilization -->|"feeds errors"| node_pid
node_pid -->|"modulates"| node_cadence
node_pid -->|"modulates"| node_ferocity
node_pid -->|"modulates"| node_balance
node_pid -->|"modulates"| node_warp
node_stabilization -->|"phase-locks"| node_resonance
node_stabilization -->|"predicts errors"| node_prescience
node_stabilization -->|"cancels self-noise"| node_espelho
node_pid -->|"learns bias"| node_saudade
node_anchor -->|"varies damping"| node_wing_model
node_cadence -->|"shifts timing"| node_wing_model
node_ferocity -->|"sets sharpness"| node_wing_model
node_balance -->|"biases thrust"| node_wing_model
node_warp -->|"asymmetrizes"| node_wing_model
node_resonance -->|"amplifies error"| node_wing_model
node_prescience -->|"feeds forward"| node_wing_model
node_espelho -->|"subtracts noise"| node_wing_model
node_saudade -->|"accumulates trim"| node_wing_model
node_wing_model -->|"drives trajectory"| node_servos
node_servos -->|"produces flapping"| node_flight
node_usb_msc -->|"dispatches storage"| node_sd_spi
node_usb_msc -->|"dispatches storage"| node_sdio
node_sd_spi -->|"reads / writes"| node_sd_card
node_sdio -->|"reads / writes"| node_sd_card

click node_cmsis_core "https://github.com/dantiel/orniflight/tree/main/lib/main/CMSIS/Core/Include"
click node_cmsis_dsp "https://github.com/dantiel/orniflight/tree/main/lib/main/CMSIS/DSP/Source"
click node_mavlink "https://github.com/dantiel/orniflight/tree/main/lib/main/MAVLink/common"
click node_usb_msc "https://github.com/dantiel/orniflight/tree/main/src/main/msc"
click node_sd_spi "https://github.com/dantiel/orniflight/blob/main/src/main/msc/usbd_storage_sd_spi.c"
click node_sdio "https://github.com/dantiel/orniflight/blob/main/src/main/msc/usbd_storage_sdio.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_stabilization,node_pid,node_cadence,node_ferocity,node_balance,node_warp,node_resonance,node_prescience,node_espelho,node_saudade,node_anchor toneBlue
class node_wing_model,node_servos,node_sd_card toneAmber
class node_cmsis_core,node_cmsis_dsp toneMint
class node_mavlink,node_usb_msc,node_sd_spi,node_sdio toneRose
class node_pilot,node_flight toneIndigo
```

## Components

### ONDAS Control

- **Stabilization inputs**
- **PID terms**
- **Cadence**
- **Ferocity**
- **Balance**
- **Warp**
- **Resonance**
- **Prescience**
- **Espelho**
- **Saudade**
- **Damping anchor**

### Wing Actuation

- **Wing oscillator**
- **Flapping servos**

### Firmware Platform

- [CMSIS core](https://github.com/dantiel/orniflight/tree/main/lib/main/CMSIS/Core/Include): `lib/main/CMSIS/Core/Include`
- [CMSIS DSP](https://github.com/dantiel/orniflight/tree/main/lib/main/CMSIS/DSP/Source): `lib/main/CMSIS/DSP/Source`

### Device Interfaces

- [MAVLink messages](https://github.com/dantiel/orniflight/tree/main/lib/main/MAVLink/common): `lib/main/MAVLink/common`
- [USB storage](https://github.com/dantiel/orniflight/tree/main/src/main/msc): `src/main/msc`
- [SD SPI backend](https://github.com/dantiel/orniflight/blob/main/src/main/msc/usbd_storage_sd_spi.c): `src/main/msc/usbd_storage_sd_spi.c`
- [SDIO backend](https://github.com/dantiel/orniflight/blob/main/src/main/msc/usbd_storage_sdio.c): `src/main/msc/usbd_storage_sdio.c`

### Other components

- **Pilot / config**
- **Flapping flight**
- **SD card**

## Connections

- Pilot / config → Stabilization inputs: sets inputs
- Stabilization inputs → PID terms: feeds errors
- PID terms → Cadence: modulates
- PID terms → Ferocity: modulates
- PID terms → Balance: modulates
- PID terms → Warp: modulates
- Stabilization inputs → Resonance: phase-locks
- Stabilization inputs → Prescience: predicts errors
- Stabilization inputs → Espelho: cancels self-noise
- PID terms → Saudade: learns bias
- Damping anchor → Wing oscillator: varies damping
- Cadence → Wing oscillator: shifts timing
- Ferocity → Wing oscillator: sets sharpness
- Balance → Wing oscillator: biases thrust
- Warp → Wing oscillator: asymmetrizes
- Resonance → Wing oscillator: amplifies error
- Prescience → Wing oscillator: feeds forward
- Espelho → Wing oscillator: subtracts noise
- Saudade → Wing oscillator: accumulates trim
- Wing oscillator → Flapping servos: drives trajectory
- Flapping servos → Flapping flight: produces flapping
- USB storage → SD SPI backend: dispatches storage
- USB storage → SDIO backend: dispatches storage
- SD SPI backend → SD card: reads / writes
- SDIO backend → SD card: reads / writes
