8static const char *
const TAG =
"cd74hc4067";
13 this->pin_s0_->
setup();
14 this->pin_s1_->
setup();
15 this->pin_s2_->
setup();
16 this->pin_s3_->
setup();
19 this->active_pin_ = 1;
24 ESP_LOGCONFIG(TAG,
"CD74HC4067 Multiplexer:");
25 LOG_PIN(
" S0 Pin: ", this->pin_s0_);
26 LOG_PIN(
" S1 Pin: ", this->pin_s1_);
27 LOG_PIN(
" S2 Pin: ", this->pin_s2_);
28 LOG_PIN(
" S3 Pin: ", this->pin_s3_);
29 ESP_LOGCONFIG(TAG,
"switch delay: %" PRIu32, this->switch_delay_);
33 if (this->active_pin_ != pin) {
34 ESP_LOGD(TAG,
"switch to input %d", pin);
36 static int mux_channel[16][4] = {
59 delay(this->switch_delay_);
60 this->active_pin_ = pin;
67 float value_v = this->
sample();
79 LOG_SENSOR(TAG,
"CD74HC4067 Sensor",
this);
80 ESP_LOGCONFIG(TAG,
" Pin: %u", this->
pin_);
81 LOG_UPDATE_INTERVAL(
this);
virtual void digital_write(bool value)=0
void activate_pin(uint8_t pin)
setting pin active by setting the right combination of the four multiplexer input pins
void setup() override
Set up the internal sensor array.
void dump_config() override
float get_setup_priority() const override
CD74HC4067Sensor(CD74HC4067Component *parent)
CD74HC4067Component * parent_
voltage_sampler::VoltageSampler * source_
The sampling source to read values from.
float get_setup_priority() const override
HARDWARE_LATE setup priority.
void dump_config() override
void publish_state(float state)
Publish a new state to the front-end.
virtual float sample()=0
Get a voltage reading, in V.
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.
void IRAM_ATTR HOT delay(uint32_t ms)