Added a function to load custom characters in LCD display (#3279)

Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Andrew J.Swan 2022-04-04 02:13:59 +03:00 committed by GitHub
parent 792108686c
commit fd7e861ff5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -167,6 +167,13 @@ void LCDDisplay::strftime(uint8_t column, uint8_t row, const char *format, time:
}
void LCDDisplay::strftime(const char *format, time::ESPTime time) { this->strftime(0, 0, format, time); }
#endif
void LCDDisplay::loadchar(uint8_t location, uint8_t charmap[]) {
location &= 0x7; // we only have 8 locations 0-7
this->command_(LCD_DISPLAY_COMMAND_SET_CGRAM_ADDR | (location << 3));
for (int i = 0; i < 8; i++) {
this->send(charmap[i], true);
}
}
} // namespace lcd_base
} // namespace esphome

View file

@ -51,6 +51,9 @@ class LCDDisplay : public PollingComponent {
void strftime(const char *format, time::ESPTime time) __attribute__((format(strftime, 2, 0)));
#endif
/// Load custom char to given location
void loadchar(uint8_t location, uint8_t charmap[]);
protected:
virtual bool is_four_bit_mode() = 0;
virtual void write_n_bits(uint8_t value, uint8_t n) = 0;