# thediyguy999/sbus architecture

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

- Interactive diagram: https://gitdiagram.com/thediyguy999/sbus
- Repository: https://github.com/thediyguy999/sbus

## Overview

SBUS is an Arduino library for receiving and parsing RC receiver packets and sending servo commands over hardware serial. An application initializes the library, reads raw or calibrated channels and status flags, and can write raw or calibrated channel values; calibration endpoints and polynomials are configurable. The excerpts show the parser, conversions, and serial packet output. The examples and some implementation lines were not sampled, so the graph focuses on documented public behavior and visible calls.

Main entry points: [`src/SBUS.cpp`](https://github.com/thediyguy999/sbus/blob/master/src/SBUS.cpp) (SBUS API), [`src/elapsedMillis.h`](https://github.com/thediyguy999/sbus/blob/master/src/elapsedMillis.h) (Elapsed timer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["SBUS interface"]
  node_sbus["SBUS API<br/>[SBUS.cpp]"]
end

subgraph group_input["Receive and decode"]
  node_parser["Packet parser<br/>[SBUS.cpp]"]
  node_timer["Elapsed timer<br/>[elapsedMillis.h]"]
  node_raw["Raw channel decode<br/>[SBUS.cpp]"]
  node_readcal["Calibrated read<br/>[SBUS.cpp]"]
end

subgraph group_output["Calibration and transmit"]
  node_calibration["Endpoint and polynomial settings<br/>[SBUS.cpp]"]
  node_writecal["Calibrated write<br/>[SBUS.cpp]"]
  node_packet["Packet encoder<br/>[SBUS.cpp]"]
end

node_app(("Arduino application"))
node_receiver["SBUS receiver"]
node_serial["Hardware serial bus"]
node_servos["SBUS servos"]

node_app -->|"initializes and calls"| node_sbus
node_receiver -->|"sends packets"| node_serial
node_sbus -->|"configures and reads"| node_serial
node_sbus -->|"parses input"| node_parser
node_parser -->|"checks timeout"| node_timer
node_sbus -->|"decodes channels"| node_raw
node_sbus -->|"calibrates reads"| node_readcal
node_readcal -->|"calls read"| node_raw
node_app -->|"sets calibration"| node_calibration
node_app -->|"requests calibrated output"| node_writecal
node_writecal -->|"uses coefficients"| node_calibration
node_writecal -->|"converts then writes"| node_packet
node_app -->|"requests raw output"| node_packet
node_packet -->|"writes packet"| node_serial
node_serial -->|"transmits commands"| node_servos

click node_sbus "https://github.com/thediyguy999/sbus/blob/master/src/SBUS.cpp"
click node_parser "https://github.com/thediyguy999/sbus/blob/master/src/SBUS.cpp"
click node_timer "https://github.com/thediyguy999/sbus/blob/master/src/elapsedMillis.h"
click node_raw "https://github.com/thediyguy999/sbus/blob/master/src/SBUS.cpp"
click node_readcal "https://github.com/thediyguy999/sbus/blob/master/src/SBUS.cpp"
click node_calibration "https://github.com/thediyguy999/sbus/blob/master/src/SBUS.cpp"
click node_writecal "https://github.com/thediyguy999/sbus/blob/master/src/SBUS.cpp"
click node_packet "https://github.com/thediyguy999/sbus/blob/master/src/SBUS.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_sbus toneBlue
class node_parser,node_timer,node_raw,node_readcal toneAmber
class node_calibration,node_writecal,node_packet toneMint
class node_app,node_receiver,node_serial,node_servos toneIndigo
```

## Components

### SBUS interface

- [SBUS API](https://github.com/thediyguy999/sbus/blob/master/src/SBUS.cpp): `src/SBUS.cpp`

### Receive and decode

- [Packet parser](https://github.com/thediyguy999/sbus/blob/master/src/SBUS.cpp): `src/SBUS.cpp`
- [Elapsed timer](https://github.com/thediyguy999/sbus/blob/master/src/elapsedMillis.h): `src/elapsedMillis.h`
- [Raw channel decode](https://github.com/thediyguy999/sbus/blob/master/src/SBUS.cpp): `src/SBUS.cpp`
- [Calibrated read](https://github.com/thediyguy999/sbus/blob/master/src/SBUS.cpp): `src/SBUS.cpp`

### Calibration and transmit

- [Endpoint and polynomial settings](https://github.com/thediyguy999/sbus/blob/master/src/SBUS.cpp): `src/SBUS.cpp`
- [Calibrated write](https://github.com/thediyguy999/sbus/blob/master/src/SBUS.cpp): `src/SBUS.cpp`
- [Packet encoder](https://github.com/thediyguy999/sbus/blob/master/src/SBUS.cpp): `src/SBUS.cpp`

### Other components

- **Arduino application**
- **SBUS receiver**
- **Hardware serial bus**
- **SBUS servos**

## Connections

- Arduino application → SBUS API: initializes and calls (evidence: `README.md`)
- SBUS receiver → Hardware serial bus: sends packets (evidence: `README.md`)
- SBUS API → Hardware serial bus: configures and reads (evidence: `src/SBUS.cpp`)
- SBUS API → Packet parser: parses input (evidence: `src/SBUS.cpp`)
- Packet parser → Elapsed timer: checks timeout (evidence: `src/SBUS.cpp`)
- SBUS API → Raw channel decode: decodes channels (evidence: `src/SBUS.cpp`)
- SBUS API → Calibrated read: calibrates reads (evidence: `src/SBUS.cpp`)
- Calibrated read → Raw channel decode: calls read (evidence: `src/SBUS.cpp`)
- Arduino application → Endpoint and polynomial settings: sets calibration (evidence: `README.md`)
- Arduino application → Calibrated write: requests calibrated output (evidence: `README.md`)
- Calibrated write → Endpoint and polynomial settings: uses coefficients (evidence: `src/SBUS.cpp`)
- Calibrated write → Packet encoder: converts then writes (evidence: `src/SBUS.cpp`)
- Arduino application → Packet encoder: requests raw output (evidence: `README.md`)
- Packet encoder → Hardware serial bus: writes packet (evidence: `src/SBUS.cpp`)
- Hardware serial bus → SBUS servos: transmits commands (evidence: `README.md`)
