ESPHome 2026.6.0-dev
Loading...
Searching...
No Matches
cd74hc4067.h
Go to the documentation of this file.
1#pragma once
2
4#include "esphome/core/hal.h"
7
8namespace esphome::cd74hc4067 {
9
11 public:
13 void setup() override;
14 void dump_config() override;
15
17 void activate_pin(uint8_t pin);
18
20 void set_pin_s0(GPIOPin *pin) { this->pin_s0_ = pin; }
22 void set_pin_s1(GPIOPin *pin) { this->pin_s1_ = pin; }
24 void set_pin_s2(GPIOPin *pin) { this->pin_s2_ = pin; }
26 void set_pin_s3(GPIOPin *pin) { this->pin_s3_ = pin; }
27
29 void set_switch_delay(uint32_t switch_delay) { this->switch_delay_ = switch_delay; }
30
31 private:
32 GPIOPin *pin_s0_;
33 GPIOPin *pin_s1_;
34 GPIOPin *pin_s2_;
35 GPIOPin *pin_s3_;
37 uint8_t active_pin_;
38 uint32_t switch_delay_;
39};
40
42 public:
44
45 void update() override;
46
47 void dump_config() override;
49 float get_setup_priority() const override;
50 void set_pin(uint8_t pin) { this->pin_ = pin; }
51 void set_source(voltage_sampler::VoltageSampler *source) { this->source_ = source; }
52
53 float sample() override;
54
55 protected:
59
60 uint8_t pin_;
61};
62} // namespace esphome::cd74hc4067
This class simplifies creating components that periodically check a state.
Definition component.h:585
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.
Definition cd74hc4067.cpp:9
void set_pin_s0(GPIOPin *pin)
set the pin connected to multiplexer control pin 0
Definition cd74hc4067.h:20
void set_pin_s3(GPIOPin *pin)
set the pin connected to multiplexer control pin 3
Definition cd74hc4067.h:26
void set_pin_s2(GPIOPin *pin)
set the pin connected to multiplexer control pin 2
Definition cd74hc4067.h:24
void set_pin_s1(GPIOPin *pin)
set the pin connected to multiplexer control pin 1
Definition cd74hc4067.h:22
void set_switch_delay(uint32_t switch_delay)
set the delay needed after an input switch
Definition cd74hc4067.h:29
void set_source(voltage_sampler::VoltageSampler *source)
Definition cd74hc4067.h:51
CD74HC4067Sensor(CD74HC4067Component *parent)
voltage_sampler::VoltageSampler * source_
The sampling source to read values from.
Definition cd74hc4067.h:58
float get_setup_priority() const override
HARDWARE_LATE setup priority.
Base-class for all sensors.
Definition sensor.h:47
Abstract interface for components to request voltage (usually ADC readings)
static void uint32_t