ESPHome  2022.12.8
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 #include <vector>
12 
13 namespace esphome {
14 namespace lcd_base {
15 
16 class LCDDisplay;
17 
18 class LCDDisplay : public PollingComponent {
19  public:
20  void set_dimensions(uint8_t columns, uint8_t rows) {
21  this->columns_ = columns;
22  this->rows_ = rows;
23  }
24 
25  void set_user_defined_char(uint8_t pos, const std::vector<uint8_t> &data) { this->user_defined_chars_[pos] = data; }
26 
27  void setup() override;
28  float get_setup_priority() const override;
29  void update() override;
30  void display();
32  void clear();
33 
35  void print(uint8_t column, uint8_t row, const char *str);
37  void print(uint8_t column, uint8_t row, const std::string &str);
39  void print(const char *str);
41  void print(const std::string &str);
43  void printf(uint8_t column, uint8_t row, const char *format, ...) __attribute__((format(printf, 4, 5)));
45  void printf(const char *format, ...) __attribute__((format(printf, 2, 3)));
46 
47 #ifdef USE_TIME
48  void strftime(uint8_t column, uint8_t row, const char *format, time::ESPTime time)
50  __attribute__((format(strftime, 4, 0)));
52  void strftime(const char *format, time::ESPTime time) __attribute__((format(strftime, 2, 0)));
53 #endif
54 
56  void loadchar(uint8_t location, uint8_t charmap[]);
57 
58  protected:
59  virtual bool is_four_bit_mode() = 0;
60  virtual void write_n_bits(uint8_t value, uint8_t n) = 0;
61  virtual void send(uint8_t value, bool rs) = 0;
62 
63  void command_(uint8_t value);
64  virtual void call_writer() = 0;
65 
66  uint8_t columns_;
67  uint8_t rows_;
68  uint8_t *buffer_{nullptr};
69  std::map<uint8_t, std::vector<uint8_t> > user_defined_chars_;
70 };
71 
72 } // namespace lcd_base
73 } // 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:267
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:69
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:20
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:25
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)