From c7175f66f5a5dbf7c5f3ce2f1fece2981898c155 Mon Sep 17 00:00:00 2001 From: Tony Corbett G0WFV Date: Sun, 24 Jul 2016 13:49:58 +0100 Subject: [PATCH 1/3] Correct HD44780 custom character behaviour Overwriting a CGRAM location also changes any characters already displayed on the LCD which use that CGRAM location! --- HD44780.cpp | 83 +++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 25 deletions(-) diff --git a/HD44780.cpp b/HD44780.cpp index 6ecd457..8e6af73 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -94,6 +94,7 @@ unsigned char toChar[8] = 0b00010 }; +/* // Custom "M" character used in MMDVM logo unsigned char mChar[8] = { @@ -133,6 +134,8 @@ unsigned char vChar[8] = 0b11111 }; +*/ + // Icon-based custom character for RF traffic unsigned char rfChar[8] = { @@ -222,16 +225,10 @@ bool CHD44780::open() ::lcdCursorBlink(m_fd, 0); ::lcdCharDef(m_fd, 0, fmChar); ::lcdCharDef(m_fd, 1, toChar); - ::lcdCharDef(m_fd, 2, mChar); - ::lcdCharDef(m_fd, 3, dChar); - ::lcdCharDef(m_fd, 4, vChar); - - /* - * TG, private call, RF and network icons defined as needed - ran out of CGRAM locations - * on the HD44780! Theoretically, we now have infinite custom characters to play with, - * just be mindful of the slow speed of CGRAM hence the lcdPosition call to delay just - * long enough so the CGRAM can be written before we try to read it. - */ + ::lcdCharDef(m_fd, 2, rfChar); + ::lcdCharDef(m_fd, 3, ipChar); + ::lcdCharDef(m_fd, 4, privChar); + ::lcdCharDef(m_fd, 5, tgChar); return true; } @@ -357,11 +354,14 @@ void CHD44780::setIdleInt() // Print MMDVM and Idle on bottom row for all screen sizes ::lcdPosition(m_fd, 0, m_rows - 1); + /* ::lcdPutchar(m_fd, 2); ::lcdPutchar(m_fd, 2); ::lcdPutchar(m_fd, 3); ::lcdPutchar(m_fd, 4); ::lcdPutchar(m_fd, 2); + */ + ::lcdPuts(m_fd, "MMDVM"); ::lcdPosition(m_fd, m_cols - 4, m_rows - 1); ::lcdPuts(m_fd, "Idle"); // Gets overwritten by clock on 2 line screen @@ -389,11 +389,14 @@ void CHD44780::setErrorInt(const char* text) } ::lcdPosition(m_fd, 0, 0); + /* ::lcdPutchar(m_fd, 2); ::lcdPutchar(m_fd, 2); ::lcdPutchar(m_fd, 3); ::lcdPutchar(m_fd, 4); ::lcdPutchar(m_fd, 2); + */ + ::lcdPuts(m_fd, "MMDVM"); ::lcdPosition(m_fd, 0, 1); ::lcdPrintf(m_fd, "%s ERROR", text); @@ -420,11 +423,14 @@ void CHD44780::setLockoutInt() } ::lcdPosition(m_fd, 0, 0); + /* ::lcdPutchar(m_fd, 2); ::lcdPutchar(m_fd, 2); ::lcdPutchar(m_fd, 3); ::lcdPutchar(m_fd, 4); ::lcdPutchar(m_fd, 2); + */ + ::lcdPuts(m_fd, "MMDVM"); ::lcdPosition(m_fd, 0, 1); ::lcdPuts(m_fd, "Lockout"); @@ -462,10 +468,13 @@ void CHD44780::writeDStarInt(const char* my1, const char* my2, const char* your, ::lcdPosition(m_fd, 0, (m_rows / 2) - 1); ::lcdPrintf(m_fd, "%.8s/%.4s", my1, my2); - - ::lcdCharDef(m_fd, 5, strcmp(type, "R") == 0 ? rfChar : ipChar); ::lcdPosition(m_fd, m_cols - 1, (m_rows / 2) - 1); - ::lcdPutchar(m_fd, 5); + + if (strcmp(type, "R") == 0) { + ::lcdPutchar(m_fd, 2); + } else { + ::lcdPutchar(m_fd, 3); + } ::sprintf(m_buffer1, "%.8s", your); @@ -573,12 +582,20 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro m_dmrScrollTimer1.start(); } - ::lcdCharDef(m_fd, 6, group ? tgChar : privChar); - ::lcdCharDef(m_fd, 5, strcmp(type, "R") == 0 ? rfChar : ipChar); ::lcdPosition(m_fd, m_cols - 3U, (m_rows / 2) - 1); ::lcdPuts(m_fd, " "); - ::lcdPutchar(m_fd, 6); - ::lcdPutchar(m_fd, 5); + + if (group) { + ::lcdPutchar(m_fd, 5); + } else { + ::lcdPutchar(m_fd, 4); + } + + if (strcmp(type, "R") == 0) { + ::lcdPutchar(m_fd, 2); + } else { + ::lcdPutchar(m_fd, 3); + } } else { ::lcdPosition(m_fd, 0, (m_rows / 2)); ::lcdPuts(m_fd, "2 "); @@ -592,29 +609,45 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro m_dmrScrollTimer2.start(); } - ::lcdCharDef(m_fd, 6, group ? tgChar : privChar); - ::lcdCharDef(m_fd, 5, strcmp(type, "R") == 0 ? rfChar : ipChar); ::lcdPosition(m_fd, m_cols - 3U, (m_rows / 2)); ::lcdPuts(m_fd, " "); - ::lcdPutchar(m_fd, 6); - ::lcdPutchar(m_fd, 5); + + if (group) { + ::lcdPutchar(m_fd, 5); + } else { + ::lcdPutchar(m_fd, 4); + } + + if (strcmp(type, "R") == 0) { + ::lcdPutchar(m_fd, 2); + } else { + ::lcdPutchar(m_fd, 3); + } } } else { ::lcdPosition(m_fd, 0, (m_rows / 2) - 1); ::lcdPutchar(m_fd, 0); ::sprintf(m_buffer2, " %s%s", src.c_str(), DEADSPACE); ::lcdPrintf(m_fd, "%.*s", m_cols - 4U, m_buffer2); - ::lcdCharDef(m_fd, 5, strcmp(type, "R") == 0 ? rfChar : ipChar); ::lcdPosition(m_fd, m_cols - 1U, (m_rows / 2) - 1); - ::lcdPutchar(m_fd, 5); + + if (strcmp(type, "R") == 0) { + ::lcdPutchar(m_fd, 2); + } else { + ::lcdPutchar(m_fd, 3); + } ::lcdPosition(m_fd, 0, (m_rows / 2)); ::lcdPutchar(m_fd, 1); ::sprintf(m_buffer2, " %s%s%s", group ? "TG" : "", dst.c_str(), DEADSPACE); ::lcdPrintf(m_fd, "%.*s", m_cols - 4U, m_buffer2); - ::lcdCharDef(m_fd, 6, group ? tgChar : privChar); ::lcdPosition(m_fd, m_cols - 1U, (m_rows / 2)); - ::lcdPutchar(m_fd, 6); + + if (group) { + ::lcdPutchar(m_fd, 5); + } else { + ::lcdPutchar(m_fd, 4); + } } m_dmr = true; } From 331a34757c66e18bc6c77f39c0d71daa5420cb67 Mon Sep 17 00:00:00 2001 From: Tony Corbett G0WFV Date: Sun, 24 Jul 2016 19:36:55 +0100 Subject: [PATCH 2/3] Fix some more display bugs --- HD44780.cpp | 67 ++--------------------------------------------------- 1 file changed, 2 insertions(+), 65 deletions(-) diff --git a/HD44780.cpp b/HD44780.cpp index 8e6af73..529a57b 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -94,48 +94,6 @@ unsigned char toChar[8] = 0b00010 }; -/* -// Custom "M" character used in MMDVM logo -unsigned char mChar[8] = -{ - 0b10001, - 0b11011, - 0b10101, - 0b10001, - 0b10001, - 0b00000, - 0b11111, - 0b11111 -}; - -// Custom "D" character used in MMDVM logo -unsigned char dChar[8] = -{ - 0b11110, - 0b10001, - 0b10001, - 0b10001, - 0b11110, - 0b00000, - 0b11111, - 0b11111 -}; - -// Custom "V" character used in MMDVM logo -unsigned char vChar[8] = -{ - 0b10001, - 0b10001, - 0b10001, - 0b01010, - 0b00100, - 0b00000, - 0b11111, - 0b11111 -}; - -*/ - // Icon-based custom character for RF traffic unsigned char rfChar[8] = { @@ -354,13 +312,6 @@ void CHD44780::setIdleInt() // Print MMDVM and Idle on bottom row for all screen sizes ::lcdPosition(m_fd, 0, m_rows - 1); - /* - ::lcdPutchar(m_fd, 2); - ::lcdPutchar(m_fd, 2); - ::lcdPutchar(m_fd, 3); - ::lcdPutchar(m_fd, 4); - ::lcdPutchar(m_fd, 2); - */ ::lcdPuts(m_fd, "MMDVM"); ::lcdPosition(m_fd, m_cols - 4, m_rows - 1); ::lcdPuts(m_fd, "Idle"); // Gets overwritten by clock on 2 line screen @@ -389,13 +340,6 @@ void CHD44780::setErrorInt(const char* text) } ::lcdPosition(m_fd, 0, 0); - /* - ::lcdPutchar(m_fd, 2); - ::lcdPutchar(m_fd, 2); - ::lcdPutchar(m_fd, 3); - ::lcdPutchar(m_fd, 4); - ::lcdPutchar(m_fd, 2); - */ ::lcdPuts(m_fd, "MMDVM"); ::lcdPosition(m_fd, 0, 1); @@ -423,13 +367,6 @@ void CHD44780::setLockoutInt() } ::lcdPosition(m_fd, 0, 0); - /* - ::lcdPutchar(m_fd, 2); - ::lcdPutchar(m_fd, 2); - ::lcdPutchar(m_fd, 3); - ::lcdPutchar(m_fd, 4); - ::lcdPutchar(m_fd, 2); - */ ::lcdPuts(m_fd, "MMDVM"); ::lcdPosition(m_fd, 0, 1); @@ -663,11 +600,11 @@ void CHD44780::clearDMRInt(unsigned int slotNo) if (m_duplex) { if (slotNo == 1U) { m_dmrScrollTimer1.stop(); // Stop the scroll timer on slot 1 - ::lcdPosition(m_fd, 0, 0); + ::lcdPosition(m_fd, 0, (m_rows / 2) - 1); ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); } else { m_dmrScrollTimer2.stop(); // Stop the scroll timer on slot 2 - ::lcdPosition(m_fd, 0, 1); + ::lcdPosition(m_fd, 0, (m_rows / 2)); ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); } } else { From 0baebe3a99b761987967c2da4379b1967166eccb Mon Sep 17 00:00:00 2001 From: Tony Corbett G0WFV Date: Sun, 24 Jul 2016 20:14:07 +0100 Subject: [PATCH 3/3] Add forgotten DMR on top line of LCDs --- HD44780.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/HD44780.cpp b/HD44780.cpp index 529a57b..0af603e 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -493,6 +493,13 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro } } else { m_dmrScrollTimer2.stop(); + + if (m_rows > 2U) { + ::lcdPosition(m_fd, 0, (m_rows / 2) - 2); + ::sprintf(m_buffer1, "%s", DEADSPACE); + ::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1); + } + ::lcdPosition(m_fd, 0, (m_rows / 2) - 1); ::sprintf(m_buffer1, "%s%s", "DMR", DEADSPACE); ::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1); @@ -506,6 +513,12 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro #endif if (m_duplex) { + if (m_rows > 2U) { + ::lcdPosition(m_fd, 0, (m_rows / 2) - 2); + ::sprintf(m_buffer1, "%s%s", "DMR", DEADSPACE); + ::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1); + } + if (slotNo == 1U) { ::lcdPosition(m_fd, 0, (m_rows / 2) - 1); ::lcdPuts(m_fd, "1 "); @@ -562,6 +575,12 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro } } } else { + if (m_rows > 2U) { + ::lcdPosition(m_fd, 0, (m_rows / 2) - 2); + ::sprintf(m_buffer1, "%s%s", "DMR", DEADSPACE); + ::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1); + } + ::lcdPosition(m_fd, 0, (m_rows / 2) - 1); ::lcdPutchar(m_fd, 0); ::sprintf(m_buffer2, " %s%s", src.c_str(), DEADSPACE); @@ -609,6 +628,13 @@ void CHD44780::clearDMRInt(unsigned int slotNo) } } else { m_dmrScrollTimer2.stop(); // Stop the scroll timer on slot 2 + + if (m_rows > 2U) { + ::lcdPosition(m_fd, 0, (m_rows / 2) - 2); + ::sprintf(m_buffer1, "%s", DEADSPACE); + ::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1); + } + ::lcdPosition(m_fd, 0, (m_rows / 2) - 1); ::sprintf(m_buffer2, "%s%s", "DMR", DEADSPACE); ::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer2);