ESPHome  2022.6.2
lcd_display.h
Go to the documentation of this file.
1 #pragma once
2 
4 #include "esphome/core/defines.h"
5 
6 #ifdef USE_TIME
8 #endif
9 
10 #include <map>
11 
12 namespace esphome {
13 namespace lcd_base {
14 
15 class LCDDisplay;
16 
17 class LCDDisplay : public PollingComponent {
18  public:
19  void set_dimensions(uint8_t columns, uint8_t rows) {
20  this->columns_ = columns;
21  this->rows_ = rows;
22  }
23 
24  void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
25 
26  void setup() override;
27  float get_setup_priority() const override;
28  void update() override;
29  void display();
31  void clear();
32 
34  void print(uint8_t column, uint8_t row, const char *str);
36  void print(uint8_t column, uint8_t row, const std::string &str);
38  void print(const char *str);
40  void print(const std::string &str);
42  void printf(uint8_t column, uint8_t row, const char *format, ...) __attribute__((format(printf, 4, 5)));
44  void printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
45 
46 #ifdef USE_TIME
47  void strftime(uint8_t column, uint8_t row, const char *format, time::ESPTime time)
49  __attribute__((format(strftime, 4, 0)));
51  void strftime(const char *format, time::ESPTime time) __attribute__((format(strftime, 2, 0)));
52 #endif
53 
55  void loadchar(uint8_t location, uint8_t charmap[]);
56 
57  protected:
58  virtual bool is_four_bit_mode() = 0;
59  virtual void write_n_bits(uint8_t value, uint8_t n) = 0;
60  virtual void send(uint8_t value, bool rs) = 0;
61 
62  void command_(uint8_t value);
63  virtual void call_writer() = 0;
64 
65  uint8_t columns_;
66  uint8_t rows_;
67  uint8_t *buffer_{nullptr};
68  std::map<uint8_t, std::vector<uint8_t> > user_defined_chars_;
69 };
70 
71 } // namespace lcd_base
72 } // namespace esphome
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:266
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:68
A more user-friendly version of struct tm from time.h.
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:19
void void void strftime(uint8_t column, uint8_t row, const char *format, time::ESPTime time) __attribute__((format(strftime
Evaluate the strftime-format and print the text at the specified column and row.
void set_user_defined_char(uint8_t pos, const std::vector< uint8_t > &data)
Definition: lcd_display.h:24
float get_setup_priority() const override
Definition: lcd_display.cpp:90
Definition: a4988.cpp:4
virtual bool is_four_bit_mode()=0
void command_(uint8_t value)