Firmware API Reference
This page documents all firmware components and their functions.ADS1220Driver
Handles low-level communication with the ADS1220 ADC chip.Methods
bool init()
Initializes the ADS1220 ADC and configures SPI.
Returns: true if successful, false if ADC not found
Example:
void reset()
Resets the ADS1220 to default settings.
Example:
void configure()
Configures ADC settings for EEG acquisition:
- Gain: 1x
- Data rate: 660 SPS
- Reference: External 3.3V
- FIR filter: 50/60Hz rejection
- Mode: Continuous conversion
init().
bool isDataReady()
Checks if new data is available from the ADC.
Returns: true if data ready, false otherwise
Example:
long readRawData()
Reads the latest raw ADC value.
Returns: 24-bit signed integer
Range: -8,388,608 to 8,388,607
Example:
BLEManager
Manages Bluetooth Low Energy communication.Constants
Methods
bool init()
Initializes BLE server and starts advertising.
Returns: true if successful
Example:
void update()
Updates BLE connection state. Call this in your main loop.
Example:
void sendData(long value)
Sends data value via BLE notification.
Parameters:
value: Raw ADC reading to send
bool isConnected()
Checks if a BLE client is connected.
Returns: true if connected
Example:
bool wasJustConnected()
Detects connection change (disconnected → connected).
Returns: true on new connection
Example:
bool wasJustDisconnected()
Detects disconnection change (connected → disconnected).
Returns: true on disconnection
Example:
bool hasCommand()
Checks if a command was received via BLE.
Returns: true if command available
char getCommand()
Retrieves the received command character.
Returns: Command character (b, s, or v)
Example:
EEGStreamer
Manages high-level EEG data streaming.Constructor
ads: Reference to ADS1220Driver instanceble: Pointer to BLEManager (nullptr for Serial-only mode)
Methods
void start()
Starts data streaming.
Example:
void stop()
Stops data streaming.
Example:
void update()
Reads and streams data if available. Call this in your main loop.
Example:
bool isStreaming()
Checks if currently streaming.
Returns: true if streaming active
Example:
CommandHandler
Processes commands from Serial and BLE.Enum
Constructor
ble: Pointer to BLEManager (nullptr for Serial-only)
Methods
Command process()
Checks for and processes commands from Serial or BLE.
Returns: Command enum value
Example:
LedController
Manages status LED for visual feedback.Methods
void init()
Initializes LED pin.
Example:
void on()
Turns LED on.
void off()
Turns LED off.
void toggle()
Toggles LED state.
void blink(int times, int duration = 250)
Blinks LED a specified number of times.
Parameters:
times: Number of blinksduration: Duration of each blink in milliseconds (default: 250)
Configuration Constants
Defined inconfig.h:
Usage Examples
Basic Serial-Only Setup
Full BLE Setup
Data Format
Serial Output
Raw ADC values as decimal integers, one per line:BLE Data Characteristic
8-byte packets with the following structure:| Bytes | Type | Description |
|---|---|---|
| 0-7 | String | ASCII representation of raw value |
"12543221"