From 31ff76427c8629e6727063538b510e0e05d41649 Mon Sep 17 00:00:00 2001 From: amishv <41266094+amishv@users.noreply.github.com> Date: Mon, 21 Oct 2019 16:13:28 +0530 Subject: [PATCH] Implementation of LCD Clear (#781) * Implementation of LCD Clear * Implementation of LCD Clear * Implementation of LCD Clear * Implementation of LCD Clear --- esphome/components/lcd_base/lcd_display.cpp | 5 +++++ esphome/components/lcd_base/lcd_display.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/esphome/components/lcd_base/lcd_display.cpp b/esphome/components/lcd_base/lcd_display.cpp index 51541049b1..25ac143817 100644 --- a/esphome/components/lcd_base/lcd_display.cpp +++ b/esphome/components/lcd_base/lcd_display.cpp @@ -148,6 +148,11 @@ void LCDDisplay::printf(const char *format, ...) { if (ret > 0) this->print(0, 0, buffer); } +void LCDDisplay::clear() { + // clear display, also sets DDRAM address to 0 (home) + this->command_(LCD_DISPLAY_COMMAND_CLEAR_DISPLAY); + delay(2); +} #ifdef USE_TIME void LCDDisplay::strftime(uint8_t column, uint8_t row, const char *format, time::ESPTime time) { char buffer[64]; diff --git a/esphome/components/lcd_base/lcd_display.h b/esphome/components/lcd_base/lcd_display.h index 791f31ace3..ee150059c6 100644 --- a/esphome/components/lcd_base/lcd_display.h +++ b/esphome/components/lcd_base/lcd_display.h @@ -23,6 +23,8 @@ class LCDDisplay : public PollingComponent { float get_setup_priority() const override; void update() override; void display(); + //// Clear LCD display + void clear(); /// Print the given text at the specified column and row. void print(uint8_t column, uint8_t row, const char *str);