FluxSand 1.0
FluxSand - Interactive Digital Hourglass
|
ADS1115 ADC driver with GPIO interrupt-based channel cycling. More...
#include <ads1115.hpp>
Public Member Functions | |
Ads1115 (I2cDevice &i2c, Gpio &drdy, uint8_t address=DEFAULT_I2C_ADDR) | |
Constructor. | |
void | StartScan () |
Starts scanning the channels and enabling data-ready interrupt. | |
void | Stop () |
Stops the scan process. | |
float | GetVoltage (int channel) const |
Returns the latest voltage reading from a specific channel. | |
void | EnableReadyInterruptMode () |
Registers interrupt-based data-ready mode (comparator configuration) | |
void | Display () const |
Prints voltage readings of all channels to console. | |
void | RegisterChannelCallback (int channel, std::function< void(float)> cb) |
Registers a callback function for a specific channel. | |
Static Public Attributes | |
static constexpr uint8_t | DEFAULT_I2C_ADDR = 0x48 |
static constexpr uint8_t | POINTER_CONVERSION = 0x00 |
static constexpr uint8_t | POINTER_CONFIG = 0x01 |
Private Member Functions | |
void | OnDataReady () |
Called on rising edge of ALERT/RDY pin Reads current value, stores it, calls callback, then switches to next channel. | |
void | ConfigureChannel (int channel) |
Configures ADS1115 for a specific single-ended channel. | |
int16_t | ReadConversion () |
Reads the 16-bit signed conversion result. | |
Private Attributes | |
I2cDevice & | i2c_ |
Gpio & | drdy_gpio_ |
uint8_t | i2c_addr_ |
std::function< void(float)> | callbacks_ [CHANNEL_NUM] |
std::atomic< bool > | scanning_ {false} |
int | current_channel_ = 0 |
float | voltages_ [CHANNEL_NUM] = {0.0f} |
ADS1115 ADC driver with GPIO interrupt-based channel cycling.
Continuously scans 4 single-ended channels using ALERT/RDY pin as data-ready signal, stores voltage values in voltages_[]
, and allows user-defined per-channel callbacks.
Definition at line 22 of file ads1115.hpp.
|
inline |
Constructor.
i2c | I2C device reference |
drdy | GPIO for ALERT/RDY pin (interrupt-enabled) |
address | I2C address (default 0x48) |
Definition at line 34 of file ads1115.hpp.
|
inlineprivate |
Configures ADS1115 for a specific single-ended channel.
channel | Index 0~3 |
Definition at line 144 of file ads1115.hpp.
|
inline |
Prints voltage readings of all channels to console.
Definition at line 85 of file ads1115.hpp.
|
inline |
Registers interrupt-based data-ready mode (comparator configuration)
Definition at line 72 of file ads1115.hpp.
|
inline |
Returns the latest voltage reading from a specific channel.
channel | Index (0 ~ CHANNEL_NUM-1) |
Definition at line 62 of file ads1115.hpp.
|
inlineprivate |
Called on rising edge of ALERT/RDY pin Reads current value, stores it, calls callback, then switches to next channel.
Definition at line 120 of file ads1115.hpp.
|
inlineprivate |
Reads the 16-bit signed conversion result.
Definition at line 172 of file ads1115.hpp.
|
inline |
Registers a callback function for a specific channel.
channel | Index (0 ~ CHANNEL_NUM-1) |
cb | Callback function taking float voltage as parameter |
Definition at line 97 of file ads1115.hpp.
|
inline |
Starts scanning the channels and enabling data-ready interrupt.
Definition at line 43 of file ads1115.hpp.
|
inline |
|
private |
Definition at line 109 of file ads1115.hpp.
|
private |
Definition at line 112 of file ads1115.hpp.
|
staticconstexpr |
Definition at line 24 of file ads1115.hpp.
Definition at line 107 of file ads1115.hpp.
Definition at line 105 of file ads1115.hpp.
|
private |
Definition at line 108 of file ads1115.hpp.
|
staticconstexpr |
Definition at line 26 of file ads1115.hpp.
|
staticconstexpr |
Definition at line 25 of file ads1115.hpp.
|
private |
Definition at line 111 of file ads1115.hpp.
|
private |
Definition at line 113 of file ads1115.hpp.