ESPHome  2024.9.2
gpio_lcd_display.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "esphome/core/hal.h"
5 
6 namespace esphome {
7 namespace lcd_gpio {
8 
10  public:
11  void set_writer(std::function<void(GPIOLCDDisplay &)> &&writer) { this->writer_ = std::move(writer); }
12  void setup() override;
13  void set_data_pins(GPIOPin *d0, GPIOPin *d1, GPIOPin *d2, GPIOPin *d3) {
14  this->data_pins_[0] = d0;
15  this->data_pins_[1] = d1;
16  this->data_pins_[2] = d2;
17  this->data_pins_[3] = d3;
18  }
19  void set_data_pins(GPIOPin *d0, GPIOPin *d1, GPIOPin *d2, GPIOPin *d3, GPIOPin *d4, GPIOPin *d5, GPIOPin *d6,
20  GPIOPin *d7) {
21  this->data_pins_[0] = d0;
22  this->data_pins_[1] = d1;
23  this->data_pins_[2] = d2;
24  this->data_pins_[3] = d3;
25  this->data_pins_[4] = d4;
26  this->data_pins_[5] = d5;
27  this->data_pins_[6] = d6;
28  this->data_pins_[7] = d7;
29  }
30  void set_enable_pin(GPIOPin *enable) { this->enable_pin_ = enable; }
31  void set_rs_pin(GPIOPin *rs) { this->rs_pin_ = rs; }
32  void set_rw_pin(GPIOPin *rw) { this->rw_pin_ = rw; }
33  void dump_config() override;
34 
35  protected:
36  bool is_four_bit_mode() override { return this->data_pins_[4] == nullptr; }
37  void write_n_bits(uint8_t value, uint8_t n) override;
38  void send(uint8_t value, bool rs) override;
39 
40  void call_writer() override { this->writer_(*this); }
41 
42  GPIOPin *rs_pin_{nullptr};
43  GPIOPin *rw_pin_{nullptr};
44  GPIOPin *enable_pin_{nullptr};
45  GPIOPin *data_pins_[8]{nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr};
46  std::function<void(GPIOLCDDisplay &)> writer_;
47 };
48 
49 } // namespace lcd_gpio
50 } // namespace esphome
void set_writer(std::function< void(GPIOLCDDisplay &)> &&writer)
void set_data_pins(GPIOPin *d0, GPIOPin *d1, GPIOPin *d2, GPIOPin *d3, GPIOPin *d4, GPIOPin *d5, GPIOPin *d6, GPIOPin *d7)
std::function< void(GPIOLCDDisplay &)> writer_
void set_enable_pin(GPIOPin *enable)
void write_n_bits(uint8_t value, uint8_t n) override
void send(uint8_t value, bool rs) override
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
void set_data_pins(GPIOPin *d0, GPIOPin *d1, GPIOPin *d2, GPIOPin *d3)