7static const char *
const TAG =
"adc.common";
12 return LOG_STR(
"average");
14 return LOG_STR(
"minimum");
16 return LOG_STR(
"maximum");
18 return LOG_STR(
"unknown");
25 this->aggr_ = std::numeric_limits<T>::max();
32 switch (this->mode_) {
38 if (value < this->aggr_) {
44 if (value > this->aggr_) {
52 if (this->samples_ == 0) {
56 return (this->aggr_ + (this->samples_ >> 1)) / this->samples_;
69 float value_v = this->
sample();
70 ESP_LOGV(TAG,
"'%s': Voltage=%.4fV", this->
get_name().c_str(), value_v);
75 if (sample_count != 0) {
BedjetMode mode
BedJet operating mode.
const StringRef & get_name() const
void set_sampling_mode(SamplingMode sampling_mode)
Set the sampling mode for how multiple ADC samples are combined into a single measurement.
void set_sample_count(uint8_t sample_count)
Set the number of samples to be taken for ADC readings to improve accuracy.
float sample() override
Perform a single ADC sampling operation and return the measured value.
void update() override
Update the sensor's state by reading the current ADC value.
SamplingMode sampling_mode_
float get_setup_priority() const override
Return the setup priority for this component.
Aggregator(SamplingMode mode)
void publish_state(float state)
Publish a new state to the front-end.
const LogString * sampling_mode_to_str(SamplingMode mode)
const float DATA
For components that import data from directly connected sensors like DHT.
Providing packet encoding functions for exchanging data with a remote host.