mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 21:44:55 +01:00
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:
parent
792108686c
commit
fd7e861ff5
2 changed files with 10 additions and 0 deletions
|
@ -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); }
|
void LCDDisplay::strftime(const char *format, time::ESPTime time) { this->strftime(0, 0, format, time); }
|
||||||
#endif
|
#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 lcd_base
|
||||||
} // namespace esphome
|
} // namespace esphome
|
||||||
|
|
|
@ -51,6 +51,9 @@ class LCDDisplay : public PollingComponent {
|
||||||
void strftime(const char *format, time::ESPTime time) __attribute__((format(strftime, 2, 0)));
|
void strftime(const char *format, time::ESPTime time) __attribute__((format(strftime, 2, 0)));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/// Load custom char to given location
|
||||||
|
void loadchar(uint8_t location, uint8_t charmap[]);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual bool is_four_bit_mode() = 0;
|
virtual bool is_four_bit_mode() = 0;
|
||||||
virtual void write_n_bits(uint8_t value, uint8_t n) = 0;
|
virtual void write_n_bits(uint8_t value, uint8_t n) = 0;
|
||||||
|
|
Loading…
Reference in a new issue