From e2ec5292b597f39af243aac7cb79937b8f78816b Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 12 Sep 2016 18:12:32 +0100 Subject: [PATCH] Update the display code for P25. --- Display.cpp | 28 ++++++++++++++++ Display.h | 6 ++++ HD44780.cpp | 86 +++++++++++++++++++++++++++++++++++++++++++++++++ HD44780.h | 3 ++ Nextion.cpp | 31 ++++++++++++++++++ Nextion.h | 3 ++ NullDisplay.cpp | 8 +++++ NullDisplay.h | 3 ++ OLED.cpp | 25 ++++++++++++++ OLED.h | 3 ++ TFTSerial.cpp | 42 ++++++++++++++++++++++++ TFTSerial.h | 3 ++ 12 files changed, 241 insertions(+) diff --git a/Display.cpp b/Display.cpp index 5732169..d75afdd 100644 --- a/Display.cpp +++ b/Display.cpp @@ -155,6 +155,29 @@ void CDisplay::clearFusion() } } +void CDisplay::writeP25(const char* source, bool group, const char* dest, const char* type) +{ + assert(source != NULL); + assert(dest != NULL); + assert(type != NULL); + + m_timer1.start(); + m_mode1 = MODE_IDLE; + + writeP25Int(source, group, dest, type); +} + +void CDisplay::clearP25() +{ + if (m_timer1.hasExpired()) { + clearP25Int(); + m_timer1.stop(); + m_mode1 = MODE_IDLE; + } else { + m_mode1 = MODE_P25; + } +} + void CDisplay::clock(unsigned int ms) { m_timer1.clock(ms); @@ -175,6 +198,11 @@ void CDisplay::clock(unsigned int ms) m_mode1 = MODE_IDLE; m_timer1.stop(); break; + case MODE_P25: + clearP25Int(); + m_mode1 = MODE_IDLE; + m_timer1.stop(); + break; default: break; } diff --git a/Display.h b/Display.h index 15f4faa..ae63872 100644 --- a/Display.h +++ b/Display.h @@ -44,6 +44,9 @@ public: void writeFusion(const char* source, const char* dest, const char* type, const char* origin); void clearFusion(); + void writeP25(const char* source, bool group, const char* dest, const char* type); + void clearP25(); + virtual void close() = 0; void clock(unsigned int ms); @@ -62,6 +65,9 @@ protected: virtual void writeFusionInt(const char* source, const char* dest, const char* type, const char* origin) = 0; virtual void clearFusionInt() = 0; + virtual void writeP25Int(const char* source, bool group, const char* dest, const char* type) = 0; + virtual void clearP25Int() = 0; + virtual void clockInt(unsigned int ms); private: diff --git a/HD44780.cpp b/HD44780.cpp index 0af603e..65a8274 100644 --- a/HD44780.cpp +++ b/HD44780.cpp @@ -730,6 +730,92 @@ void CHD44780::clearFusionInt() } } +void CHD44780::writeP25Int(const char* source, bool group, const char* dest, const char* type) +{ + assert(source != NULL); + assert(dest != NULL); + assert(type != NULL); + +#ifdef ADAFRUIT_DISPLAY + adafruitLCDColour(AC_RED); +#endif + + m_clockDisplayTimer.stop(); // Stop the clock display + ::lcdClear(m_fd); + + if (m_pwm) { + if (m_pwmPin != 1U) + ::softPwmWrite(m_pwmPin, m_pwmBright); + else + ::pwmWrite(m_pwmPin, (m_pwmBright / 100) * 1024); + } + + ::lcdPosition(m_fd, 0, 0); + ::lcdPuts(m_fd, "P25"); + + if (m_rows == 2U && m_cols == 16U) { + char m_buffer1[16U]; + ::sprintf(m_buffer1, "%.10s >", source); + ::lcdPosition(m_fd, 0, 1); + ::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1); + } else if (m_rows == 4U && m_cols == 16U) { + char m_buffer1[16U]; + ::sprintf(m_buffer1, "%.10s >", source); + ::lcdPosition(m_fd, 0, 1); + ::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1); + + ::sprintf(m_buffer1, "%s%.10s", group ? "TG" : "", dest); + ::lcdPosition(m_fd, 0, 2); + ::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1); + } else if (m_rows == 4U && m_cols == 20U) { + char m_buffer1[20U]; + ::sprintf(m_buffer1, "%.10s >", source); + ::lcdPosition(m_fd, 0, 1); + ::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1); + + ::sprintf(m_buffer1, "%s%.10s", group ? "TG" : "", dest); + ::lcdPosition(m_fd, 0, 2); + ::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1); + } else if (m_rows == 2 && m_cols == 40U) { + char m_buffer1[40U]; + ::sprintf(m_buffer1, "%.10s > %s%.10s", source, group ? "TG" : "", dest); + + ::lcdPosition(m_fd, 0, 1); + ::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1); + } + + m_dmr = false; +} + +void CHD44780::clearP25Int() +{ +#ifdef ADAFRUIT_DISPLAY + adafruitLCDColour(AC_PURPLE); +#endif + + m_clockDisplayTimer.stop(); // Stop the clock display + + if (m_rows == 2U && m_cols == 16U) { + ::lcdPosition(m_fd, 0, 1); + ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING); + } else if (m_rows == 4U && m_cols == 16U) { + ::lcdPosition(m_fd, 0, 1); + ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING); + + ::lcdPosition(m_fd, 0, 2); + ::lcdPrintf(m_fd, "%.*s", m_cols, " "); + } else if (m_rows == 4U && m_cols == 20U) { + ::lcdPosition(m_fd, 0, 1); + ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING); + + ::lcdPosition(m_fd, 0, 2); + ::lcdPrintf(m_fd, "%.*s", m_cols, " "); + } else if (m_rows == 2 && m_cols == 40U) { + ::lcdPosition(m_fd, 0, 1); + ::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING); + } +} + void CHD44780::clockInt(unsigned int ms) { m_clockDisplayTimer.clock(ms); diff --git a/HD44780.h b/HD44780.h index 4748b79..ac4c73b 100644 --- a/HD44780.h +++ b/HD44780.h @@ -110,6 +110,9 @@ protected: virtual void writeFusionInt(const char* source, const char* dest, const char* type, const char* origin); virtual void clearFusionInt(); + virtual void writeP25Int(const char* source, bool group, const char* dest, const char* type); + virtual void clearP25Int(); + virtual void clockInt(unsigned int ms); private: diff --git a/Nextion.cpp b/Nextion.cpp index 7fdc72d..c67c5c1 100644 --- a/Nextion.cpp +++ b/Nextion.cpp @@ -233,6 +233,37 @@ void CNextion::clearFusionInt() sendCommand("t2.txt=\"\""); } +void CNextion::writeP25Int(const char* source, bool group, const char* dest, const char* type) +{ + assert(source != NULL); + assert(dest != NULL); + assert(type != NULL); + + if (m_mode != MODE_P25) + sendCommand("page P25"); + + char text[30U]; + ::sprintf(text, "dim=%u", m_brightness); + sendCommand(text); + + ::sprintf(text, "t0.txt=\"%s %.10s\"", type, source); + sendCommand(text); + + ::sprintf(text, "t1.txt=\"%s%.10s\"", group ? "TG" : "", dest); + sendCommand(text); + + m_clockDisplayTimer.stop(); + + m_mode = MODE_P25; +} + +void CNextion::clearP25Int() +{ + sendCommand("t0.txt=\"Listening\""); + sendCommand("t1.txt=\"\""); + sendCommand("t2.txt=\"\""); +} + void CNextion::clockInt(unsigned int ms) { // Update the clock display in IDLE mode every 400ms diff --git a/Nextion.h b/Nextion.h index 38fa55f..6f6329a 100644 --- a/Nextion.h +++ b/Nextion.h @@ -50,6 +50,9 @@ protected: virtual void writeFusionInt(const char* source, const char* dest, const char* type, const char* origin); virtual void clearFusionInt(); + virtual void writeP25Int(const char* source, bool group, const char* dest, const char* type); + virtual void clearP25Int(); + virtual void clockInt(unsigned int ms); private: diff --git a/NullDisplay.cpp b/NullDisplay.cpp index 9eb3059..b3018c8 100644 --- a/NullDisplay.cpp +++ b/NullDisplay.cpp @@ -68,6 +68,14 @@ void CNullDisplay::clearFusionInt() { } +void CNullDisplay::writeP25Int(const char* source, bool group, const char* dest, const char* type) +{ +} + +void CNullDisplay::clearP25Int() +{ +} + void CNullDisplay::close() { } diff --git a/NullDisplay.h b/NullDisplay.h index 7040157..ad25aee 100644 --- a/NullDisplay.h +++ b/NullDisplay.h @@ -47,6 +47,9 @@ protected: virtual void writeFusionInt(const char* source, const char* dest, const char* type, const char* origin); virtual void clearFusionInt(); + virtual void writeP25Int(const char* source, bool group, const char* dest, const char* type); + virtual void clearP25Int(); + private: }; diff --git a/OLED.cpp b/OLED.cpp index 5efbbee..2e4a687 100644 --- a/OLED.cpp +++ b/OLED.cpp @@ -210,6 +210,29 @@ void COLED::clearFusionInt() display.display(); } +void COLED::writeP25Int(const char* source, bool group, const char* dest, const char* type) +{ + m_mode = MODE_P25; + display.fillRect(0, OLED_LINE1, display.width(), 10, BLACK); + display.setCursor(0,OLED_LINE1); + display.printf("%s %.10s", type, source); + display.fillRect(0, OLED_LINE2, display.width(), 10, BLACK); + display.setCursor(0,OLED_LINE2); + display.printf(" %s%.10s", group ? "TG" : "", dest); + OLED_statusbar(); + display.display(); +} + +void COLED::clearP25Int() +{ + display.fillRect(0, OLED_LINE1, display.width(), 10, BLACK); + display.setCursor(0,OLED_LINE1); + display.print("Listening"); + display.fillRect(0, OLED_LINE2, display.width(), 10, BLACK); + OLED_statusbar(); + display.display(); +} + void COLED::close() { display.close(); @@ -227,6 +250,8 @@ void COLED::OLED_statusbar() display.print("D-Star"); else if (m_mode == MODE_YSF) display.print("Fusion"); + else if (m_mode == MODE_P25) + display.print("P25"); else display.drawBitmap(0, 0, logo_glcd_bmp, 16, 15, WHITE); } diff --git a/OLED.h b/OLED.h index 014d1fb..9c2d08f 100644 --- a/OLED.h +++ b/OLED.h @@ -94,6 +94,9 @@ public: virtual void writeFusionInt(const char* source, const char* dest, const char* type, const char* origin); virtual void clearFusionInt(); + virtual void writeP25Int(const char* source, bool group, const char* dest, const char* type); + virtual void clearP25Int(); + virtual void close(); private: diff --git a/TFTSerial.cpp b/TFTSerial.cpp index 8a0dc9d..ee2d7c4 100644 --- a/TFTSerial.cpp +++ b/TFTSerial.cpp @@ -311,6 +311,48 @@ void CTFTSerial::clearFusionInt() displayText(" "); } +void CTFTSerial::writeP25Int(const char* source, bool group, const char* dest, const char* type) +{ + assert(source != NULL); + assert(dest != NULL); + assert(type != NULL); + + if (m_mode != MODE_P25) { + // Clear the screen + clearScreen(); + + setFontSize(FONT_MEDIUM); + + // Draw the P25 insignia + displayBitmap(0U, 0U, "P25_sm.bmp"); + } + + char text[30U]; + ::sprintf(text, "%s %.10s", type, source); + + gotoPosPixel(5U, 70U); + displayText(text); + + ::sprintf(text, " %s%.10s", group ? "TG" : "", dest); + + gotoPosPixel(5U, 90U); + displayText(text); + + m_mode = MODE_P25; +} + +void CTFTSerial::clearP25Int() +{ + gotoPosPixel(5U, 70U); + displayText(" Listening "); + + gotoPosPixel(5U, 90U); + displayText(" "); + + gotoPosPixel(5U, 110U); + displayText(" "); +} + void CTFTSerial::close() { m_serial.close(); diff --git a/TFTSerial.h b/TFTSerial.h index 00e60fc..a0ad7d0 100644 --- a/TFTSerial.h +++ b/TFTSerial.h @@ -49,6 +49,9 @@ protected: virtual void writeFusionInt(const char* source, const char* dest, const char* type, const char* origin); virtual void clearFusionInt(); + virtual void writeP25Int(const char* source, bool group, const char* dest, const char* type); + virtual void clearP25Int(); + private: std::string m_callsign; unsigned int m_dmrid;