LCC Fusion Project 1.0
LCC Automation
Loading...
Searching...
No Matches
UOD Card Firmware

Firmware for the LCC Fusion UOD (Ultrasonic Occupancy Detection) Card. More...

Collaboration diagram for UOD Card Firmware:

Classes

struct  SensorRange
 Per-card occupancy thresholds (mA) for each sensor on a BSD Card. More...
 
struct  SensorStatus
 Sensor status bitmask structure. More...
 

Macros

#define WEB_SSID   "LCC_Fusion_UOD_Card"
 Web Serial SSID used when Web Serial is enabled.
 
#define BT_DEVICE_NAME   "LCC Fusion UOD Card"
 Bluetooth device name used when Bluetooth serial is enabled.
 

Functions

static HCSR04 hc (UOD_TRIGGER_PIN, ECHO_PINS_SET, NUM_UOD_SENSORS_PER_CARD)
 HC-SR04 driver instance.
 
void onI2cRequest ()
 I2C onRequest handler: send the 2-byte sensor bitmap. More...
 
void setupHelpCallback ()
 Register help/usage text for this card (shown on user request). More...
 
void setupTestCallback ()
 Install the test callback for the Audio Card commands.
 
void setupProgramCallback ()
 Install the progam callback for the Card commands.
 
void getSensorRanges ()
 Parse up to NUM_UOD_SENSORS_PER_CARD "< min_cm max_cm ... >" pairs and update ranges. Rules: More...
 
void initSerialComm ()
 One-time initialization for SerialIO, I2C slave registration, and optional diagnostics. More...
 
void setup ()
 Arduino setup for the BSD Card. More...
 
void loop ()
 Main loop: poll SerialIO for range updates and perform timed ultrasonic sweeps. More...
 

Variables

static constexpr uint8_t I2C_ADDR_OFFSET_PIN_SET [3] = { 27, 26, 25 }
 GPIO pins used for I2C address selection DIP switches. More...
 
static constexpr uint8_t I2C_SDA_PIN = 12
 Default I2C SDA pin (ESP32 I2C bus 0).
 
static constexpr uint8_t I2C_SCL_PIN = 14
 Default I2C SCL pin (ESP32 I2C bus 0).
 

Detailed Description

Firmware for the LCC Fusion UOD (Ultrasonic Occupancy Detection) Card.

High-level overview and links to the main entry points (setup/loop) and helper functions used by the UOD firmware.

Function Documentation

◆ getSensorRanges()

void getSensorRanges ( )

Parse up to NUM_UOD_SENSORS_PER_CARD "< min_cm max_cm ... >" pairs and update ranges. Rules:

  • Values parsed as base-10 unsigned, clamped to 0..256.
  • If max==0 → disable sensor (both set to 0).
  • If min>max (and max!=0) → swap to enforce min<=max.
  • Remaining sensors untouched if fewer pairs are provided.
  • Clears the input buffer after applying at least one pair to avoid reapplying.

Definition at line 184 of file UOD_Card.ino.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ initSerialComm()

void initSerialComm ( )

One-time initialization for SerialIO, I2C slave registration, and optional diagnostics.

Computes the final I2C address from DIP pins (base + offset) as defined in config.h, registers onRequest (and onReceive if used), and sets up any help/diagnostic callbacks.

Definition at line 269 of file UOD_Card.ino.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ loop()

void loop ( )

Main loop: poll SerialIO for range updates and perform timed ultrasonic sweeps.

  • Calls SerialIO parsing to update per-sensor min/max ranges when available.
  • Enforces minimum inter-trigger delay (e.g., ≥60–100 ms) between sweep bursts.
  • Rebuilds the triggered bitmap each sweep by measuring all configured sensors once.

Definition at line 300 of file UOD_Card.ino.

Here is the call graph for this function:

◆ onI2cRequest()

void onI2cRequest ( )

I2C onRequest handler: send the 2-byte sensor bitmap.

The master expects exactly 2 bytes. Send little-endian order: LSB first, then MSB of the current triggered bitmap.

Definition at line 123 of file UOD_Card.ino.

Here is the caller graph for this function:

◆ setup()

void setup ( )

Arduino setup for the BSD Card.

Verifies MCU is running on correct hardware Initializes GPIO, I2C, and register callbacks for serial commands (?, P, < cmd >, T)

Definition at line 283 of file UOD_Card.ino.

Here is the call graph for this function:

◆ setupHelpCallback()

void setupHelpCallback ( )

Register help/usage text for this card (shown on user request).

Purely diagnostic; does not alter ranges or bitmap.

Definition at line 132 of file UOD_Card.ino.

Here is the call graph for this function:

Variable Documentation

◆ I2C_ADDR_OFFSET_PIN_SET

constexpr uint8_t I2C_ADDR_OFFSET_PIN_SET[3] = { 27, 26, 25 }
staticconstexpr

GPIO pins used for I2C address selection DIP switches.

Each pin contributes a bit (pin1=+1, pin2=+2, pin3=+4) relative to base address. These pins must be configured with internal pull-ups; DIP switch grounds pin when closed.

Definition at line 74 of file config.h.