# keterez/fbl_library architecture

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

- Interactive diagram: https://gitdiagram.com/keterez/fbl_library
- Repository: https://github.com/keterez/fbl_library

## Overview

HydraX1 is an embedded sensor-and-actuator library: callers initialize the board, wait for and calibrate an AS5600L magnetic angle sensor, read its angle, and write actuator output. The sensor accesses registers through a shared I2C abstraction; board services provide logging, delays, and pin output. Arduino I2C is implemented in the sampled code. The README describes an STM32 I2C backend, but the supplied tree has no STM32 I2C implementation, so that branch is documented but unverified here.

Main entry points: [`src/as5600l.cpp`](https://github.com/keterez/fbl_library/blob/main/src/as5600l.cpp) (AS5600L Driver), [`HydraX1.cpp`](https://github.com/keterez/fbl_library/blob/main/HydraX1.cpp) (HydraX1 API), [`src/platforms/I2C.h`](https://github.com/keterez/fbl_library/blob/main/src/platforms/I2C.h) (I2C Contract), [`src/platforms/Platform.h`](https://github.com/keterez/fbl_library/blob/main/src/platforms/Platform.h) (Platform Selector)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_control["HydraX1 Control"]
  node_hydra["HydraX1 API<br/>[HydraX1.cpp]"]
  node_hydra_header["HydraX1 Interface<br/>[HydraX1.h]"]
end

subgraph group_sensor["Angle Sensing"]
  node_constants["Angle Constants<br/>[constatns.h]"]
  node_as5600["AS5600L Driver<br/>[as5600l.cpp]"]
end

subgraph group_bus["I2C Transport"]
  node_i2c_contract["I2C Contract<br/>[I2C.h]"]
  node_i2c_factory["I2C Bus Factory<br/>[I2C.cpp]"]
  node_arduino_i2c["Arduino I2C<br/>[arduinoI2C.cpp]"]
  node_stm32_i2c["STM32 I2C Backend"]
end

subgraph group_platform["Platform Services"]
  node_platform_select["Platform Selector<br/>[Platform.h]"]
  node_arduino_platform["Arduino Services<br/>[ArduinoPlatform.h]"]
  node_stm32_platform["STM32 Services<br/>[STM32Platform.h]"]
end

node_caller(("Library Caller"))
node_wire["Arduino Wire"]

node_caller -.->|"calls"| node_hydra
node_hydra -->|"initializes, calibrates, reads"| node_as5600
node_hydra -->|"uses services"| node_platform_select
node_hydra_header -->|"declares sensor"| node_as5600
node_as5600 -->|"reads and writes registers"| node_i2c_contract
node_as5600 -->|"uses angle constant"| node_constants
node_i2c_contract -->|"aliases implementation"| node_arduino_i2c
node_i2c_factory -->|"constructs bus"| node_arduino_i2c
node_arduino_i2c -->|"transfers bytes"| node_wire
node_i2c_contract -.->|"backend described"| node_stm32_i2c
node_platform_select -->|"selects on Arduino"| node_arduino_platform
node_platform_select -->|"selects on STM32"| node_stm32_platform

click node_hydra "https://github.com/keterez/fbl_library/blob/main/HydraX1.cpp"
click node_hydra_header "https://github.com/keterez/fbl_library/blob/main/HydraX1.h"
click node_constants "https://github.com/keterez/fbl_library/blob/main/constatns.h"
click node_as5600 "https://github.com/keterez/fbl_library/blob/main/src/as5600l.cpp"
click node_i2c_contract "https://github.com/keterez/fbl_library/blob/main/src/platforms/I2C.h"
click node_i2c_factory "https://github.com/keterez/fbl_library/blob/main/src/platforms/I2C.cpp"
click node_arduino_i2c "https://github.com/keterez/fbl_library/blob/main/src/platforms/arduino/arduinoI2C.cpp"
click node_stm32_i2c "https://github.com/keterez/fbl_library/tree/main/src/platforms/stm32"
click node_platform_select "https://github.com/keterez/fbl_library/blob/main/src/platforms/Platform.h"
click node_arduino_platform "https://github.com/keterez/fbl_library/blob/main/src/platforms/arduino/ArduinoPlatform.h"
click node_stm32_platform "https://github.com/keterez/fbl_library/blob/main/src/platforms/stm32/STM32Platform.h"

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_hydra,node_hydra_header toneBlue
class node_constants,node_as5600 toneAmber
class node_i2c_contract,node_i2c_factory,node_arduino_i2c,node_stm32_i2c toneMint
class node_platform_select,node_arduino_platform,node_stm32_platform toneRose
class node_caller,node_wire toneIndigo
```

## Components

### HydraX1 Control

- [HydraX1 API](https://github.com/keterez/fbl_library/blob/main/HydraX1.cpp): `HydraX1.cpp`
- [HydraX1 Interface](https://github.com/keterez/fbl_library/blob/main/HydraX1.h): `HydraX1.h`

### Angle Sensing

- [Angle Constants](https://github.com/keterez/fbl_library/blob/main/constatns.h): `constatns.h`
- [AS5600L Driver](https://github.com/keterez/fbl_library/blob/main/src/as5600l.cpp): `src/as5600l.cpp`

### I2C Transport

- [I2C Contract](https://github.com/keterez/fbl_library/blob/main/src/platforms/I2C.h): `src/platforms/I2C.h`
- [I2C Bus Factory](https://github.com/keterez/fbl_library/blob/main/src/platforms/I2C.cpp): `src/platforms/I2C.cpp`
- [Arduino I2C](https://github.com/keterez/fbl_library/blob/main/src/platforms/arduino/arduinoI2C.cpp): `src/platforms/arduino/arduinoI2C.cpp`
- [STM32 I2C Backend](https://github.com/keterez/fbl_library/tree/main/src/platforms/stm32): `src/platforms/stm32`

### Platform Services

- [Platform Selector](https://github.com/keterez/fbl_library/blob/main/src/platforms/Platform.h): `src/platforms/Platform.h`
- [Arduino Services](https://github.com/keterez/fbl_library/blob/main/src/platforms/arduino/ArduinoPlatform.h): `src/platforms/arduino/ArduinoPlatform.h`
- [STM32 Services](https://github.com/keterez/fbl_library/blob/main/src/platforms/stm32/STM32Platform.h): `src/platforms/stm32/STM32Platform.h`

### Other components

- **Library Caller**
- **Arduino Wire**

## Connections

- Library Caller → HydraX1 API: calls
- HydraX1 API → AS5600L Driver: initializes, calibrates, reads (evidence: `HydraX1.cpp`)
- HydraX1 API → Platform Selector: uses services (evidence: `HydraX1.cpp`)
- HydraX1 Interface → AS5600L Driver: declares sensor (evidence: `HydraX1.h`)
- AS5600L Driver → I2C Contract: reads and writes registers (evidence: `src/as5600l.cpp`)
- AS5600L Driver → Angle Constants: uses angle constant
- I2C Contract → Arduino I2C: aliases implementation (evidence: `src/platforms/I2C.h`)
- I2C Bus Factory → Arduino I2C: constructs bus (evidence: `src/platforms/I2C.cpp`)
- Arduino I2C → Arduino Wire: transfers bytes (evidence: `src/platforms/arduino/arduinoI2C.cpp`)
- I2C Contract → STM32 I2C Backend: backend described (evidence: `readme.txt`)
- Platform Selector → Arduino Services: selects on Arduino (evidence: `src/platforms/Platform.h`)
- Platform Selector → STM32 Services: selects on STM32 (evidence: `src/platforms/Platform.h`)
