# rohanjudd/ble-fx-control architecture

> Architecture diagram of the GitHub repository rohanjudd/ble-fx-control, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rohanjudd/ble-fx-control
- Repository: https://github.com/rohanjudd/ble-fx-control

## Overview

##### Project Type and Purpose
- This is an embedded firmware project (“BLE FX Control”) targeting an Arduino-compatible microcontroller (BLE-enabled) to sense inputs (sensors, analog controls) and drive outputs (LEDs, OLED display, haptic/tactile feedback) under commands received over Bluetooth Low Energy (BLE).

##### Main Architectural Components
a. Hardware Abstraction Layer (HAL) – device drivers for each peripheral:
- AmpControl (audio or signal amplitude control via DAC/PWM)
- Analogue (knobs/potentiometers or analog sensors)
- Hall (magnetic sensor)
- IMU (inertial measurement unit)
- Tactile (buttons, switches, haptic actuator)
- LED (RGB or status LEDs)
- OLED (display driver)
b. Communication Layer
- BLE (nRF52832 or similar)—receives control commands, streams sensor data
c. Application Logic / Control “Nav”
- Nav.cpp/h implements the finite-state machine or signal-routing logic, sequences effects, handles mode switching
d. Presentation Layer
- OLED display UI
- LED patterns
- Tactile/haptic feedback patterns
e. Build / Configuration
- .ino sketch (BLE_FX_Control5.ino) ties all components together in Arduino setup()/loop()

##### Interactions & Data Flows
- BLE ←→ Nav: receive commands (effect parameters, mode select), send sensor telemetry
- Sensors (IMU, Hall, Analogue) → HAL → Nav: continuous data feed for gesture or position-based modulation
- Nav → Outputs:
- AmpControl → external amplifier or audio chain
- LED module → visual effects
- Tactile → haptic feedback
- OLED → display current mode/status

##### Architectural Patterns & Principles
- Layered architecture separating hardware drivers (each .cpp/.h pair) from application logic (Nav) and communication (BLE)
- Event-driven loop: Arduino sketch polls sensors and BLE events, dispatches to Nav FSM
- Single responsibility per driver module—clear boundaries for maintainability

a. Components to show:
- Microcontroller (as central node)
- Peripheral blocks: IMU, Hall, Analogue, Tactile, AmpControl, LED, OLED
- BLE radio module (internal to MCU or external)
- Application block “Nav / Control Logic”
c. Technologies & libraries:
- Arduino framework (setup/loop)
- BLE library (e.g., ArduinoBLE or Nordic SDK)
- I2C/SPI bus for IMU/OLED
- ADC for Analogue & Hall sensors
d. Patterns:
- Hardware Abstraction Layer (label per driver)
- Control / FSM layer
- Presentation / Output layer

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Entry Point"
        Sketch["BLE_FX_Control5.ino"]:::entry
    end

    subgraph "Communication Layer"
        BLE["BLE Module"]:::comm
    end

    subgraph "Hardware Abstraction Layer"
        IMU["IMU Driver"]:::HAL
        Hall["Hall Driver"]:::HAL
        Analogue["Analogue Driver"]:::HAL
        AmpControl["AmpControl Driver"]:::HAL
        LED["LED Driver"]:::HAL
        Tactile["Tactile Driver"]:::HAL
        OLED["OLED Driver"]:::HAL
    end

    subgraph "Application Logic / Control"
        Nav["Nav Control Logic"]:::logic
    end

    Sketch --> BLE
    Sketch --> IMU
    Sketch --> Hall
    Sketch --> Analogue
    Sketch --> AmpControl
    Sketch --> LED
    Sketch --> Tactile
    Sketch --> OLED
    Sketch --> Nav

    BLE -->|"BLE GATT"| Nav
    Nav -->|"Telemetry"| BLE

    IMU -->|"I2C Data"| Nav
    Hall -->|"ADC Data"| Nav
    Analogue -->|"ADC Data"| Nav

    Nav -->|"PWM/DAC"| AmpControl
    Nav -->|"PWM/Digital"| LED
    Nav -->|"Digital/PWM"| Tactile
    Nav -->|"I2C Command"| OLED

    click Sketch "https://github.com/rohanjudd/ble-fx-control/blob/main/BLE_FX_Control5.ino"
    click BLE "https://github.com/rohanjudd/ble-fx-control/blob/main/BLE_FX_Control5.ino"
    click IMU "https://github.com/rohanjudd/ble-fx-control/blob/main/IMU.cpp"
    click IMU "https://github.com/rohanjudd/ble-fx-control/blob/main/IMU.h"
    click Hall "https://github.com/rohanjudd/ble-fx-control/blob/main/Hall.cpp"
    click Hall "https://github.com/rohanjudd/ble-fx-control/blob/main/Hall.h"
    click Analogue "https://github.com/rohanjudd/ble-fx-control/blob/main/Analogue.cpp"
    click Analogue "https://github.com/rohanjudd/ble-fx-control/blob/main/Analogue.h"
    click AmpControl "https://github.com/rohanjudd/ble-fx-control/blob/main/AmpControl.cpp"
    click AmpControl "https://github.com/rohanjudd/ble-fx-control/blob/main/AmpControl.h"
    click LED "https://github.com/rohanjudd/ble-fx-control/blob/main/LED.cpp"
    click LED "https://github.com/rohanjudd/ble-fx-control/blob/main/LED.h"
    click Tactile "https://github.com/rohanjudd/ble-fx-control/blob/main/Tactile.cpp"
    click Tactile "https://github.com/rohanjudd/ble-fx-control/blob/main/Tactile.h"
    click OLED "https://github.com/rohanjudd/ble-fx-control/blob/main/OLED.cpp"
    click OLED "https://github.com/rohanjudd/ble-fx-control/blob/main/OLED.h"
    click Nav "https://github.com/rohanjudd/ble-fx-control/blob/main/Nav.cpp"
    click Nav "https://github.com/rohanjudd/ble-fx-control/blob/main/Nav.h"

    classDef HAL fill:#add8e6,stroke:#000;
    classDef logic fill:#90ee90,stroke:#000;
    classDef comm fill:#dda0dd,stroke:#000;
    classDef entry fill:#f0e68c,stroke:#000;
```
