29 lines
896 B
C++
29 lines
896 B
C++
#include "ads1115_int_sensor.h"
|
|
|
|
#include "esphome/core/log.h"
|
|
|
|
namespace esphome {
|
|
namespace ads1115_int {
|
|
|
|
static const char *const TAG = "ads1115_int.sensor";
|
|
|
|
void ADS1115Sensor::loop()
|
|
{
|
|
if(this->first_reading_) {
|
|
this->parent_->set_mux_data(this->multiplexer_, this->gain_, this->resolution_, this->samplerate_, this);
|
|
this->first_reading_ = false;
|
|
this->parent_->start_single_shot_conversion(); // this will set off the first conversion; subsequent conversions will be triggered by the ISR
|
|
}
|
|
}
|
|
|
|
void ADS1115Sensor::dump_config() {
|
|
LOG_SENSOR(" ", "ADS1115 Int Sensor", this);
|
|
ESP_LOGCONFIG(TAG, " Multiplexer: %u", this->multiplexer_);
|
|
ESP_LOGCONFIG(TAG, " Gain: %u", this->gain_);
|
|
ESP_LOGCONFIG(TAG, " Resolution: %u", this->resolution_);
|
|
ESP_LOGCONFIG(TAG, " Sample rate: %u", this->samplerate_);
|
|
}
|
|
|
|
} // namespace ads1115
|
|
} // namespace esphome
|