diff --git a/Display.h b/Display.h index f831af9..5f19f7f 100644 --- a/Display.h +++ b/Display.h @@ -33,15 +33,12 @@ public: virtual void setLockout() = 0; virtual void setError(const char* text) = 0; - virtual void setDStar() = 0; virtual void writeDStar(const char* my1, const char* my2, const char* your) = 0; virtual void clearDStar() = 0; - virtual void setDMR() = 0; virtual void writeDMR(unsigned int slotNo, unsigned int srdId, bool group, unsigned int dstId, const char* type) = 0; virtual void clearDMR(unsigned int slotNo) = 0; - virtual void setFusion() = 0; virtual void writeFusion(const char* source, const char* dest) = 0; virtual void clearFusion() = 0; diff --git a/HD44780.cpp b/HD44780.cpp index 8eb86af..fd3635f 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -38,7 +38,8 @@ m_d0(pins.at(2U)), m_d1(pins.at(3U)), m_d2(pins.at(4U)), m_d3(pins.at(5U)), -m_fd(-1) +m_fd(-1), +m_dmr(false) { assert(rows > 1U); assert(cols > 15U); @@ -74,6 +75,8 @@ void CHD44780::setIdle() ::lcdPosition(m_fd, 0, 1); ::lcdPuts(m_fd, "MMDVM Idle"); + + m_dmr = false; } void CHD44780::setError(const char* text) @@ -87,6 +90,8 @@ void CHD44780::setError(const char* text) ::lcdPosition(m_fd, 0, 1); ::lcdPrintf(m_fd, "%s ERROR", text); + + m_dmr = false; } void CHD44780::setLockout() @@ -98,17 +103,8 @@ void CHD44780::setLockout() ::lcdPosition(m_fd, 0, 1); ::lcdPuts(m_fd, "Lockout"); -} -void CHD44780::setDStar() -{ - ::lcdClear(m_fd); - - ::lcdPosition(m_fd, 0, 0); - ::lcdPuts(m_fd, "D-Star"); - - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING); + m_dmr = false; } void CHD44780::writeDStar(const char* my1, const char* my2, const char* your) @@ -117,6 +113,11 @@ void CHD44780::writeDStar(const char* my1, const char* my2, const char* your) assert(my2 != NULL); assert(your != NULL); + ::lcdClear(m_fd); + + ::lcdPosition(m_fd, 0, 0); + ::lcdPuts(m_fd, "D-Star"); + if (m_rows > 2U) { char buffer[40U]; @@ -134,6 +135,8 @@ void CHD44780::writeDStar(const char* my1, const char* my2, const char* your) ::lcdPosition(m_fd, 0, 1); ::lcdPrintf(m_fd, "%.*s", m_cols, buffer); } + + m_dmr = false; } void CHD44780::clearDStar() @@ -150,30 +153,27 @@ void CHD44780::clearDStar() } } -void CHD44780::setDMR() -{ - ::lcdClear(m_fd); - - int row = 0; - if (m_rows > 2U) { - ::lcdPosition(m_fd, 0, row); - ::lcdPuts(m_fd, "DMR"); - row++; - } - - ::lcdPosition(m_fd, 0, row); - ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); - - row++; - - ::lcdPosition(m_fd, 0, row); - ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); -} - void CHD44780::writeDMR(unsigned int slotNo, unsigned int srcId, bool group, unsigned int dstId, const char* type) { assert(type != NULL); + ::lcdClear(m_fd); + + if (m_rows > 2U) { + ::lcdPosition(m_fd, 0, 0); + ::lcdPuts(m_fd, "DMR"); + } + + if (!m_dmr) { + if (slotNo == 1U) { + ::lcdPosition(m_fd, 0, m_rows > 2U ? 2 : 1); + ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, LISTENING); + } else { + ::lcdPosition(m_fd, 0, m_rows > 2U ? 1 : 0); + ::lcdPrintf(m_fd, "1 %.*s", m_cols - 2U, LISTENING); + } + } + if (slotNo == 1U) { char buffer[40U]; if (m_cols > 16U) @@ -193,6 +193,8 @@ void CHD44780::writeDMR(unsigned int slotNo, unsigned int srcId, bool group, uns ::lcdPosition(m_fd, 0, m_rows > 2U ? 2 : 1); ::lcdPrintf(m_fd, "2 %.*s", m_cols - 2U, buffer); } + + m_dmr = true; } void CHD44780::clearDMR(unsigned int slotNo) @@ -206,22 +208,16 @@ void CHD44780::clearDMR(unsigned int slotNo) } } -void CHD44780::setFusion() -{ - ::lcdClear(m_fd); - - ::lcdPosition(m_fd, 0, 0); - ::lcdPuts(m_fd, "System Fusion"); - - ::lcdPosition(m_fd, 0, 1); - ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING); -} - void CHD44780::writeFusion(const char* source, const char* dest) { assert(source != NULL); assert(dest != NULL); + ::lcdClear(m_fd); + + ::lcdPosition(m_fd, 0, 0); + ::lcdPuts(m_fd, "System Fusion"); + if (m_rows > 2U) { char buffer[40U]; @@ -239,6 +235,8 @@ void CHD44780::writeFusion(const char* source, const char* dest) ::lcdPosition(m_fd, 0, 1); ::lcdPrintf(m_fd, "%.*s", m_cols, buffer); } + + m_dmr = false; } void CHD44780::clearFusion() diff --git a/HD44780.h b/HD44780.h index bf95bd2..fe5bed2 100644 --- a/HD44780.h +++ b/HD44780.h @@ -37,15 +37,12 @@ public: virtual void setError(const char* text); virtual void setLockout(); - virtual void setDStar(); virtual void writeDStar(const char* my1, const char* my2, const char* your); virtual void clearDStar(); - virtual void setDMR(); virtual void writeDMR(unsigned int slotNo, unsigned int srdId, bool group, unsigned int dstId, const char* type); virtual void clearDMR(unsigned int slotNo); - virtual void setFusion(); virtual void writeFusion(const char* source, const char* dest); virtual void clearFusion(); @@ -63,6 +60,7 @@ private: unsigned int m_d2; unsigned int m_d3; int m_fd; + bool m_dmr; }; #endif diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 2f2a018..e299e8e 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -625,7 +625,6 @@ void CMMDVMHost::setMode(unsigned char mode, bool logging) LogMessage("Mode set to D-Star"); if (m_dmrNetwork != NULL) m_dmrNetwork->enable(false); - m_display->setDStar(); m_modem->setMode(MODE_DSTAR); m_mode = MODE_DSTAR; m_modeTimer.start(); @@ -636,7 +635,6 @@ void CMMDVMHost::setMode(unsigned char mode, bool logging) LogMessage("Mode set to DMR"); if (m_dstarNetwork != NULL) m_dstarNetwork->enable(false); - m_display->setDMR(); m_modem->setMode(MODE_DMR); if (m_duplex) m_modem->writeDMRStart(true); @@ -651,7 +649,6 @@ void CMMDVMHost::setMode(unsigned char mode, bool logging) m_dstarNetwork->enable(false); if (m_dmrNetwork != NULL) m_dmrNetwork->enable(false); - m_display->setFusion(); m_modem->setMode(MODE_YSF); m_mode = MODE_YSF; m_modeTimer.start(); diff --git a/Nextion.cpp b/Nextion.cpp index ab5b869..2dcbfe8 100644 --- a/Nextion.cpp +++ b/Nextion.cpp @@ -27,7 +27,8 @@ CNextion::CNextion(const char* callsign, unsigned int dmrid, const std::string& m_callsign(callsign), m_dmrid(dmrid), m_serial(port, SERIAL_9600), -m_brightness(brightness) +m_brightness(brightness), +m_mode(MODE_IDLE) { assert(brightness >= 0U && brightness <= 100U); } @@ -64,6 +65,8 @@ void CNextion::setIdle() sendCommand(command); sendCommand("t1.txt=\"MMDVM IDLE\""); + + m_mode = MODE_IDLE; } void CNextion::setError(const char* text) @@ -77,6 +80,8 @@ void CNextion::setError(const char* text) sendCommand(command); sendCommand("t1.txt=\"ERROR\""); + + m_mode = MODE_ERROR; } void CNextion::setLockout() @@ -84,13 +89,8 @@ void CNextion::setLockout() sendCommand("page MMDVM"); sendCommand("t0.txt=\"LOCKOUT\""); -} -void CNextion::setDStar() -{ - sendCommand("page DStar"); - - sendCommand("t0.txt=\"Listening\""); + m_mode = MODE_LOCKOUT; } void CNextion::writeDStar(const char* my1, const char* my2, const char* your) @@ -99,12 +99,17 @@ void CNextion::writeDStar(const char* my1, const char* my2, const char* your) assert(my2 != NULL); assert(your != NULL); + if (m_mode != MODE_DSTAR) + sendCommand("page DStar"); + char text[30U]; ::sprintf(text, "t0.txt=\"%.8s/%4.4s\"", my1, my2); sendCommand(text); ::sprintf(text, "t1.txt=\"%.8s\"", your); sendCommand(text); + + m_mode = MODE_DSTAR; } void CNextion::clearDStar() @@ -113,18 +118,19 @@ void CNextion::clearDStar() sendCommand("t1.txt=\"\""); } -void CNextion::setDMR() -{ - sendCommand("page DMR"); - - sendCommand("t0.txt=\"1 Listening\""); - sendCommand("t2.txt=\"2 Listening\""); -} - void CNextion::writeDMR(unsigned int slotNo, unsigned int srcId, bool group, unsigned int dstId, const char* type) { assert(type != NULL); + if (m_mode != MODE_DMR) { + sendCommand("page DMR"); + + if (slotNo == 1U) + sendCommand("t2.txt=\"2 Listening\""); + else + sendCommand("t0.txt=\"1 Listening\""); + } + if (slotNo == 1U) { char text[30U]; @@ -142,6 +148,8 @@ void CNextion::writeDMR(unsigned int slotNo, unsigned int srcId, bool group, uns ::sprintf(text, "t3.txt=\"%s%u\"", group ? "TG" : "", dstId); sendCommand(text); } + + m_mode = MODE_DMR; } void CNextion::clearDMR(unsigned int slotNo) @@ -155,24 +163,22 @@ void CNextion::clearDMR(unsigned int slotNo) } } -void CNextion::setFusion() -{ - sendCommand("page YSF"); - - sendCommand("t0.txt=\"Listening\""); -} - void CNextion::writeFusion(const char* source, const char* dest) { assert(source != NULL); assert(dest != NULL); + if (m_mode != MODE_YSF) + sendCommand("page YSF"); + char text[30U]; ::sprintf(text, "t0.txt=\"%.10s\"", source); sendCommand(text); ::sprintf(text, "t1.txt=\"%.10s\"", dest); sendCommand(text); + + m_mode = MODE_YSF; } void CNextion::clearFusion() diff --git a/Nextion.h b/Nextion.h index ff8bd46..3f9c1f6 100644 --- a/Nextion.h +++ b/Nextion.h @@ -20,6 +20,7 @@ #define NEXTION_H #include "Display.h" +#include "Defines.h" #include "SerialController.h" #include @@ -37,15 +38,12 @@ public: virtual void setError(const char* text); virtual void setLockout(); - virtual void setDStar(); virtual void writeDStar(const char* my1, const char* my2, const char* your); virtual void clearDStar(); - virtual void setDMR(); virtual void writeDMR(unsigned int slotNo, unsigned int srdId, bool group, unsigned int dstId, const char* type); virtual void clearDMR(unsigned int slotNo); - virtual void setFusion(); virtual void writeFusion(const char* source, const char* dest); virtual void clearFusion(); @@ -56,6 +54,7 @@ private: unsigned int m_dmrid; CSerialController m_serial; unsigned int m_brightness; + unsigned char m_mode; void sendCommand(const char* command); }; diff --git a/NullDisplay.cpp b/NullDisplay.cpp index 59b45ef..46786cd 100644 --- a/NullDisplay.cpp +++ b/NullDisplay.cpp @@ -43,10 +43,6 @@ void CNullDisplay::setLockout() { } -void CNullDisplay::setDStar() -{ -} - void CNullDisplay::writeDStar(const char* my1, const char* my2, const char* your) { } @@ -55,10 +51,6 @@ void CNullDisplay::clearDStar() { } -void CNullDisplay::setDMR() -{ -} - void CNullDisplay::writeDMR(unsigned int slotNo, unsigned int srcId, bool group, unsigned int dstId, const char* type) { } @@ -67,10 +59,6 @@ void CNullDisplay::clearDMR(unsigned int slotNo) { } -void CNullDisplay::setFusion() -{ -} - void CNullDisplay::writeFusion(const char* source, const char* dest) { } diff --git a/NullDisplay.h b/NullDisplay.h index abcfa6e..f30721b 100644 --- a/NullDisplay.h +++ b/NullDisplay.h @@ -36,15 +36,12 @@ public: virtual void setError(const char* text); virtual void setLockout(); - virtual void setDStar(); virtual void writeDStar(const char* my1, const char* my2, const char* your); virtual void clearDStar(); - virtual void setDMR(); virtual void writeDMR(unsigned int slotNo, unsigned int srdId, bool group, unsigned int dstId, const char* type); virtual void clearDMR(unsigned int slotNo); - virtual void setFusion(); virtual void writeFusion(const char* source, const char* dest); virtual void clearFusion(); diff --git a/TFTSerial.cpp b/TFTSerial.cpp index 2ff36d7..c767708 100644 --- a/TFTSerial.cpp +++ b/TFTSerial.cpp @@ -48,7 +48,8 @@ CTFTSerial::CTFTSerial(const char* callsign, unsigned int dmrid, const std::stri m_callsign(callsign), m_dmrid(dmrid), m_serial(port, SERIAL_9600), -m_brightness(brightness) +m_brightness(brightness), +m_mode(MODE_IDLE) { assert(brightness >= 0U && brightness <= 100U); } @@ -96,6 +97,8 @@ void CTFTSerial::setIdle() gotoPosPixel(45U, 90U); displayText("IDLE"); + + m_mode = MODE_IDLE; } void CTFTSerial::setError(const char* text) @@ -119,6 +122,8 @@ void CTFTSerial::setError(const char* text) displayText("ERROR"); setForeground(COLOUR_BLACK); + + m_mode = MODE_ERROR; } void CTFTSerial::setLockout() @@ -133,20 +138,8 @@ void CTFTSerial::setLockout() gotoPosPixel(20U, 60U); displayText("LOCKOUT"); -} -void CTFTSerial::setDStar() -{ - // Clear the screen - clearScreen(); - - setFontSize(FONT_MEDIUM); - - // Draw D-Star insignia - displayBitmap(0U, 0U, "DStar_sm.bmp"); - - gotoPosPixel(30U, 80U); - displayText("Listening"); + m_mode = MODE_LOCKOUT; } void CTFTSerial::writeDStar(const char* my1, const char* my2, const char* your) @@ -155,6 +148,16 @@ void CTFTSerial::writeDStar(const char* my1, const char* my2, const char* your) assert(my2 != NULL); assert(your != NULL); + if (m_mode != MODE_DSTAR) { + // Clear the screen + clearScreen(); + + setFontSize(FONT_MEDIUM); + + // Draw D-Star insignia + displayBitmap(0U, 0U, "DStar_sm.bmp"); + } + char text[30U]; ::sprintf(text, "%.8s/%4.4s", my1, my2); @@ -165,6 +168,8 @@ void CTFTSerial::writeDStar(const char* my1, const char* my2, const char* your) gotoPosPixel(5U, 100U); displayText(text); + + m_mode = MODE_DSTAR; } void CTFTSerial::clearDStar() @@ -176,27 +181,28 @@ void CTFTSerial::clearDStar() displayText(" "); } -void CTFTSerial::setDMR() -{ - // Clear the screen - clearScreen(); - - setFontSize(FONT_MEDIUM); - - // Draw DMR insignia - displayBitmap(0U, 0U, "DMR_sm.bmp"); - - gotoPosPixel(5U, 55U); - displayText("1 Listening"); - - gotoPosPixel(5U, 90U); - displayText("2 Listening"); -} - void CTFTSerial::writeDMR(unsigned int slotNo, unsigned int srcId, bool group, unsigned int dstId, const char* type) { assert(type != NULL); + if (m_mode != MODE_DMR) { + // Clear the screen + clearScreen(); + + setFontSize(FONT_MEDIUM); + + // Draw DMR insignia + displayBitmap(0U, 0U, "DMR_sm.bmp"); + + if (slotNo == 1U) { + gotoPosPixel(5U, 90U); + displayText("2 Listening"); + } else { + gotoPosPixel(5U, 55U); + displayText("1 Listening"); + } + } + if (slotNo == 1U) { char text[30U]; @@ -218,6 +224,8 @@ void CTFTSerial::writeDMR(unsigned int slotNo, unsigned int srcId, bool group, u gotoPosPixel(65U, 107U); displayText(text); } + + m_mode = MODE_DMR; } void CTFTSerial::clearDMR(unsigned int slotNo) @@ -237,25 +245,21 @@ void CTFTSerial::clearDMR(unsigned int slotNo) } } -void CTFTSerial::setFusion() -{ - // Clear the screen - clearScreen(); - - setFontSize(FONT_MEDIUM); - - // Draw the System Fusion insignia - displayBitmap(0U, 0U, "YSF_sm.bmp"); - - gotoPosPixel(30U, 80U); - displayText("Listening"); -} - void CTFTSerial::writeFusion(const char* source, const char* dest) { assert(source != NULL); assert(dest != NULL); + if (m_mode != MODE_YSF) { + // Clear the screen + clearScreen(); + + setFontSize(FONT_MEDIUM); + + // Draw the System Fusion insignia + displayBitmap(0U, 0U, "YSF_sm.bmp"); + } + char text[30U]; ::sprintf(text, "%.10s", source); @@ -266,6 +270,8 @@ void CTFTSerial::writeFusion(const char* source, const char* dest) gotoPosPixel(5U, 100U); displayText(text); + + m_mode = MODE_YSF; } void CTFTSerial::clearFusion() diff --git a/TFTSerial.h b/TFTSerial.h index 23def14..987e4f4 100644 --- a/TFTSerial.h +++ b/TFTSerial.h @@ -20,6 +20,7 @@ #define TFTSERIAL_H #include "Display.h" +#include "Defines.h" #include "SerialController.h" #include @@ -37,15 +38,12 @@ public: virtual void setError(const char* text); virtual void setLockout(); - virtual void setDStar(); virtual void writeDStar(const char* my1, const char* my2, const char* your); virtual void clearDStar(); - virtual void setDMR(); virtual void writeDMR(unsigned int slotNo, unsigned int srdId, bool group, unsigned int dstId, const char* type); virtual void clearDMR(unsigned int slotNo); - virtual void setFusion(); virtual void writeFusion(const char* source, const char* dest); virtual void clearFusion(); @@ -56,6 +54,7 @@ private: unsigned int m_dmrid; CSerialController m_serial; unsigned int m_brightness; + unsigned char m_mode; void clearScreen(); void setBackground(unsigned char colour);