ESPHome  2021.9.3
sn74hc595.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/esphal.h"
5 
6 namespace esphome {
7 namespace sn74hc595 {
8 
9 class SN74HC595Component : public Component {
10  public:
11  SN74HC595Component() = default;
12 
13  void setup() override;
14  float get_setup_priority() const override;
15  void dump_config() override;
16 
17  void set_data_pin(GPIOPin *pin) { data_pin_ = pin; }
18  void set_clock_pin(GPIOPin *pin) { clock_pin_ = pin; }
19  void set_latch_pin(GPIOPin *pin) { latch_pin_ = pin; }
20  void set_oe_pin(GPIOPin *pin) {
21  oe_pin_ = pin;
22  have_oe_pin_ = true;
23  }
24  void set_sr_count(uint8_t count) { sr_count_ = count; }
25 
26  protected:
27  friend class SN74HC595GPIOPin;
28  bool digital_read_(uint8_t pin);
29  void digital_write_(uint8_t pin, bool value);
30  bool write_gpio_();
31 
36  uint8_t sr_count_;
37  bool have_oe_pin_{false};
38  uint32_t output_bits_{0x00};
39 };
40 
42 class SN74HC595GPIOPin : public GPIOPin {
43  public:
44  SN74HC595GPIOPin(SN74HC595Component *parent, uint8_t pin, bool inverted = false);
45 
46  void setup() override;
47  bool digital_read() override;
48  void digital_write(bool value) override;
49 
50  protected:
52 };
53 
54 } // namespace sn74hc595
55 } // namespace esphome
SN74HC595Component * parent_
Definition: sn74hc595.h:51
Helper class to expose a SC74HC595 pin as an internal output GPIO pin.
Definition: sn74hc595.h:42
float get_setup_priority() const override
Definition: sn74hc595.cpp:63
void digital_write_(uint8_t pin, bool value)
Definition: sn74hc595.cpp:33
Library based on https://github.com/miguelbalboa/rfid and adapted to ESPHome by . ...
Definition: a4988.cpp:4
void set_sr_count(uint8_t count)
Definition: sn74hc595.h:24
A high-level abstraction class that can expose a pin together with useful options like pinMode...
Definition: esphal.h:69