ads1115  0.2.0
ads1115.hpp
Go to the documentation of this file.
1 #ifndef ADS1115_ADS1115_HPP_
2 #define ADS1115_ADS1115_HPP_
3 
4 // ADS1115
5 #include "ads1115/config.hpp"
7 #include "ads1115/threshold.hpp"
8 
9 // i2c-device
10 #include "i2c-device/device.hpp"
11 
12 // stl
13 #include <cstdio>
14 #include <filesystem>
15 
16 namespace ADS1115
17 {
18 
24  {
26  i2c::i2c_device<> m_device;
27 
30 
32  Config m_config {};
33 
35  Threshold m_threshold {};
36 
37  public:
47  ADS1115(const int adapter_nr, const ADDR addr);
48 
49  ADS1115(const ADS1115& other) = delete;
50  ADS1115(ADS1115&& other) noexcept;
51 
52  ADS1115& operator=(const ADS1115& other) = delete;
53  ADS1115& operator=(ADS1115&& other) noexcept;
54 
56  ~ADS1115() = default;
57 
62  ADDR getADDR() const;
63 
70  std::int16_t read() const;
71 
78  double readVoltage() const;
79 
82  void reset();
83 
91  double toVoltage(const std::int16_t value) const;
92 
100  std::int16_t fromVoltage(const double value) const;
101 
102  /***************************
103  * Config register *
104  ***************************/
105 
113  Config readRegConfig();
114 
119  Config getRegConfig() const;
120 
128  void setRegConfig(const Config config);
129 
130  /**********************
131  * Threshold register *
132  **********************/
133 
141  Threshold readRegThreshold();
142 
148  Threshold getRegThreshold() const;
149 
157  void setRegThreshold(const Threshold threshold);
158  };
159 
160 } // namespace ADS1115
161 
162 #endif // ADS1115_ADS1115_HPP_
ADS1115
Definition: ads1115.hpp:16
ADS1115::Threshold
Definition: threshold.hpp:12
config.hpp
ads1115_export.h
ADS1115::ADS1115::m_addr
ADDR m_addr
The i2c bus address of the ADS1115.
Definition: ads1115.hpp:29
ADS1115::ADS1115::m_device
i2c::i2c_device m_device
The generic i2c device in use.
Definition: ads1115.hpp:26
threshold.hpp
ADS1115::Config
Definition: config.hpp:20
ADS1115_EXPORT
#define ADS1115_EXPORT
Definition: ads1115_export.h:15
ADS1115::ADDR
ADDR
This Enum describes the possible i2c bus addresses of a ADS1115.
Definition: parameters.hpp:20