From a117d70c5662528464b6e3ef7dd58bb9fefb4db4 Mon Sep 17 00:00:00 2001 From: SASANO Takayoshi Date: Mon, 24 Feb 2020 17:52:30 +0900 Subject: [PATCH] send CR+LF (command terminator) first at refreshDisplay() Sometimes BOXF (box fill) command at refreshDisplay() fails. Normally this is not occured, but running MMDVMHost for long time (about one day) we see this problem. The reason is unknown. But if LCD panel receives garbage character between calling refreshDisplay(), first command (BOXF) at latter-called refresDdisplay() will fail. For workaround, send CR+LF command terminator first at this function. --- TFTSurenoo.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/TFTSurenoo.cpp b/TFTSurenoo.cpp index 73972c7..6f253cc 100644 --- a/TFTSurenoo.cpp +++ b/TFTSurenoo.cpp @@ -63,7 +63,7 @@ enum LcdColour { #define MODE_CHARS (X_WIDTH / (MODE_FONT_SIZE / 2)) #define STATUS_CHARS (X_WIDTH / (STATUS_FONT_SIZE / 2)) #define STATUS_LINES ((Y_WIDTH - STATUS_MARGIN) / STATUS_FONT_SIZE) -#define statusLine_offset(x) ((STATUS_CHARS + 1) * ((x) + 1)) +#define statusLine_offset(x) ((STATUS_CHARS + 1) * ((x) + 1)) // This module sometimes ignores display command (too busy?), // so supress display refresh @@ -374,6 +374,10 @@ void CTFTSurenoo::refreshDisplay(void) { if (!m_refresh) return; + // send CR+LF to avoid first command is not processed + ::snprintf(m_temp, sizeof(m_temp), STR_CRLF); + m_serial->write((unsigned char*)m_temp, (unsigned int)::strlen(m_temp)); + // clear display ::snprintf(m_temp, sizeof(m_temp), "BOXF(%d,%d,%d,%d,%d);", 0, 0, X_WIDTH - 1, Y_WIDTH - 1, BG_COLOUR);