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