8static const char *
const TAG =
"lcd";
11static const uint8_t LCD_DISPLAY_COMMAND_CLEAR_DISPLAY = 0x01;
12static const uint8_t LCD_DISPLAY_COMMAND_RETURN_HOME = 0x02;
13static const uint8_t LCD_DISPLAY_COMMAND_ENTRY_MODE_SET = 0x04;
14static const uint8_t LCD_DISPLAY_COMMAND_DISPLAY_CONTROL = 0x08;
15static const uint8_t LCD_DISPLAY_COMMAND_CURSOR_SHIFT = 0x10;
16static const uint8_t LCD_DISPLAY_COMMAND_FUNCTION_SET = 0x20;
17static const uint8_t LCD_DISPLAY_COMMAND_SET_CGRAM_ADDR = 0x40;
18static const uint8_t LCD_DISPLAY_COMMAND_SET_DDRAM_ADDR = 0x80;
20static const uint8_t LCD_DISPLAY_ENTRY_SHIFT_INCREMENT = 0x01;
21static const uint8_t LCD_DISPLAY_ENTRY_LEFT = 0x02;
23static const uint8_t LCD_DISPLAY_DISPLAY_BLINK_ON = 0x01;
24static const uint8_t LCD_DISPLAY_DISPLAY_CURSOR_ON = 0x02;
25static const uint8_t LCD_DISPLAY_DISPLAY_ON = 0x04;
27static const uint8_t LCD_DISPLAY_FUNCTION_8_BIT_MODE = 0x10;
28static const uint8_t LCD_DISPLAY_FUNCTION_2_LINE = 0x08;
29static const uint8_t LCD_DISPLAY_FUNCTION_5X10_DOTS = 0x04;
36 uint8_t display_function = 0;
39 display_function |= LCD_DISPLAY_FUNCTION_8_BIT_MODE;
42 display_function |= LCD_DISPLAY_FUNCTION_2_LINE;
60 this->
command_(LCD_DISPLAY_COMMAND_FUNCTION_SET | display_function);
62 this->
command_(LCD_DISPLAY_COMMAND_FUNCTION_SET | display_function);
64 this->
command_(LCD_DISPLAY_COMMAND_FUNCTION_SET | display_function);
69 this->
command_(LCD_DISPLAY_COMMAND_SET_CGRAM_ADDR | (user_defined_char.first << 3));
70 for (
auto data : user_defined_char.second)
71 this->
send(data,
true);
74 this->
command_(LCD_DISPLAY_COMMAND_FUNCTION_SET | display_function);
75 uint8_t display_control = LCD_DISPLAY_DISPLAY_ON;
76 this->
command_(LCD_DISPLAY_COMMAND_DISPLAY_CONTROL | display_control);
79 this->
command_(LCD_DISPLAY_COMMAND_CLEAR_DISPLAY);
82 uint8_t entry_mode = LCD_DISPLAY_ENTRY_LEFT;
83 this->
command_(LCD_DISPLAY_COMMAND_ENTRY_MODE_SET | entry_mode);
85 this->
command_(LCD_DISPLAY_COMMAND_RETURN_HOME);
91 this->
command_(LCD_DISPLAY_COMMAND_SET_DDRAM_ADDR | 0);
93 for (uint8_t i = 0; i < this->
columns_; i++)
96 if (this->
rows_ >= 3) {
97 for (uint8_t i = 0; i < this->
columns_; i++)
98 this->
send(this->
buffer_[this->columns_ * 2 + i],
true);
101 if (this->
rows_ >= 2) {
102 this->
command_(LCD_DISPLAY_COMMAND_SET_DDRAM_ADDR | 0x40);
104 for (uint8_t i = 0; i < this->
columns_; i++)
105 this->
send(this->
buffer_[this->columns_ + i],
true);
107 if (this->
rows_ >= 4) {
108 for (uint8_t i = 0; i < this->
columns_; i++)
109 this->
send(this->
buffer_[this->columns_ * 3 + i],
true);
121 for (; *str !=
'\0'; str++) {
126 if (
pos >= this->
rows_ * this->columns_) {
127 ESP_LOGW(TAG,
"LCDDisplay writing out of range!");
131 this->
buffer_[
pos] = *
reinterpret_cast<const uint8_t *
>(str);
142 int ret = vsnprintf(buffer,
sizeof(buffer),
format, arg);
145 this->
print(column, row, buffer);
151 int ret = vsnprintf(buffer,
sizeof(buffer),
format, arg);
154 this->
print(0, 0, buffer);
164 this->
print(column, row, buffer);
169 this->
command_(LCD_DISPLAY_COMMAND_SET_CGRAM_ADDR | (location << 3));
170 for (
int i = 0; i < 8; i++) {
171 this->
send(charmap[i],
true);
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.
std::map< uint8_t, std::vector< uint8_t > > user_defined_chars_
void command_(uint8_t value)
virtual void write_n_bits(uint8_t value, uint8_t n)=0
virtual void send(uint8_t value, bool rs)=0
void print(uint8_t column, uint8_t row, const char *str)
Print the given text at the specified column and row.
virtual void call_writer()=0
float get_setup_priority() const override
void void void void void loadchar(uint8_t location, uint8_t charmap[])
Load custom char to given location.
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.
virtual bool is_four_bit_mode()=0
constexpr float PROCESSOR
For components that use data from sensors like displays.
const char int const __FlashStringHelper * format
void IRAM_ATTR HOT delayMicroseconds(uint32_t us)
size_t size_t const char va_start(args, fmt)
void HOT delay(uint32_t ms)
uint32_t IRAM_ATTR HOT millis()
A more user-friendly version of struct tm from time.h.
size_t strftime(char *buffer, size_t buffer_len, const char *format)
Convert this ESPTime struct to a null-terminated c string buffer as specified by the format argument.