From 60e82737b98d84f4e0cb04a0b4732eb6aef27b0f Mon Sep 17 00:00:00 2001 From: SASANO Takayoshi Date: Sat, 18 Jan 2020 06:29:49 +0900 Subject: [PATCH] improve refreshing display Display space character with DCV command to clear screen, but this command is very slow. I tested filling whole 160x128 area with 8x16 character by DCV16 command, it took 540msec. This is the worst case, but display refresh period has extended to 600ms for safety. To clear screen, use BOXF command instead. And, reduced issuing DCV command. --- TFTSurenoo.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/TFTSurenoo.cpp b/TFTSurenoo.cpp index d2def43..73972c7 100644 --- a/TFTSurenoo.cpp +++ b/TFTSurenoo.cpp @@ -67,7 +67,7 @@ enum LcdColour { // This module sometimes ignores display command (too busy?), // so supress display refresh -#define REFRESH_PERIOD 250 // msec +#define REFRESH_PERIOD 600 // msec #define STR_CRLF "\x0D\x0A" #define STR_DMR "DMR" @@ -352,8 +352,6 @@ void CTFTSurenoo::setLineBuffer(char *buf, const char *text, int maxchar) for (i = 0; i < maxchar && text[i] != '\0'; i++) buf[i] = text[i]; - for (; i < maxchar; i++) - buf[i] = ' '; buf[i] = '\0'; m_refresh = true; @@ -376,6 +374,11 @@ void CTFTSurenoo::refreshDisplay(void) { if (!m_refresh) return; + // clear display + ::snprintf(m_temp, sizeof(m_temp), "BOXF(%d,%d,%d,%d,%d);", + 0, 0, X_WIDTH - 1, Y_WIDTH - 1, BG_COLOUR); + m_serial->write((unsigned char*)m_temp, ::strlen(m_temp)); + // mode line ::snprintf(m_temp, sizeof(m_temp), "DCV%d(%d,%d,'%s',%d);", MODE_FONT_SIZE, 0, 0, m_lineBuf, MODE_COLOUR); @@ -383,10 +386,13 @@ void CTFTSurenoo::refreshDisplay(void) // status line for (int i = 0; i < STATUS_LINES; i++) { + char *p = m_lineBuf + statusLine_offset(i); + if (!::strlen(p)) continue; + ::snprintf(m_temp, sizeof(m_temp), "DCV%d(%d,%d,'%s',%d);", STATUS_FONT_SIZE, 0, STATUS_MARGIN + STATUS_FONT_SIZE * i, - m_lineBuf + statusLine_offset(i), FG_COLOUR); + p, FG_COLOUR); m_serial->write((unsigned char*)m_temp, (unsigned int)::strlen(m_temp)); }