8 #include "i2c-device/device.hpp" 
    9 #include "i2c-device/util.hpp" 
   22         : m_device(i2c::AdapterNumber(adapter_nr), i2c::DeviceID(static_cast<int>(addr))),
 
   28         : m_device(std::move(other.m_device)),
 
   30           m_config(other.m_config),
 
   31           m_threshold(other.m_threshold)
 
   37         m_device = std::move(other.m_device);
 
   38         m_addr = std::move(other.m_addr);
 
   39         m_config = std::move(other.m_config);
 
   40         m_threshold = std::move(other.m_threshold);
 
   45     ADDR ADS1115::getADDR()
 const 
   50     std::int16_t ADS1115::read()
 const 
   55             m_device.write_word_data(
conf_reg_addr, m_config.to_bytes() | 0x8000);
 
   60                 std::this_thread::sleep_for(std::chrono::milliseconds(1));
 
   66         return std::bit_cast<std::int16_t>(data);
 
   69     double ADS1115::readVoltage()
 const 
   71         return toVoltage(read());
 
   80         setRegThreshold(threshold);
 
   83     double ADS1115::toVoltage(
const std::int16_t value)
 const 
   85         return value * 
pga_voltage_map.at(m_config.pga) / std::numeric_limits<std::int16_t>::max();
 
   88     std::int16_t ADS1115::fromVoltage(
const double value)
 const 
   90         return static_cast<std::int16_t
>(
 
   91             value * std::numeric_limits<std::int16_t>::max() / 
pga_voltage_map.at(m_config.pga));
 
  100         const std::uint16_t config_word = m_device.read_word_data(
conf_reg_addr);
 
  101         Config config(config_word);
 
  111     void ADS1115::setRegConfig(
const Config config)
 
  113         m_device.write_word_data(
conf_reg_addr, m_config.to_bytes());
 
  127             std::bit_cast<std::int16_t>(low_threshold),
 
  128             std::bit_cast<std::int16_t>(high_threshold),
 
  131         m_threshold = threshold;
 
  140     void ADS1115::setRegThreshold(
const Threshold threshold)
 
  142         m_device.write_word_data(
 
  144             std::bit_cast<std::uint16_t>(threshold.
getLow()));
 
  145         m_device.write_word_data(
 
  147             std::bit_cast<std::uint16_t>(threshold.
getHigh()));
 
  148         m_threshold = threshold;