From 440f55634c9faf5c14e54625d0f95e68254e77d4 Mon Sep 17 00:00:00 2001 From: Tony Corbett Date: Wed, 11 May 2016 07:58:05 +0100 Subject: [PATCH 1/4] Add custom chars to HD44780 to further reduce screen usage (and add a little 'je ne sais qoi') --- HD44780.cpp | 99 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 90 insertions(+), 9 deletions(-) diff --git a/HD44780.cpp b/HD44780.cpp index 29e320b..2f4afb6 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -53,6 +53,66 @@ m_dmr(false) assert(cols > 15U); } +unsigned char fmChar[8] = +{ + 0b11100, + 0b10000, + 0b11000, + 0b10000, + 0b00101, + 0b00111, + 0b00101, + 0b00101 +}; + +unsigned char toChar[8] = +{ + 0b11100, + 0b01000, + 0b01000, + 0b01000, + 0b00010, + 0b00101, + 0b00101, + 0b00010 +}; + +unsigned char mChar[8] = +{ + 0b10001, + 0b11011, + 0b10101, + 0b10001, + 0b10001, + 0b00000, + 0b11111, + 0b11111 +}; + +unsigned char dChar[8] = +{ + 0b11110, + 0b10001, + 0b10001, + 0b10001, + 0b11110, + 0b00000, + 0b11111, + 0b11111 +}; + +unsigned char vChar[8] = +{ + 0b10001, + 0b10001, + 0b10001, + 0b01010, + 0b00100, + 0b00000, + 0b11111, + 0b11111 +}; + CHD44780::~CHD44780() { } @@ -84,6 +144,11 @@ bool CHD44780::open() ::lcdDisplay(m_fd, 1); ::lcdCursor(m_fd, 0); ::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); return true; } @@ -172,7 +237,13 @@ void CHD44780::setIdleInt() ::lcdPrintf(m_fd, "%-6s / %u", m_callsign.c_str(), m_dmrid); ::lcdPosition(m_fd, 0, 1); - ::lcdPuts(m_fd, "MMDVM Idle"); +// ::lcdPuts(m_fd, "MMDVM Idle"); + ::lcdPutchar(m_fd, 2); + ::lcdPutchar(m_fd, 2); + ::lcdPutchar(m_fd, 3); + ::lcdPutchar(m_fd, 4); + ::lcdPutchar(m_fd, 2); + ::lcdPuts(m_fd, " Idle"); m_dmr = false; } @@ -195,7 +266,12 @@ void CHD44780::setErrorInt(const char* text) } ::lcdPosition(m_fd, 0, 0); - ::lcdPuts(m_fd, "MMDVM"); +// ::lcdPuts(m_fd, "MMDVM"); + ::lcdPutchar(m_fd, 2); + ::lcdPutchar(m_fd, 2); + ::lcdPutchar(m_fd, 3); + ::lcdPutchar(m_fd, 4); + ::lcdPutchar(m_fd, 2); ::lcdPosition(m_fd, 0, 1); ::lcdPrintf(m_fd, "%s ERROR", text); @@ -219,7 +295,12 @@ void CHD44780::setLockoutInt() } ::lcdPosition(m_fd, 0, 0); - ::lcdPuts(m_fd, "MMDVM"); +// ::lcdPuts(m_fd, "MMDVM"); + ::lcdPutchar(m_fd, 2); + ::lcdPutchar(m_fd, 2); + ::lcdPutchar(m_fd, 3); + ::lcdPutchar(m_fd, 4); + ::lcdPutchar(m_fd, 2); ::lcdPosition(m_fd, 0, 1); ::lcdPuts(m_fd, "Lockout"); @@ -407,15 +488,15 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); } } else { - ::sprintf(buffer, "From: %s", src.c_str()); ::lcdPosition(m_fd, 0, 0); -// ::lcdPrintf(m_fd, "%.*s", m_cols, buffer); - ::lcdPrintf(m_fd, "%-16s", buffer); + ::lcdPutchar(m_fd, 0); + ::sprintf(buffer, " %s", src.c_str()); + ::lcdPrintf(m_fd, "%-14s", buffer); - ::sprintf(buffer, "To : %s%s", group ? "TG" : "", dst.c_str()); ::lcdPosition(m_fd, 0, 1); -// ::lcdPrintf(m_fd, "%.*s", m_cols, buffer); - ::lcdPrintf(m_fd, "%-16s", buffer); + ::lcdPutchar(m_fd, 1); + ::sprintf(buffer, " %s%s", group ? "TG" : "", dst.c_str()); + ::lcdPrintf(m_fd, "%-14s", buffer); } } else if (m_rows == 4U && m_cols == 16U) { #ifdef ADAFRUIT_DISPLAY From db81407f9956b03dce902f6a233c02c875940c8e Mon Sep 17 00:00:00 2001 From: Tony Corbett Date: Wed, 11 May 2016 07:58:05 +0100 Subject: [PATCH 2/4] Add custom chars to HD44780 to further increase available screen Also add a little "je ne sais qoi" as the HD44780 can't do graphics! --- HD44780.cpp | 99 ++++++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 90 insertions(+), 9 deletions(-) diff --git a/HD44780.cpp b/HD44780.cpp index 29e320b..2f4afb6 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -53,6 +53,66 @@ m_dmr(false) assert(cols > 15U); } +unsigned char fmChar[8] = +{ + 0b11100, + 0b10000, + 0b11000, + 0b10000, + 0b00101, + 0b00111, + 0b00101, + 0b00101 +}; + +unsigned char toChar[8] = +{ + 0b11100, + 0b01000, + 0b01000, + 0b01000, + 0b00010, + 0b00101, + 0b00101, + 0b00010 +}; + +unsigned char mChar[8] = +{ + 0b10001, + 0b11011, + 0b10101, + 0b10001, + 0b10001, + 0b00000, + 0b11111, + 0b11111 +}; + +unsigned char dChar[8] = +{ + 0b11110, + 0b10001, + 0b10001, + 0b10001, + 0b11110, + 0b00000, + 0b11111, + 0b11111 +}; + +unsigned char vChar[8] = +{ + 0b10001, + 0b10001, + 0b10001, + 0b01010, + 0b00100, + 0b00000, + 0b11111, + 0b11111 +}; + CHD44780::~CHD44780() { } @@ -84,6 +144,11 @@ bool CHD44780::open() ::lcdDisplay(m_fd, 1); ::lcdCursor(m_fd, 0); ::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); return true; } @@ -172,7 +237,13 @@ void CHD44780::setIdleInt() ::lcdPrintf(m_fd, "%-6s / %u", m_callsign.c_str(), m_dmrid); ::lcdPosition(m_fd, 0, 1); - ::lcdPuts(m_fd, "MMDVM Idle"); +// ::lcdPuts(m_fd, "MMDVM Idle"); + ::lcdPutchar(m_fd, 2); + ::lcdPutchar(m_fd, 2); + ::lcdPutchar(m_fd, 3); + ::lcdPutchar(m_fd, 4); + ::lcdPutchar(m_fd, 2); + ::lcdPuts(m_fd, " Idle"); m_dmr = false; } @@ -195,7 +266,12 @@ void CHD44780::setErrorInt(const char* text) } ::lcdPosition(m_fd, 0, 0); - ::lcdPuts(m_fd, "MMDVM"); +// ::lcdPuts(m_fd, "MMDVM"); + ::lcdPutchar(m_fd, 2); + ::lcdPutchar(m_fd, 2); + ::lcdPutchar(m_fd, 3); + ::lcdPutchar(m_fd, 4); + ::lcdPutchar(m_fd, 2); ::lcdPosition(m_fd, 0, 1); ::lcdPrintf(m_fd, "%s ERROR", text); @@ -219,7 +295,12 @@ void CHD44780::setLockoutInt() } ::lcdPosition(m_fd, 0, 0); - ::lcdPuts(m_fd, "MMDVM"); +// ::lcdPuts(m_fd, "MMDVM"); + ::lcdPutchar(m_fd, 2); + ::lcdPutchar(m_fd, 2); + ::lcdPutchar(m_fd, 3); + ::lcdPutchar(m_fd, 4); + ::lcdPutchar(m_fd, 2); ::lcdPosition(m_fd, 0, 1); ::lcdPuts(m_fd, "Lockout"); @@ -407,15 +488,15 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); } } else { - ::sprintf(buffer, "From: %s", src.c_str()); ::lcdPosition(m_fd, 0, 0); -// ::lcdPrintf(m_fd, "%.*s", m_cols, buffer); - ::lcdPrintf(m_fd, "%-16s", buffer); + ::lcdPutchar(m_fd, 0); + ::sprintf(buffer, " %s", src.c_str()); + ::lcdPrintf(m_fd, "%-14s", buffer); - ::sprintf(buffer, "To : %s%s", group ? "TG" : "", dst.c_str()); ::lcdPosition(m_fd, 0, 1); -// ::lcdPrintf(m_fd, "%.*s", m_cols, buffer); - ::lcdPrintf(m_fd, "%-16s", buffer); + ::lcdPutchar(m_fd, 1); + ::sprintf(buffer, " %s%s", group ? "TG" : "", dst.c_str()); + ::lcdPrintf(m_fd, "%-14s", buffer); } } else if (m_rows == 4U && m_cols == 16U) { #ifdef ADAFRUIT_DISPLAY From bcdc2fc1c458bb3bbf720c43e2b57ec79e5e8b31 Mon Sep 17 00:00:00 2001 From: Tony Corbett Date: Wed, 11 May 2016 09:10:48 +0100 Subject: [PATCH 3/4] Add more custom chars for type (rf or ip) and use them --- HD44780.cpp | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/HD44780.cpp b/HD44780.cpp index 2f4afb6..2f5609b 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -113,6 +113,30 @@ unsigned char vChar[8] = 0b11111 }; +unsigned char rfChar[8] = +{ + 0b11100, + 0b10100, + 0b11000, + 0b10100, + 0b00111, + 0b00100, + 0b00110, + 0b00100 +}; + +unsigned char ipChar[8] = +{ + 0b01000, + 0b01000, + 0b01000, + 0b01000, + 0b00110, + 0b00101, + 0b00110, + 0b00100 +}; + CHD44780::~CHD44780() { } @@ -149,6 +173,8 @@ bool CHD44780::open() ::lcdCharDef(m_fd, 2, mChar); ::lcdCharDef(m_fd, 3, dChar); ::lcdCharDef(m_fd, 4, vChar); + ::lcdCharDef(m_fd, 5, rfChar); + ::lcdCharDef(m_fd, 6, ipChar); return true; } @@ -237,7 +263,6 @@ void CHD44780::setIdleInt() ::lcdPrintf(m_fd, "%-6s / %u", m_callsign.c_str(), m_dmrid); ::lcdPosition(m_fd, 0, 1); -// ::lcdPuts(m_fd, "MMDVM Idle"); ::lcdPutchar(m_fd, 2); ::lcdPutchar(m_fd, 2); ::lcdPutchar(m_fd, 3); @@ -266,7 +291,6 @@ void CHD44780::setErrorInt(const char* text) } ::lcdPosition(m_fd, 0, 0); -// ::lcdPuts(m_fd, "MMDVM"); ::lcdPutchar(m_fd, 2); ::lcdPutchar(m_fd, 2); ::lcdPutchar(m_fd, 3); @@ -295,7 +319,6 @@ void CHD44780::setLockoutInt() } ::lcdPosition(m_fd, 0, 0); -// ::lcdPuts(m_fd, "MMDVM"); ::lcdPutchar(m_fd, 2); ::lcdPutchar(m_fd, 2); ::lcdPutchar(m_fd, 3); @@ -435,7 +458,6 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro ::lcdPosition(m_fd, 0, 0); ::lcdPuts(m_fd, "DMR "); ::lcdPosition(m_fd, 0, 1); -// ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING); ::lcdPrintf(m_fd, "%-16s", "Listening"); } } else if (m_rows == 4U && m_cols == 16U) { @@ -471,11 +493,12 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro } } - if (m_rows == 2U && m_cols == 16U) { + #ifdef ADAFRUIT_DISPLAY adafruitLCDColour(AC_RED); #endif + if (m_rows == 2U && m_cols == 16U) { char buffer[16U]; if (m_duplex) { if (slotNo == 1U) { @@ -492,17 +515,15 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro ::lcdPutchar(m_fd, 0); ::sprintf(buffer, " %s", src.c_str()); ::lcdPrintf(m_fd, "%-14s", buffer); + ::lcdPutchar(m_fd, strcmp(type, "R") == 0 ? 5 : 6); ::lcdPosition(m_fd, 0, 1); ::lcdPutchar(m_fd, 1); ::sprintf(buffer, " %s%s", group ? "TG" : "", dst.c_str()); ::lcdPrintf(m_fd, "%-14s", buffer); + ::lcdPutchar(m_fd, strcmp(type, "R") == 0 ? 5 : 6); } } else if (m_rows == 4U && m_cols == 16U) { -#ifdef ADAFRUIT_DISPLAY - adafruitLCDColour(AC_RED); -#endif - char buffer[16U]; if (slotNo == 1U) { ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); @@ -514,10 +535,6 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); } } else if (m_rows == 4U && m_cols == 20U) { -#ifdef ADAFRUIT_DISPLAY - adafruitLCDColour(AC_RED); -#endif - char buffer[20U]; if (slotNo == 1U) { ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); @@ -529,10 +546,6 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); } } else if (m_rows == 2U && m_cols == 40U) { -#ifdef ADAFRUIT_DISPLAY - adafruitLCDColour(AC_RED); -#endif - char buffer[40U]; if (slotNo == 1U) { ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); From db77c34fcd9136d6f81e1abc69f72e9637fddf18 Mon Sep 17 00:00:00 2001 From: Tony Corbett Date: Wed, 11 May 2016 09:29:30 +0100 Subject: [PATCH 4/4] Added HD44780 todo list --- HD44780.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 HD44780.md diff --git a/HD44780.md b/HD44780.md new file mode 100644 index 0000000..37d31c6 --- /dev/null +++ b/HD44780.md @@ -0,0 +1,18 @@ +G0WFV's HD44780 todo list ... + +As I only have a 2x16 screen at the moment, development has been done based +on this size screen. + +Some additions I can translate to the other size screens without connecting +the physical screen (and I will do eventually once I get the code working +for the 2x16!) I am however getting some 4x16 screens to play with so +expect more reliable progress in this area! + +Here's a list of things I need to accomplish in the near future ... + +- Propagate non-duplex (DVMega) screen usage changes to other size screens + as appropriate. + +- Propagate custom characters for rf and ip sources to other screens + Currently only states "R" or "N" for RF or network traffic, which is nice + but there are now custom characters for this!