ESPHome  2024.9.2
lcd_display.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/time.h"
5 
6 #include <map>
7 #include <vector>
8 
9 namespace esphome {
10 namespace lcd_base {
11 
12 class LCDDisplay;
13 
14 class LCDDisplay : public PollingComponent {
15  public:
16  void set_dimensions(uint8_t columns, uint8_t rows) {
17  this->columns_ = columns;
18  this->rows_ = rows;
19  }
20 
21  void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
22 
23  void setup() override;
24  float get_setup_priority() const override;
25  void update() override;
26  void display();
28  void clear();
29 
31  void print(uint8_t column, uint8_t row, const char *str);
33  void print(uint8_t column, uint8_t row, const std::string &str);
35  void print(const char *str);
37  void print(const std::string &str);
39  void printf(uint8_t column, uint8_t row, const char *format, ...) __attribute__((format(printf, 4, 5)));
41  void printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
42 
44  void strftime(uint8_t column, uint8_t row, const char *format, ESPTime time) __attribute__((format(strftime, 4, 0)));
46  void strftime(const char *format, ESPTime time) __attribute__((format(strftime, 2, 0)));
47 
49  void loadchar(uint8_t location, uint8_t charmap[]);
50 
51  protected:
52  virtual bool is_four_bit_mode() = 0;
53  virtual void write_n_bits(uint8_t value, uint8_t n) = 0;
54  virtual void send(uint8_t value, bool rs) = 0;
55 
56  void command_(uint8_t value);
57  virtual void call_writer() = 0;
58 
59  uint8_t columns_;
60  uint8_t rows_;
61  uint8_t *buffer_{nullptr};
62  std::map<uint8_t, std::vector<uint8_t> > user_defined_chars_;
63 };
64 
65 } // namespace lcd_base
66 } // namespace esphome
A more user-friendly version of struct tm from time.h.
Definition: time.h:17
virtual void send(uint8_t value, bool rs)=0
void void void void void loadchar(uint8_t location, uint8_t charmap[])
Load custom char to given location.
This class simplifies creating components that periodically check a state.
Definition: component.h:283
virtual void write_n_bits(uint8_t value, uint8_t n)=0
virtual void call_writer()=0
std::map< uint8_t, std::vector< uint8_t > > user_defined_chars_
Definition: lcd_display.h:62
void printf(uint8_t column, uint8_t row, const char *format,...) __attribute__((format(printf
Evaluate the printf-format and print the text at the specified column and row.
enum esphome::EntityCategory __attribute__
void print(uint8_t column, uint8_t row, const char *str)
Print the given text at the specified column and row.
void set_dimensions(uint8_t columns, uint8_t rows)
Definition: lcd_display.h:16
void set_user_defined_char(uint8_t pos, const std::vector< uint8_t > &data)
Definition: lcd_display.h:21
float get_setup_priority() const override
Definition: lcd_display.cpp:90
Implementation of SPI Controller mode.
Definition: a01nyub.cpp:7
virtual bool is_four_bit_mode()=0
void void void strftime(uint8_t column, uint8_t row, const char *format, ESPTime time) __attribute__((format(strftime
Evaluate the strftime-format and print the text at the specified column and row.
void command_(uint8_t value)