From 9e6c7cff4279b6fae036bddec2bf1e1f80c889ed Mon Sep 17 00:00:00 2001 From: Tony Corbett G0WFV Date: Thu, 5 May 2016 14:29:46 +0100 Subject: [PATCH 1/5] Beginnings of DVMega Display Use the HD44780 real estate where TS1 is irrelevant. --- Conf.cpp | 8 ++++++++ Conf.h | 2 ++ HD44780.cpp | 33 ++++++++++++++++++++++----------- HD44780.h | 3 ++- MMDVM.ini | 3 +++ 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 7e7f6de..74f8e88 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -115,6 +115,7 @@ m_hd44780PWM(false), m_hd44780PWMPin(), m_hd44780PWMBright(), m_hd44780PWMDim(), +m_hd44780DVMegaDisplay(false), m_nextionSize("2.4"), m_nextionPort("/dev/ttyAMA0"), m_nextionBrightness(50U) @@ -355,6 +356,8 @@ bool CConf::read() m_hd44780PWMBright = (unsigned int)::atoi(value); else if (::strcmp(key, "PWMDim") == 0) m_hd44780PWMDim = (unsigned int)::atoi(value); + else if (::strcmp(key, "DVMegaDisplay") == 0) + m_hd44780DVMegaDisplay = (unsigned int)::atoi(value); else if (::strcmp(key, "Pins") == 0) { char* p = ::strtok(value, ",\r\n"); while (p != NULL) { @@ -723,6 +726,11 @@ unsigned int CConf::getHD44780PWMDim() const return m_hd44780PWMDim; } +bool CConf::getHD44780DVMegaDisplay() const +{ + return m_hd44780DVMegaDisplay; +} + std::string CConf::getNextionSize() const { return m_nextionSize; diff --git a/Conf.h b/Conf.h index 2e3e177..a57ed29 100644 --- a/Conf.h +++ b/Conf.h @@ -122,6 +122,7 @@ public: unsigned int getHD44780PWMPin() const; unsigned int getHD44780PWMBright() const; unsigned int getHD44780PWMDim() const; + bool getHD44780DVMegaDisplay() const; // The Nextion section std::string getNextionSize() const; @@ -210,6 +211,7 @@ private: unsigned int m_hd44780PWMPin; unsigned int m_hd44780PWMBright; unsigned int m_hd44780PWMDim; + bool m_hd44780DVMegaDisplay; std::string m_nextionSize; std::string m_nextionPort; diff --git a/HD44780.cpp b/HD44780.cpp index c1a99f8..1e95d20 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -29,7 +29,7 @@ const char* LISTENING = "Listening "; -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) : +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 dvmegaDisplay) : m_rows(rows), m_cols(cols), m_callsign(callsign), @@ -44,6 +44,7 @@ m_pwm(pwm), m_pwmPin(pwmPin), m_pwmBright(pwmBright), m_pwmDim(pwmDim), +m_dvmegaDisplay(dvmegaDisplay), m_fd(-1), m_dmr(false) { @@ -345,8 +346,11 @@ void CHD44780::writeDMR(unsigned int slotNo, const std::string& src, bool group, ::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 (m_dvmegaDisplay) { + ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); + else + ::lcdPuts(m_fd, "DMR"); + } } } else if (m_rows == 4U && m_cols == 16U) { ::lcdPosition(m_fd, 0, 0); @@ -387,14 +391,21 @@ void CHD44780::writeDMR(unsigned int slotNo, const std::string& src, bool group, #endif 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); + if (!m_dvmegaDisplay) { + 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); + } + else { + ::lcdPosition(m_fd, 0, 0); + ::lcdPrintf(m_fd, "From: %s", src.c_str()); + ::lcdPosition(m_fd, 0, 0); + ::lcdPrintf(m_fd, "To : %s%s", group ? "TG" : "", dst.c_str()); } } else if (m_rows == 4U && m_cols == 16U) { #ifdef ADAFRUIT_DISPLAY diff --git a/HD44780.h b/HD44780.h index 8983018..59519b3 100644 --- a/HD44780.h +++ b/HD44780.h @@ -51,7 +51,7 @@ enum ADAFRUIT_COLOUR { class CHD44780 : public IDisplay { public: - 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); + 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 DVMegaDisplay); virtual ~CHD44780(); virtual bool open(); @@ -87,6 +87,7 @@ private: unsigned int m_pwmPin; unsigned int m_pwmBright; unsigned int m_pwmDim; + bool m_dvmegaDisplay; int m_fd; bool m_dmr; diff --git a/MMDVM.ini b/MMDVM.ini index 5f29c84..7ec4c56 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -97,6 +97,9 @@ PWMDim=16 # Adafruit i2c HD44780 Pins=115,113,112,111,110,109 +# Use redundant display real estate when connected to a DVMega +DVMegaDisplay=0 + [Nextion] Size=2.4 Port=/dev/ttyAMA0 From f31a8815cb3bc778e6e401a7c6f9de3782b025e1 Mon Sep 17 00:00:00 2001 From: Tony Corbett G0WFV Date: Thu, 5 May 2016 14:52:49 +0100 Subject: [PATCH 2/5] Forgot MMDVMHost.cpp! --- MMDVMHost.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index fe315a7..d95ee6a 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -691,6 +691,7 @@ void CMMDVMHost::createDisplay() unsigned int pwmPin = m_conf.getHD44780PWMPin(); unsigned int pwmBright = m_conf.getHD44780PWMBright(); unsigned int pwmDim = m_conf.getHD44780PWMDim(); + bool dvmegaDisplay = m_conf.getHD44780DVMegaDisplay(); if (pins.size() == 6U) { LogInfo(" Rows: %u", rows); @@ -704,7 +705,10 @@ void CMMDVMHost::createDisplay() LogInfo(" PWM Dim: %u", pwmDim); } - m_display = new CHD44780(rows, columns, callsign, dmrid, pins, pwm, pwmPin, pwmBright, pwmDim); + if (dvmegaDisplay) + LogInfo("Using DVMega display output on 16x2 HD44780"); + + m_display = new CHD44780(rows, columns, callsign, dmrid, pins, pwm, pwmPin, pwmBright, pwmDim, dvmegaDisplay); } #endif } else { From 57352093943b8d139d3c53ded8411c71ef1c6e99 Mon Sep 17 00:00:00 2001 From: Tony Corbett Date: Thu, 5 May 2016 16:13:06 +0100 Subject: [PATCH 3/5] Better usage of display with DVMega --- Conf.cpp | 2 +- HD44780.cpp | 49 +++++++++++++++++++++++++++++++++---------------- HD44780.h | 2 +- MMDVMHost.cpp | 2 +- 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 74f8e88..fcb9fd1 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -357,7 +357,7 @@ bool CConf::read() else if (::strcmp(key, "PWMDim") == 0) m_hd44780PWMDim = (unsigned int)::atoi(value); else if (::strcmp(key, "DVMegaDisplay") == 0) - m_hd44780DVMegaDisplay = (unsigned int)::atoi(value); + m_hd44780DVMegaDisplay = ::atoi(value) == 1; else if (::strcmp(key, "Pins") == 0) { char* p = ::strtok(value, ",\r\n"); while (p != NULL) { diff --git a/HD44780.cpp b/HD44780.cpp index 1e95d20..d4937c2 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -341,16 +341,20 @@ void CHD44780::writeDMR(unsigned int slotNo, const std::string& src, bool group, } if (m_rows == 2U && m_cols == 16U) { - if (slotNo == 1U) { - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); + if (!m_dvmegaDisplay) { + 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); - if (m_dvmegaDisplay) { - ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); - else - ::lcdPuts(m_fd, "DMR"); - } + ::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) { ::lcdPosition(m_fd, 0, 0); @@ -401,11 +405,16 @@ void CHD44780::writeDMR(unsigned int slotNo, const std::string& src, bool group, ::lcdPosition(m_fd, 0, 1); ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); } - else { + } else { + ::sprintf(buffer, "From: %s", src.c_str()); ::lcdPosition(m_fd, 0, 0); - ::lcdPrintf(m_fd, "From: %s", src.c_str()); - ::lcdPosition(m_fd, 0, 0); - ::lcdPrintf(m_fd, "To : %s%s", group ? "TG" : "", dst.c_str()); +// ::lcdPrintf(m_fd, "%.*s", m_cols, buffer); + ::lcdPrintf(m_fd, "%-16s", buffer); + + ::sprintf(buffer, "To : %s", dst.c_str()); + ::lcdPosition(m_fd, 0, 1); +// ::lcdPrintf(m_fd, "%.*s", m_cols, buffer); + ::lcdPrintf(m_fd, "%-16s", buffer); } } else if (m_rows == 4U && m_cols == 16U) { #ifdef ADAFRUIT_DISPLAY @@ -464,12 +473,20 @@ void CHD44780::clearDMR(unsigned int slotNo) #endif if (m_rows == 2U && m_cols == 16U) { - if (slotNo == 1U) { - ::lcdPosition(m_fd, 0, 0); - ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); + if (!m_dvmegaDisplay) { + 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, "2 %.*s", m_cols - 2U, LISTENING); +// ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING); + ::lcdPrintf(m_fd, "%-16s", "Listening..."); } } else if (m_rows == 4U && m_cols == 16U) { if (slotNo == 1U) { diff --git a/HD44780.h b/HD44780.h index 59519b3..5b9805b 100644 --- a/HD44780.h +++ b/HD44780.h @@ -51,7 +51,7 @@ enum ADAFRUIT_COLOUR { class CHD44780 : public IDisplay { public: - 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 DVMegaDisplay); + 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 dvmegaDisplay); virtual ~CHD44780(); virtual bool open(); diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index d95ee6a..1c6611e 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -706,7 +706,7 @@ void CMMDVMHost::createDisplay() } if (dvmegaDisplay) - LogInfo("Using DVMega display output on 16x2 HD44780"); + LogInfo("Using DVMega display output on HD44780"); m_display = new CHD44780(rows, columns, callsign, dmrid, pins, pwm, pwmPin, pwmBright, pwmDim, dvmegaDisplay); } From 352c4872796aa32f3bde2ec204fab2a70dd3b284 Mon Sep 17 00:00:00 2001 From: Tony Corbett Date: Thu, 5 May 2016 16:32:41 +0100 Subject: [PATCH 4/5] Re-added missed TG --- HD44780.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HD44780.cpp b/HD44780.cpp index d4937c2..daeb398 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -411,7 +411,7 @@ void CHD44780::writeDMR(unsigned int slotNo, const std::string& src, bool group, // ::lcdPrintf(m_fd, "%.*s", m_cols, buffer); ::lcdPrintf(m_fd, "%-16s", buffer); - ::sprintf(buffer, "To : %s", dst.c_str()); + ::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); From 8aa52ae13d870440fad2e121ac6724421276b5e2 Mon Sep 17 00:00:00 2001 From: Tony Corbett Date: Thu, 5 May 2016 16:55:31 +0100 Subject: [PATCH 5/5] Formatting for consistency --- HD44780.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/HD44780.cpp b/HD44780.cpp index daeb398..658f803 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -354,7 +354,7 @@ void CHD44780::writeDMR(unsigned int slotNo, const std::string& src, bool group, ::lcdPuts(m_fd, "DMR "); ::lcdPosition(m_fd, 0, 1); // ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING); - ::lcdPrintf(m_fd, "%-16s", "Listening..."); + ::lcdPrintf(m_fd, "%-16s", "Listening"); } } else if (m_rows == 4U && m_cols == 16U) { ::lcdPosition(m_fd, 0, 0); @@ -397,11 +397,11 @@ void CHD44780::writeDMR(unsigned int slotNo, const std::string& src, bool group, char buffer[16U]; if (!m_dvmegaDisplay) { if (slotNo == 1U) { - ::sprintf(buffer, "%s >%s%s", src.c_str(), group ? "TG" : "", dst.c_str()); + ::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()); + ::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); } @@ -423,11 +423,11 @@ void CHD44780::writeDMR(unsigned int slotNo, const std::string& src, bool group, char buffer[16U]; if (slotNo == 1U) { - ::sprintf(buffer, "%s %s >%s%s", type, src.c_str(), group ? "TG" : "", dst.c_str()); + ::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()); + ::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); } @@ -486,7 +486,7 @@ void CHD44780::clearDMR(unsigned int slotNo) ::lcdPuts(m_fd, "DMR "); ::lcdPosition(m_fd, 0, 1); // ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING); - ::lcdPrintf(m_fd, "%-16s", "Listening..."); + ::lcdPrintf(m_fd, "%-16s", "Listening"); } } else if (m_rows == 4U && m_cols == 16U) { if (slotNo == 1U) {