ESPHome  2024.4.1
cd74hc4067.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/hal.h"
7 
8 namespace esphome {
9 namespace cd74hc4067 {
10 
12  public:
14  void setup() override;
15  void dump_config() override;
16  float get_setup_priority() const override;
17 
19  void activate_pin(uint8_t pin);
20 
22  void set_pin_s0(GPIOPin *pin) { this->pin_s0_ = pin; }
24  void set_pin_s1(GPIOPin *pin) { this->pin_s1_ = pin; }
26  void set_pin_s2(GPIOPin *pin) { this->pin_s2_ = pin; }
28  void set_pin_s3(GPIOPin *pin) { this->pin_s3_ = pin; }
29 
31  void set_switch_delay(uint32_t switch_delay) { this->switch_delay_ = switch_delay; }
32 
33  private:
34  GPIOPin *pin_s0_;
35  GPIOPin *pin_s1_;
36  GPIOPin *pin_s2_;
37  GPIOPin *pin_s3_;
39  uint8_t active_pin_;
40  uint32_t switch_delay_;
41 };
42 
44  public:
46 
47  void update() override;
48 
49  void dump_config() override;
51  float get_setup_priority() const override;
52  void set_pin(uint8_t pin) { this->pin_ = pin; }
53  void set_source(voltage_sampler::VoltageSampler *source) { this->source_ = source; }
54 
55  float sample() override;
56 
57  protected:
61 
62  uint8_t pin_;
63 };
64 } // namespace cd74hc4067
65 } // namespace esphome
Abstract interface for components to request voltage (usually ADC readings)
void set_pin_s2(GPIOPin *pin)
set the pin connected to multiplexer control pin 2
Definition: cd74hc4067.h:26
This class simplifies creating components that periodically check a state.
Definition: component.h:283
void set_pin_s1(GPIOPin *pin)
set the pin connected to multiplexer control pin 1
Definition: cd74hc4067.h:24
void set_pin_s0(GPIOPin *pin)
set the pin connected to multiplexer control pin 0
Definition: cd74hc4067.h:22
void set_switch_delay(uint32_t switch_delay)
set the delay needed after an input switch
Definition: cd74hc4067.h:31
void activate_pin(uint8_t pin)
setting pin active by setting the right combination of the four multiplexer input pins ...
Definition: cd74hc4067.cpp:34
voltage_sampler::VoltageSampler * source_
The sampling source to read values from.
Definition: cd74hc4067.h:60
void set_pin_s3(GPIOPin *pin)
set the pin connected to multiplexer control pin 3
Definition: cd74hc4067.h:28
float get_setup_priority() const override
Definition: cd74hc4067.cpp:10
This is a workaround until we can figure out a way to get the tflite-micro idf component code availab...
Definition: a01nyub.cpp:7
void set_source(voltage_sampler::VoltageSampler *source)
Definition: cd74hc4067.h:53
Base-class for all sensors.
Definition: sensor.h:57
CD74HC4067Component * parent_
Definition: cd74hc4067.h:58
void setup() override
Set up the internal sensor array.
Definition: cd74hc4067.cpp:12