ads1115
0.2.0
|
#include "ads1115.hpp"
Public Member Functions | |
ADS1115 (const int adapter_nr, const ADDR addr) | |
ADS1115 (const ADS1115 &other)=delete | |
ADS1115 (ADS1115 &&other) noexcept | |
ADS1115 & | operator= (const ADS1115 &other)=delete |
ADS1115 & | operator= (ADS1115 &&other) noexcept |
~ADS1115 ()=default | |
Destroys the object that represents the ADS1115. More... | |
ADDR | getADDR () const |
std::int16_t | read () const |
double | readVoltage () const |
void | reset () |
double | toVoltage (const std::int16_t value) const |
std::int16_t | fromVoltage (const double value) const |
Config | readRegConfig () |
Config | getRegConfig () const |
void | setRegConfig (const Config config) |
Threshold | readRegThreshold () |
Threshold | getRegThreshold () const |
void | setRegThreshold (const Threshold threshold) |
Private Attributes | |
i2c::i2c_device | m_device |
The generic i2c device in use. More... | |
ADDR | m_addr |
The i2c bus address of the ADS1115. More... | |
Config | m_config {} |
The current configuration of the ADS1115. More... | |
Threshold | m_threshold {} |
The current configuration of the threshold registers. More... | |
This class describes the ADS1115. The data sheet of the ADS1115 can be fond at https://cdn-shop.adafruit.com/datasheets/ads1115.pdf.
Definition at line 23 of file ads1115.hpp.
ADS1115::ADS1115::ADS1115 | ( | const int | adapter_nr, |
const ADDR | addr | ||
) |
Creates the object to represent the ADS1115.
This will open the device given by fs_dev and try to connect to the given i2c bus address. The the configuration register of the ADS1115 is loaded and stored in the object.
fs_dev | std::filesystem::path to the i2c bus device file. |
addr | Address of the ADS1115 on the i2c bus. |
Definition at line 21 of file ads1115.cpp.
|
delete |
|
noexcept |
Definition at line 27 of file ads1115.cpp.
|
default |
Destroys the object that represents the ADS1115.
std::int16_t ADS1115::ADS1115::fromVoltage | ( | const double | value | ) | const |
Converts a voltage value to a value returned by read(),
Uses the current PGA setting for the conversion.
value | The value to be converted. |
Definition at line 88 of file ads1115.cpp.
References ADS1115::pga_voltage_map.
ADDR ADS1115::ADS1115::getADDR | ( | ) | const |
Returns the address of the ADS1115 that is currently used.
Definition at line 45 of file ads1115.cpp.
Config ADS1115::ADS1115::getRegConfig | ( | ) | const |
Threshold ADS1115::ADS1115::getRegThreshold | ( | ) | const |
Returns the currently stored threshold registers of the ADS1115 whithout hiting the chip.
Definition at line 135 of file ads1115.cpp.
Referenced by TEST().
Definition at line 35 of file ads1115.cpp.
std::int16_t ADS1115::ADS1115::read | ( | ) | const |
Read the current value of the conversion register of the ADS1115. If the ADS1115 is in single conversion mode a new conversion will be started and the function returns when the conversion is done.
Definition at line 50 of file ads1115.cpp.
References ADS1115::conf_reg_addr, ADS1115::conv_reg_addr, and ADS1115::SINGLE_CONV.
Config ADS1115::ADS1115::readRegConfig | ( | ) |
Read the config register of the ADS1115.
Reads the current value of the config register of the ADS1115 and updates the internal object representation of the config.
Definition at line 98 of file ads1115.cpp.
References ADS1115::conf_reg_addr.
Threshold ADS1115::ADS1115::readRegThreshold | ( | ) |
Read the threshold registers of the ADS1115.
Reads the current value of the threshold registers of the ADS1115 and updates the internal object representation.
Definition at line 121 of file ads1115.cpp.
References ADS1115::hi_thresh_reg_addr, and ADS1115::lo_thresh_reg_addr.
double ADS1115::ADS1115::readVoltage | ( | ) | const |
void ADS1115::ADS1115::reset | ( | ) |
Resets the device to it's default state.
Definition at line 74 of file ads1115.cpp.
Referenced by TEST().
void ADS1115::ADS1115::setRegConfig | ( | const Config | config | ) |
Sets the configuration of the ADS1115.
Updates the internal object representation of the configuration and writes it to the config register of the ADS1115.
config | A Config object representing the content of the config register. |
Definition at line 111 of file ads1115.cpp.
References ADS1115::conf_reg_addr.
void ADS1115::ADS1115::setRegThreshold | ( | const Threshold | threshold | ) |
Sets the threshold registers of the ADS1115.
Updates the internal object representation of the configuration and writes it to the threshold registers of the ADS1115.
threshold | A Threshold object representing the contents of the threshold registers. |
Definition at line 140 of file ads1115.cpp.
References ADS1115::Threshold::getHigh(), ADS1115::Threshold::getLow(), ADS1115::hi_thresh_reg_addr, and ADS1115::lo_thresh_reg_addr.
double ADS1115::ADS1115::toVoltage | ( | const std::int16_t | value | ) | const |
Converts a value returned by read() to a Voltage.
Uses the current PGA setting for the conversion.
value | The value to be converted. |
Definition at line 83 of file ads1115.cpp.
References ADS1115::pga_voltage_map.
|
private |
The i2c bus address of the ADS1115.
Definition at line 29 of file ads1115.hpp.
|
private |
The current configuration of the ADS1115.
Definition at line 32 of file ads1115.hpp.
|
private |
The generic i2c device in use.
Definition at line 26 of file ads1115.hpp.
|
private |
The current configuration of the threshold registers.
Definition at line 35 of file ads1115.hpp.