9 #include <esp_adc_cal.h> 10 #include "driver/adc.h" 18 #if (ESP_IDF_VERSION_MAJOR == 4 && ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 4, 7)) || \ 19 (ESP_IDF_VERSION_MAJOR == 5 && \ 20 ((ESP_IDF_VERSION_MINOR == 0 && ESP_IDF_VERSION_PATCH >= 5) || \ 21 (ESP_IDF_VERSION_MINOR == 1 && ESP_IDF_VERSION_PATCH >= 3) || \ 22 (ESP_IDF_VERSION_MINOR >= 2)) \ 25 static const adc_atten_t ADC_ATTEN_DB_12_COMPAT = ADC_ATTEN_DB_12;
27 static const adc_atten_t ADC_ATTEN_DB_12_COMPAT = ADC_ATTEN_DB_11;
36 void add_sample(uint32_t value);
49 void set_attenuation(adc_atten_t attenuation) { this->attenuation_ = attenuation; }
52 this->channel1_ = channel;
53 this->channel2_ = ADC2_CHANNEL_MAX;
56 this->channel2_ = channel;
57 this->channel1_ = ADC1_CHANNEL_MAX;
63 void update()
override;
65 void setup()
override;
66 void dump_config()
override;
68 float get_setup_priority()
const override;
71 void set_sample_count(uint8_t sample_count);
73 float sample()
override;
76 std::string unique_id()
override;
85 bool output_raw_{
false};
86 uint8_t sample_count_{1};
90 bool is_temperature_{
false};
94 adc_atten_t attenuation_{ADC_ATTEN_DB_0};
95 adc1_channel_t channel1_{ADC1_CHANNEL_MAX};
96 adc2_channel_t channel2_{ADC2_CHANNEL_MAX};
97 bool autorange_{
false};
98 #if ESP_IDF_VERSION_MAJOR >= 5 99 esp_adc_cal_characteristics_t cal_characteristics_[SOC_ADC_ATTEN_NUM] = {};
101 esp_adc_cal_characteristics_t cal_characteristics_[ADC_ATTEN_MAX] = {};
102 #endif // ESP_IDF_VERSION_MAJOR
const LogString * sampling_mode_to_str(SamplingMode mode)
Abstract interface for components to request voltage (usually ADC readings)
This class simplifies creating components that periodically check a state.
void set_channel2(adc2_channel_t channel)
void set_channel1(adc1_channel_t channel)
void set_is_temperature()
BedjetMode mode
BedJet operating mode.
void set_output_raw(bool output_raw)
Implementation of SPI Controller mode.
void set_autorange(bool autorange)
void set_pin(InternalGPIOPin *pin)
Base-class for all sensors.