From ca4d534ff29c939d8bca4f0b470efdd3ff4911e7 Mon Sep 17 00:00:00 2001 From: Tony Corbett Date: Wed, 11 May 2016 21:14:17 +0100 Subject: [PATCH 1/8] Code restructure to allow for something to come ... --- HD44780.cpp | 107 ++++++++++++++++++++++++++-------------------------- 1 file changed, 53 insertions(+), 54 deletions(-) diff --git a/HD44780.cpp b/HD44780.cpp index 2482031..e4eca93 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -569,10 +569,10 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro adafruitLCDColour(AC_RED); #endif - // 2 x 16 - if (m_rows == 2U && m_cols == 16U) { - char buffer[16U]; - if (m_duplex) { + if (m_duplex) { + // 2 x 16 + if (m_rows == 2U && m_cols == 16U) { + char buffer[16U]; if (slotNo == 1U) { ::sprintf(buffer, "%s >%s%s", src.c_str(), group ? "TG" : "", dst.c_str()); ::lcdPosition(m_fd, 0, 0); @@ -582,59 +582,58 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro ::lcdPosition(m_fd, 0, 1); ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); } - } else { - ::lcdPosition(m_fd, 0, 0); - ::lcdPutchar(m_fd, 0); - ::lcdPrintf(m_fd, " %-12s", src.c_str()); - ::lcdCharDef(m_fd, 5, strcmp(type, "R") == 0 ? rfChar : ipChar); - ::lcdPosition(m_fd, 15, 0); - ::lcdPutchar(m_fd, 5); - + // 4 x 16 + } else if (m_rows == 4U && m_cols == 16U) { + char buffer[16U]; + if (slotNo == 1U) { + ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); ::lcdPosition(m_fd, 0, 1); - ::lcdPutchar(m_fd, 1); - ::lcdPrintf(m_fd, " %-12s", dst.c_str()); - ::lcdCharDef(m_fd, 6, group ? tgChar : privChar); - ::lcdPosition(m_fd, 15, 1); - ::lcdPutchar(m_fd, 6); + ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer); + } else { + ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); + ::lcdPosition(m_fd, 0, 2); + ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); + } + // 4 x 20 + } else if (m_rows == 4U && m_cols == 20U) { + char buffer[20U]; + if (slotNo == 1U) { + ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); + ::lcdPosition(m_fd, 0, 1); + ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer); + } else { + ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); + ::lcdPosition(m_fd, 0, 2); + ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); + } + // 2 x 40 + } else if (m_rows == 2U && m_cols == 40U) { + char buffer[40U]; + if (slotNo == 1U) { + ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); + ::lcdPosition(m_fd, 0, 0); + ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer); + } else { + ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); + ::lcdPosition(m_fd, 0, 1); + ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); + } } - // 4 x 16 - } else if (m_rows == 4U && m_cols == 16U) { - char buffer[16U]; - if (slotNo == 1U) { - ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer); - } else { - ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); - ::lcdPosition(m_fd, 0, 2); - ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); - } - // 4 x 20 - } else if (m_rows == 4U && m_cols == 20U) { - char buffer[20U]; - if (slotNo == 1U) { - ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer); - } else { - ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); - ::lcdPosition(m_fd, 0, 2); - ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); - } - // 2 x 40 - } else if (m_rows == 2U && m_cols == 40U) { - char buffer[40U]; - if (slotNo == 1U) { - ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); - ::lcdPosition(m_fd, 0, 0); - ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer); - } else { - ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); - } - } + } else { + ::lcdPosition(m_fd, 0, m_rows == 2 ? 0 : 1); + ::lcdPutchar(m_fd, 0); + ::lcdPrintf(m_fd, " %-12s", src.c_str()); + ::lcdCharDef(m_fd, 5, strcmp(type, "R") == 0 ? rfChar : ipChar); + ::lcdPosition(m_fd, 15, 0); + ::lcdPutchar(m_fd, 5); + ::lcdPosition(m_fd, 0, m_rows == 2 ? 1 : 2); + ::lcdPutchar(m_fd, 1); + ::lcdPrintf(m_fd, " %-12s", dst.c_str()); + ::lcdCharDef(m_fd, 6, group ? tgChar : privChar); + ::lcdPosition(m_fd, 15, 1); + ::lcdPutchar(m_fd, 6); + } m_dmr = true; } From 127438abbebe9e7f8731fb0c4b6a7cb28fd58224 Mon Sep 17 00:00:00 2001 From: Tony Corbett Date: Wed, 11 May 2016 22:30:06 +0100 Subject: [PATCH 2/8] More restructuring --- HD44780.cpp | 72 ++++++++++++++++++++++++++--------------------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/HD44780.cpp b/HD44780.cpp index e4eca93..b269693 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -517,8 +517,8 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro ::pwmWrite(m_pwmPin, (m_pwmBright / 100) * 1024); } - if (m_rows == 2U && m_cols == 16U) { - if (m_duplex) { + if (m_duplex) { + if (m_rows == 2U && m_cols == 16U) { if (slotNo == 1U) { ::lcdPosition(m_fd, 0, 1); ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); @@ -526,47 +526,47 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro ::lcdPosition(m_fd, 0, 0); ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); } - } else { + } else if (m_rows == 4U && m_cols == 16U) { ::lcdPosition(m_fd, 0, 0); - ::lcdPuts(m_fd, "DMR "); - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "%-16s", "Listening"); - } - } else if (m_rows == 4U && m_cols == 16U) { - ::lcdPosition(m_fd, 0, 0); - ::lcdPuts(m_fd, "DMR"); + ::lcdPuts(m_fd, "DMR"); - if (slotNo == 1U) { - ::lcdPosition(m_fd, 0, 2); - ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); - } else { - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); - } - } else if (m_rows == 4U && m_cols == 20U) { - ::lcdPosition(m_fd, 0, 0); - ::lcdPuts(m_fd, "DMR"); - - if (slotNo == 1U) { - ::lcdPosition(m_fd, 0, 2); - ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); - } else { - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); - } - } else if (m_rows == 2U && m_cols == 40U) { - if (slotNo == 1U) { - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); - } else { + if (slotNo == 1U) { + ::lcdPosition(m_fd, 0, 2); + ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); + } else { + ::lcdPosition(m_fd, 0, 1); + ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); + } + } else if (m_rows == 4U && m_cols == 20U) { ::lcdPosition(m_fd, 0, 0); - ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); - } + ::lcdPuts(m_fd, "DMR"); + + if (slotNo == 1U) { + ::lcdPosition(m_fd, 0, 2); + ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); + } else { + ::lcdPosition(m_fd, 0, 1); + ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); + } + } else if (m_rows == 2U && m_cols == 40U) { + if (slotNo == 1U) { + ::lcdPosition(m_fd, 0, 1); + ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); + } else { + ::lcdPosition(m_fd, 0, 0); + ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); + } + } + } else { + ::lcdPosition(m_fd, 0, 0); + ::lcdPuts(m_fd, "DMR "); + ::lcdPosition(m_fd, 0, 1); + ::lcdPrintf(m_fd, "%-16s", "Listening"); } } #ifdef ADAFRUIT_DISPLAY - adafruitLCDColour(AC_RED); + adafruitLCDColour(AC_RED); #endif if (m_duplex) { From 74eb55ae7ea58fc584895cf9d46187cf99573c73 Mon Sep 17 00:00:00 2001 From: Tony Corbett Date: Thu, 12 May 2016 09:53:42 +0100 Subject: [PATCH 3/8] Major restructure of writeDMRInt / clearDMRInt --- HD44780.cpp | 252 ++++++++++++++++------------------------------------ 1 file changed, 76 insertions(+), 176 deletions(-) diff --git a/HD44780.cpp b/HD44780.cpp index b269693..773f96c 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -22,12 +22,14 @@ #include #include #include +#include #include #include #include const char* LISTENING = "Listening "; +const char* DEADSPACE = " "; CHD44780::CHD44780(unsigned int rows, unsigned int cols, const std::string& callsign, unsigned int dmrid, const std::vector& pins, bool pwm, unsigned int pwmPin, unsigned int pwmBright, unsigned int pwmDim, bool duplex) : CDisplay(), @@ -45,7 +47,8 @@ m_pwm(pwm), m_pwmPin(pwmPin), m_pwmBright(pwmBright), m_pwmDim(pwmDim), -m_duplex(duplex), +//m_duplex(duplex), +m_duplex(true), m_fd(-1), m_dmr(false) { @@ -53,6 +56,7 @@ m_dmr(false) assert(cols > 15U); } +// Text-based custom character for "from" unsigned char fmChar[8] = { 0b11100, @@ -65,6 +69,7 @@ unsigned char fmChar[8] = 0b00101 }; +// Text-based custom character for "to" unsigned char toChar[8] = { 0b11100, @@ -77,6 +82,7 @@ unsigned char toChar[8] = 0b00010 }; +// Custom "M" character used in MMDVM logo unsigned char mChar[8] = { 0b10001, @@ -89,6 +95,7 @@ unsigned char mChar[8] = 0b11111 }; +// Custom "D" character used in MMDVM logo unsigned char dChar[8] = { 0b11110, @@ -101,6 +108,7 @@ unsigned char dChar[8] = 0b11111 }; +// Custom "V" character used in MMDVM logo unsigned char vChar[8] = { 0b10001, @@ -113,19 +121,6 @@ unsigned char vChar[8] = 0b11111 }; -// Text-based custom character for RF traffic -/* unsigned char rfChar[8] = -{ - 0b11100, - 0b10100, - 0b11000, - 0b10100, - 0b00111, - 0b00100, - 0b00110, - 0b00100 -}; */ - // Icon-based custom character for RF traffic unsigned char rfChar[8] = { @@ -135,63 +130,37 @@ unsigned char rfChar[8] = 0b00100, 0b00100, 0b00100, - 0b00000, + 0b00100, 0b00000 }; -// Text-based custom character for network traffic -/* unsigned char ipChar[8] = -{ - 0b01000, - 0b01000, - 0b01000, - 0b01000, - 0b00110, - 0b00101, - 0b00110, - 0b00100 -}; */ - // Icon-based custom character for network traffic unsigned char ipChar[8] = { + 0b00000, 0b01110, 0b10001, 0b00100, 0b01010, 0b00000, 0b00100, - 0b00000, 0b00000 }; -// Text-based custom character for talkgroup -/* unsigned char tgChar[8] = -{ - 0b11100, - 0b01000, - 0b01000, - 0b01000, - 0b00011, - 0b00100, - 0b00101, - 0b00111 -}; */ - -// Icon-based custom character for talkgroup +// Icon-based custom character for call to talkgroup unsigned char tgChar[8] = { 0b01110, 0b10001, 0b10001, 0b10001, - 0b01101, - 0b00110, - 0b11000, + 0b01010, + 0b01100, + 0b10000, 0b00000 }; -// Icon-based custom character for personal contact +// Icon-based custom character for private call unsigned char privChar[8] = { 0b00100, @@ -501,6 +470,7 @@ void CHD44780::clearDStarInt() void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) { + char buffer[128]; // force 128 char buffer - we're never getting that far but stops us overflowing it! assert(type != NULL); if (!m_dmr) { @@ -518,50 +488,25 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro } if (m_duplex) { - if (m_rows == 2U && m_cols == 16U) { - if (slotNo == 1U) { - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); - } else { - ::lcdPosition(m_fd, 0, 0); - ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); - } - } else if (m_rows == 4U && m_cols == 16U) { - ::lcdPosition(m_fd, 0, 0); - ::lcdPuts(m_fd, "DMR"); + if (m_rows > 2U) { + ::lcdPosition(m_fd, 0, (m_rows / 2) - 2); + ::sprintf(buffer, "%s%s", buffer, DEADSPACE); + ::lcdPrintf(m_fd, "%.*s", m_cols, buffer); + } - if (slotNo == 1U) { - ::lcdPosition(m_fd, 0, 2); - ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); - } else { - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); - } - } else if (m_rows == 4U && m_cols == 20U) { - ::lcdPosition(m_fd, 0, 0); - ::lcdPuts(m_fd, "DMR"); - - if (slotNo == 1U) { - ::lcdPosition(m_fd, 0, 2); - ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); - } else { - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); - } - } else if (m_rows == 2U && m_cols == 40U) { - if (slotNo == 1U) { - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); - } else { - ::lcdPosition(m_fd, 0, 0); - ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); - } - } + if (slotNo == 1U) { + ::lcdPosition(m_fd, 0, (m_rows / 2)); + ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); + } else { + ::lcdPosition(m_fd, 0, (m_rows / 2) - 1); + ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); + } } else { - ::lcdPosition(m_fd, 0, 0); - ::lcdPuts(m_fd, "DMR "); - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "%-16s", "Listening"); + ::lcdPosition(m_fd, 0, (m_rows / 2) - 1); + ::sprintf(buffer, "%s%s", "DMR", DEADSPACE); + ::lcdPrintf(m_fd, "%.*s", m_cols, buffer); + ::lcdPosition(m_fd, 0, (m_rows / 2)); + ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING); } } @@ -570,68 +515,42 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro #endif if (m_duplex) { - // 2 x 16 - if (m_rows == 2U && m_cols == 16U) { - char buffer[16U]; - if (slotNo == 1U) { - ::sprintf(buffer, "%s >%s%s", src.c_str(), group ? "TG" : "", dst.c_str()); - ::lcdPosition(m_fd, 0, 0); - ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer); - } else { - ::sprintf(buffer, "%s >%s%s", src.c_str(), group ? "TG" : "", dst.c_str()); - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); - } - // 4 x 16 - } else if (m_rows == 4U && m_cols == 16U) { - char buffer[16U]; - if (slotNo == 1U) { - ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer); - } else { - ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); - ::lcdPosition(m_fd, 0, 2); - ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); - } - // 4 x 20 - } else if (m_rows == 4U && m_cols == 20U) { - char buffer[20U]; - if (slotNo == 1U) { - ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer); - } else { - ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); - ::lcdPosition(m_fd, 0, 2); - ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); - } - // 2 x 40 - } else if (m_rows == 2U && m_cols == 40U) { - char buffer[40U]; - if (slotNo == 1U) { - ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); - ::lcdPosition(m_fd, 0, 0); - ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, buffer); - } else { - ::sprintf(buffer, "%s %s > %s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); - } + if (slotNo == 1U) { + ::lcdPosition(m_fd, 0, (m_rows / 2) - 1); + ::lcdPuts(m_fd, "1"); + ::sprintf(buffer, " %s > %s%s", src.c_str(), dst.c_str(), DEADSPACE); + ::lcdPrintf(m_fd, "%.*s", m_cols - 4U, buffer); + ::lcdCharDef(m_fd, 6, group ? tgChar : privChar); + ::lcdCharDef(m_fd, 5, strcmp(type, "R") == 0 ? rfChar : ipChar); + ::lcdPosition(m_fd, m_cols - 2U, (m_rows / 2) - 1); + ::lcdPutchar(m_fd, 6); + ::lcdPutchar(m_fd, 5); + } else { + ::lcdPosition(m_fd, 0, (m_rows / 2)); + ::lcdPuts(m_fd, "2"); + ::sprintf(buffer, " %s > %s%s", src.c_str(), dst.c_str(), DEADSPACE); + ::lcdPrintf(m_fd, "%.*s", m_cols - 4U, buffer); + ::lcdCharDef(m_fd, 6, group ? tgChar : privChar); + ::lcdCharDef(m_fd, 5, strcmp(type, "R") == 0 ? rfChar : ipChar); + ::lcdPosition(m_fd, m_cols - 2U, (m_rows / 2)); + ::lcdPutchar(m_fd, 6); + ::lcdPutchar(m_fd, 5); } } else { - ::lcdPosition(m_fd, 0, m_rows == 2 ? 0 : 1); + ::lcdPosition(m_fd, 0, (m_rows / 2) - 1); ::lcdPutchar(m_fd, 0); - ::lcdPrintf(m_fd, " %-12s", src.c_str()); + ::sprintf(buffer, " %s%s", src.c_str(), DEADSPACE); + ::lcdPrintf(m_fd, "%.*s", m_cols - 4U, buffer); ::lcdCharDef(m_fd, 5, strcmp(type, "R") == 0 ? rfChar : ipChar); - ::lcdPosition(m_fd, 15, 0); + ::lcdPosition(m_fd, m_cols - 1U, (m_rows / 2) - 1); ::lcdPutchar(m_fd, 5); - ::lcdPosition(m_fd, 0, m_rows == 2 ? 1 : 2); + ::lcdPosition(m_fd, 0, (m_rows / 2)); ::lcdPutchar(m_fd, 1); - ::lcdPrintf(m_fd, " %-12s", dst.c_str()); + ::sprintf(buffer, " %s%s", dst.c_str(), DEADSPACE); + ::lcdPrintf(m_fd, "%.*s", m_cols - 4U, buffer); ::lcdCharDef(m_fd, 6, group ? tgChar : privChar); - ::lcdPosition(m_fd, 15, 1); + ::lcdPosition(m_fd, m_cols - 1U, (m_rows / 2)); ::lcdPutchar(m_fd, 6); } m_dmr = true; @@ -639,43 +558,13 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro void CHD44780::clearDMRInt(unsigned int slotNo) { + char buffer[128]; // force 128 char buffer - we're never getting that far but stops us overflowing it! + #ifdef ADAFRUIT_DISPLAY adafruitLCDColour(AC_PURPLE); #endif - if (m_rows == 2U && m_cols == 16U) { - if (m_duplex) { - if (slotNo == 1U) { - ::lcdPosition(m_fd, 0, 0); - ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); - } else { - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); - } - } else { - ::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) { - if (slotNo == 1U) { - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); - } else { - ::lcdPosition(m_fd, 0, 2); - ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); - } - } else if (m_rows == 4U && m_cols == 20U) { - if (slotNo == 1U) { - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); - } else { - ::lcdPosition(m_fd, 0, 2); - ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); - } - } else if (m_rows == 2U && m_cols == 40U) { + if (m_duplex) { if (slotNo == 1U) { ::lcdPosition(m_fd, 0, 0); ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); @@ -683,6 +572,17 @@ void CHD44780::clearDMRInt(unsigned int slotNo) ::lcdPosition(m_fd, 0, 1); ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); } + } else { + ::lcdPosition(m_fd, 0, (m_rows / 2) - 1); + ::sprintf(buffer, "%s%s", "DMR", DEADSPACE); + ::lcdPrintf(m_fd, "%.*s", m_cols, buffer); + ::lcdPosition(m_fd, 0, (m_rows / 2)); + ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING); + +/* ::lcdPosition(m_fd, 0, 0); + ::lcdPuts(m_fd, "DMR "); + ::lcdPosition(m_fd, 0, 1); + ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING); */ } } From 6065488b3f2787d79ff7caca25282d4a22673ea6 Mon Sep 17 00:00:00 2001 From: Tony Corbett Date: Thu, 12 May 2016 12:32:19 +0100 Subject: [PATCH 4/8] Tidied up and uncommented test duplex flag --- HD44780.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HD44780.cpp b/HD44780.cpp index 773f96c..7ceff33 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -47,8 +47,8 @@ m_pwm(pwm), m_pwmPin(pwmPin), m_pwmBright(pwmBright), m_pwmDim(pwmDim), -//m_duplex(duplex), -m_duplex(true), +m_duplex(duplex), +//m_duplex(true), // uncomment to force duplex display for testing! m_fd(-1), m_dmr(false) { From 0afaf87713024603c1f0bc9a6a8344089751aa2f Mon Sep 17 00:00:00 2001 From: Tony Corbett Date: Thu, 12 May 2016 12:32:19 +0100 Subject: [PATCH 5/8] Tidied up and uncommented test duplex flag Need to look at threading the printing of the buffer to the LCD so it can scroll long strings without pausing (and stopping) the processing of other data. --- HD44780.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/HD44780.cpp b/HD44780.cpp index 773f96c..7ceff33 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -47,8 +47,8 @@ m_pwm(pwm), m_pwmPin(pwmPin), m_pwmBright(pwmBright), m_pwmDim(pwmDim), -//m_duplex(duplex), -m_duplex(true), +m_duplex(duplex), +//m_duplex(true), // uncomment to force duplex display for testing! m_fd(-1), m_dmr(false) { From 0014e39be7008252fbac64917095f552cc885907 Mon Sep 17 00:00:00 2001 From: Tony Corbett Date: Thu, 12 May 2016 12:45:12 +0100 Subject: [PATCH 6/8] Commented the point at which I'd like to start a new thread --- HD44780.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/HD44780.cpp b/HD44780.cpp index 7ceff33..7930bda 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -519,7 +519,10 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro ::lcdPosition(m_fd, 0, (m_rows / 2) - 1); ::lcdPuts(m_fd, "1"); ::sprintf(buffer, " %s > %s%s", src.c_str(), dst.c_str(), DEADSPACE); + + // Thread this out ::lcdPrintf(m_fd, "%.*s", m_cols - 4U, buffer); + ::lcdCharDef(m_fd, 6, group ? tgChar : privChar); ::lcdCharDef(m_fd, 5, strcmp(type, "R") == 0 ? rfChar : ipChar); ::lcdPosition(m_fd, m_cols - 2U, (m_rows / 2) - 1); @@ -529,7 +532,10 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro ::lcdPosition(m_fd, 0, (m_rows / 2)); ::lcdPuts(m_fd, "2"); ::sprintf(buffer, " %s > %s%s", src.c_str(), dst.c_str(), DEADSPACE); + + // Thread this out ::lcdPrintf(m_fd, "%.*s", m_cols - 4U, buffer); + ::lcdCharDef(m_fd, 6, group ? tgChar : privChar); ::lcdCharDef(m_fd, 5, strcmp(type, "R") == 0 ? rfChar : ipChar); ::lcdPosition(m_fd, m_cols - 2U, (m_rows / 2)); From bfe0bb389c0672a8eba369d844317b1cbf581dd7 Mon Sep 17 00:00:00 2001 From: Tony Corbett G0WFV Date: Thu, 12 May 2016 14:04:43 +0100 Subject: [PATCH 7/8] Correct an error with printing DMR to top line of 4 line screens --- HD44780.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HD44780.cpp b/HD44780.cpp index 7930bda..6ed9bc6 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -490,7 +490,7 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro if (m_duplex) { if (m_rows > 2U) { ::lcdPosition(m_fd, 0, (m_rows / 2) - 2); - ::sprintf(buffer, "%s%s", buffer, DEADSPACE); + ::sprintf(buffer, "%s%s", "DMR", DEADSPACE); ::lcdPrintf(m_fd, "%.*s", m_cols, buffer); } From 635ab50aa53a3fd00e7fa409aff4f415dd89d80a Mon Sep 17 00:00:00 2001 From: Tony Corbett G0WFV Date: Thu, 12 May 2016 16:32:27 +0100 Subject: [PATCH 8/8] Clean up and make good without threading Threading of scrolling source and destination IDs to be revisited another time (hopefully by someone else who knows what they're doing!) --- HD44780.cpp | 53 +++++++++++++++++++++++++++-------------------------- 1 file changed, 27 insertions(+), 26 deletions(-) diff --git a/HD44780.cpp b/HD44780.cpp index 6ed9bc6..41a2811 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -517,37 +517,43 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro if (m_duplex) { if (slotNo == 1U) { ::lcdPosition(m_fd, 0, (m_rows / 2) - 1); - ::lcdPuts(m_fd, "1"); - ::sprintf(buffer, " %s > %s%s", src.c_str(), dst.c_str(), DEADSPACE); + ::lcdPuts(m_fd, "1 "); + ::sprintf(buffer, "%s > %s%s", src.c_str(), dst.c_str(), DEADSPACE); - // Thread this out - ::lcdPrintf(m_fd, "%.*s", m_cols - 4U, buffer); - - ::lcdCharDef(m_fd, 6, group ? tgChar : privChar); - ::lcdCharDef(m_fd, 5, strcmp(type, "R") == 0 ? rfChar : ipChar); - ::lcdPosition(m_fd, m_cols - 2U, (m_rows / 2) - 1); - ::lcdPutchar(m_fd, 6); - ::lcdPutchar(m_fd, 5); + // Thread this out? + ::lcdPrintf(m_fd, "%.*s", m_cols - 2U, buffer); + + if (m_cols > 16) { + ::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); + } } else { ::lcdPosition(m_fd, 0, (m_rows / 2)); - ::lcdPuts(m_fd, "2"); - ::sprintf(buffer, " %s > %s%s", src.c_str(), dst.c_str(), DEADSPACE); + ::lcdPuts(m_fd, "2 "); + ::sprintf(buffer, "%s > %s%s", src.c_str(), dst.c_str(), DEADSPACE); - // Thread this out - ::lcdPrintf(m_fd, "%.*s", m_cols - 4U, buffer); + // Thread this out? + ::lcdPrintf(m_fd, "%.*s", m_cols - 2U, buffer); - ::lcdCharDef(m_fd, 6, group ? tgChar : privChar); - ::lcdCharDef(m_fd, 5, strcmp(type, "R") == 0 ? rfChar : ipChar); - ::lcdPosition(m_fd, m_cols - 2U, (m_rows / 2)); - ::lcdPutchar(m_fd, 6); - ::lcdPutchar(m_fd, 5); + if (m_cols > 16) { + ::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); + } } } else { ::lcdPosition(m_fd, 0, (m_rows / 2) - 1); ::lcdPutchar(m_fd, 0); ::sprintf(buffer, " %s%s", src.c_str(), DEADSPACE); ::lcdPrintf(m_fd, "%.*s", m_cols - 4U, buffer); - ::lcdCharDef(m_fd, 5, strcmp(type, "R") == 0 ? rfChar : ipChar); + ::lcdCharDef(m_fd, 5, strcmp(type, "R") == 0 ? rfChar : ipChar); ::lcdPosition(m_fd, m_cols - 1U, (m_rows / 2) - 1); ::lcdPutchar(m_fd, 5); @@ -555,7 +561,7 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro ::lcdPutchar(m_fd, 1); ::sprintf(buffer, " %s%s", dst.c_str(), DEADSPACE); ::lcdPrintf(m_fd, "%.*s", m_cols - 4U, buffer); - ::lcdCharDef(m_fd, 6, group ? tgChar : privChar); + ::lcdCharDef(m_fd, 6, group ? tgChar : privChar); ::lcdPosition(m_fd, m_cols - 1U, (m_rows / 2)); ::lcdPutchar(m_fd, 6); } @@ -584,11 +590,6 @@ void CHD44780::clearDMRInt(unsigned int slotNo) ::lcdPrintf(m_fd, "%.*s", m_cols, buffer); ::lcdPosition(m_fd, 0, (m_rows / 2)); ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING); - -/* ::lcdPosition(m_fd, 0, 0); - ::lcdPuts(m_fd, "DMR "); - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING); */ } }