diff --git a/CASTInfo.cpp b/CASTInfo.cpp index 603ee20..46178c0 100644 --- a/CASTInfo.cpp +++ b/CASTInfo.cpp @@ -130,6 +130,16 @@ void CCASTInfo::clearNXDNInt() { } +void CCASTInfo::writeM17Int(const char* source, const char* dest, const char* type) +{ + if (m_modem != NULL) + m_modem->writeM17Info(source, dest, type); +} + +void CCASTInfo::clearM17Int() +{ +} + void CCASTInfo::writePOCSAGInt(uint32_t ric, const std::string& message) { if (m_modem != NULL) diff --git a/CASTInfo.h b/CASTInfo.h index 8945dcd..a369aaa 100644 --- a/CASTInfo.h +++ b/CASTInfo.h @@ -57,6 +57,9 @@ protected: virtual void writeNXDNInt(const char* source, bool group, unsigned int dest, const char* type); virtual void clearNXDNInt(); + virtual void writeM17Int(const char* source, const char* dest, const char* type); + virtual void clearM17Int(); + virtual void writePOCSAGInt(uint32_t ric, const std::string& message); virtual void clearPOCSAGInt(); diff --git a/Display.cpp b/Display.cpp index 39b0a09..bacba26 100644 --- a/Display.cpp +++ b/Display.cpp @@ -335,6 +335,40 @@ void CDisplay::clearNXDN() } } +void CDisplay::writeM17(const char* source, const char* dest, const char* type) +{ + assert(source != NULL); + assert(dest != NULL); + assert(type != NULL); + + m_timer1.start(); + m_mode1 = MODE_IDLE; + + writeM17Int(source, dest, type); +} + +void CDisplay::writeM17RSSI(unsigned char rssi) +{ + if (rssi != 0U) + writeM17RSSIInt(rssi); +} + +void CDisplay::writeM17BER(float ber) +{ + writeM17BERInt(ber); +} + +void CDisplay::clearM17() +{ + if (m_timer1.hasExpired()) { + clearM17Int(); + m_timer1.stop(); + m_mode1 = MODE_IDLE; + } else { + m_mode1 = MODE_M17; + } +} + void CDisplay::writePOCSAG(uint32_t ric, const std::string& message) { m_timer1.start(); @@ -392,6 +426,11 @@ void CDisplay::clock(unsigned int ms) m_mode1 = MODE_IDLE; m_timer1.stop(); break; + case MODE_M17: + clearM17Int(); + m_mode1 = MODE_IDLE; + m_timer1.stop(); + break; case MODE_POCSAG: clearPOCSAGInt(); m_mode1 = MODE_IDLE; @@ -482,6 +521,14 @@ void CDisplay::writeNXDNBERInt(float ber) { } +void CDisplay::writeM17RSSIInt(unsigned char rssi) +{ +} + +void CDisplay::writeM17BERInt(float ber) +{ +} + int CDisplay::writeNXDNIntEx(const class CUserDBentry& source, bool group, unsigned int dest, const char* type) { /* return value definition is same as writeDMRIntEx() */ diff --git a/Display.h b/Display.h index e23b3ec..165d05c 100644 --- a/Display.h +++ b/Display.h @@ -72,6 +72,11 @@ public: void writeNXDNBER(float ber); void clearNXDN(); + void writeM17(const char* source, const char* dest, const char* type); + void writeM17RSSI(unsigned char rssi); + void writeM17BER(float ber); + void clearM17(); + void writePOCSAG(uint32_t ric, const std::string& message); void clearPOCSAG(); @@ -118,6 +123,11 @@ protected: virtual void writeNXDNBERInt(float ber); virtual void clearNXDNInt() = 0; + virtual void writeM17Int(const char* source, const char* dest, const char* type) = 0; + virtual void writeM17RSSIInt(unsigned char rssi); + virtual void writeM17BERInt(float ber); + virtual void clearM17Int() = 0; + virtual void writePOCSAGInt(uint32_t ric, const std::string& message) = 0; virtual void clearPOCSAGInt() = 0; diff --git a/Nextion.cpp b/Nextion.cpp index fa6851e..2029aeb 100644 --- a/Nextion.cpp +++ b/Nextion.cpp @@ -36,6 +36,8 @@ const unsigned int P25_RSSI_COUNT = 7U; // 7 * 180ms = 1260ms const unsigned int P25_BER_COUNT = 7U; // 7 * 180ms = 1260ms const unsigned int NXDN_RSSI_COUNT = 28U; // 28 * 40ms = 1120ms const unsigned int NXDN_BER_COUNT = 28U; // 28 * 40ms = 1120ms +const unsigned int M17_RSSI_COUNT = 28U; // 28 * 40ms = 1120ms +const unsigned int M17_BER_COUNT = 28U; // 28 * 40ms = 1120ms #define LAYOUT_COMPAT_MASK (7 << 0) // compatibility for old setting #define LAYOUT_TA_ENABLE (1 << 4) // enable Talker Alias (TA) display @@ -822,6 +824,79 @@ void CNextion::clearNXDNInt() sendCommand("t3.txt=\"\""); } +void CNextion::writeM17Int(const char* source, const char* dest, const char* type) +{ + assert(source != NULL); + assert(dest != NULL); + assert(type != NULL); + + if (m_mode != MODE_M17) { + sendCommand("page M17"); + sendCommandAction(6U); + } + + char text[30U]; + if (m_brightness > 0) { + ::sprintf(text, "dim=%u", m_brightness); + sendCommand(text); + } + + ::sprintf(text, "t0.txt=\"%s %.10s\"", type, source); + sendCommand(text); + sendCommandAction(122U); + + ::sprintf(text, "t1.txt=\"%s\"", dest); + sendCommand(text); + sendCommandAction(123U); + + m_clockDisplayTimer.stop(); + + m_mode = MODE_M17; + m_rssiAccum1 = 0U; + m_berAccum1 = 0.0F; + m_rssiCount1 = 0U; + m_berCount1 = 0U; +} + +void CNextion::writeM17RSSIInt(unsigned char rssi) +{ + m_rssiAccum1 += rssi; + m_rssiCount1++; + + if (m_rssiCount1 == M17_RSSI_COUNT) { + char text[25U]; + ::sprintf(text, "t2.txt=\"-%udBm\"", m_rssiAccum1 / M17_RSSI_COUNT); + sendCommand(text); + sendCommandAction(124U); + m_rssiAccum1 = 0U; + m_rssiCount1 = 0U; + } +} + +void CNextion::writeM17BERInt(float ber) +{ + m_berAccum1 += ber; + m_berCount1++; + + if (m_berCount1 == M17_BER_COUNT) { + char text[25U]; + ::sprintf(text, "t3.txt=\"%.1f%%\"", m_berAccum1 / float(M17_BER_COUNT)); + sendCommand(text); + sendCommandAction(125U); + m_berAccum1 = 0.0F; + m_berCount1 = 0U; + } +} + +void CNextion::clearM17Int() +{ + sendCommand("t0.txt=\"Listening\""); + sendCommandAction(121U); + sendCommand("t1.txt=\"\""); + sendCommand("t2.txt=\"\""); + sendCommand("t3.txt=\"\""); +} + void CNextion::writePOCSAGInt(uint32_t ric, const std::string& message) { if (m_mode != MODE_POCSAG) { diff --git a/Nextion.h b/Nextion.h index 488372f..713fc90 100644 --- a/Nextion.h +++ b/Nextion.h @@ -70,6 +70,11 @@ protected: virtual void writeNXDNBERInt(float ber); virtual void clearNXDNInt(); + virtual void writeM17Int(const char* source, const char* dest, const char* type); + virtual void writeM17RSSIInt(unsigned char rssi); + virtual void writeM17BERInt(float ber); + virtual void clearM17Int(); + virtual void writePOCSAGInt(uint32_t ric, const std::string& message); virtual void clearPOCSAGInt(); diff --git a/NullDisplay.cpp b/NullDisplay.cpp index 2471e93..5708028 100644 --- a/NullDisplay.cpp +++ b/NullDisplay.cpp @@ -134,6 +134,20 @@ void CNullDisplay::clearNXDNInt() #endif } +void CNullDisplay::writeM17Int(const char* source, const char* dest, const char* type) +{ +#if defined(RASPBERRY_PI) + ::digitalWrite(LED_STATUS, 1); +#endif +} + +void CNullDisplay::clearM17Int() +{ +#if defined(RASPBERRY_PI) + ::digitalWrite(LED_STATUS, 0); +#endif +} + void CNullDisplay::writePOCSAGInt(uint32_t ric, const std::string& message) { #if defined(RASPBERRY_PI) diff --git a/NullDisplay.h b/NullDisplay.h index a222959..c53dc08 100644 --- a/NullDisplay.h +++ b/NullDisplay.h @@ -55,6 +55,9 @@ protected: virtual void writeNXDNInt(const char* source, bool group, unsigned int dest, const char* type); virtual void clearNXDNInt(); + virtual void writeM17Int(const char* source, const char* dest, const char* type); + virtual void clearM17Int(); + virtual void writePOCSAGInt(uint32_t ric, const std::string& message); virtual void clearPOCSAGInt(); diff --git a/TFTSerial.cpp b/TFTSerial.cpp index dab532e..2d0e9dc 100644 --- a/TFTSerial.cpp +++ b/TFTSerial.cpp @@ -397,7 +397,7 @@ void CTFTSerial::writeNXDNInt(const char* source, bool group, unsigned int dest, setFontSize(FONT_MEDIUM); - // Draw the P25 insignia + // Draw the NXDN insignia displayBitmap(0U, 0U, "NXDN_sm.bmp"); } @@ -427,6 +427,48 @@ void CTFTSerial::clearNXDNInt() displayText(" "); } +void CTFTSerial::writeM17Int(const char* source, const char* dest, const char* type) +{ + assert(source != NULL); + assert(dest != NULL); + assert(type != NULL); + + if (m_mode != MODE_M17) { + // Clear the screen + clearScreen(); + + setFontSize(FONT_MEDIUM); + + // Draw the M17 insignia + displayBitmap(0U, 0U, "M17_sm.bmp"); + } + + char text[30U]; + ::sprintf(text, "%s %.10s", type, source); + + gotoPosPixel(5U, 70U); + displayText(text); + + ::sprintf(text, " %s", dest); + + gotoPosPixel(5U, 90U); + displayText(text); + + m_mode = MODE_M17; +} + +void CTFTSerial::clearM17Int() +{ + gotoPosPixel(5U, 70U); + displayText(" Listening "); + + gotoPosPixel(5U, 90U); + displayText(" "); + + gotoPosPixel(5U, 110U); + displayText(" "); +} + void CTFTSerial::writePOCSAGInt(uint32_t ric, const std::string& message) { gotoPosPixel(15U, 90U); diff --git a/TFTSerial.h b/TFTSerial.h index d34e9da..86d4130 100644 --- a/TFTSerial.h +++ b/TFTSerial.h @@ -57,6 +57,9 @@ protected: virtual void writeNXDNInt(const char* source, bool group, unsigned int dest, const char* type); virtual void clearNXDNInt(); + virtual void writeM17Int(const char* source, const char* dest, const char* type); + virtual void clearM17Int(); + virtual void writePOCSAGInt(uint32_t ric, const std::string& message); virtual void clearPOCSAGInt(); diff --git a/TFTSurenoo.cpp b/TFTSurenoo.cpp index fc61ca9..c9498b6 100644 --- a/TFTSurenoo.cpp +++ b/TFTSurenoo.cpp @@ -77,6 +77,7 @@ enum LcdColour { #define STR_DSTAR "D-STAR" #define STR_MMDVM "MMDVM" #define STR_NXDN "NXDN" +#define STR_M17 "M17" #define STR_P25 "P25" #define STR_YSF "SystemFusion" @@ -358,6 +359,29 @@ void CTFTSurenoo::clearNXDNInt() clearDStarInt(); } +void CTFTSurenoo::writeM17Int(const char* source, const char* dest, const char* type) +{ + assert(source != NULL); + assert(dest != NULL); + assert(type != NULL); + + if (m_mode != MODE_M17) + setModeLine(STR_M17); + + ::snprintf(m_temp, sizeof(m_temp), "%s %s", type, source); + setStatusLine(statusLineNo(0), m_temp); + + ::snprintf(m_temp, sizeof(m_temp), "%s", dest); + setStatusLine(statusLineNo(1), m_temp); + + m_mode = MODE_M17; +} + +void CTFTSurenoo::clearM17Int() +{ + clearDStarInt(); +} + void CTFTSurenoo::writePOCSAGInt(uint32_t ric, const std::string& message) { setStatusLine(statusLineNo(1), "POCSAG TX"); diff --git a/TFTSurenoo.h b/TFTSurenoo.h index e21a17e..2e9abdb 100644 --- a/TFTSurenoo.h +++ b/TFTSurenoo.h @@ -61,6 +61,9 @@ protected: virtual int writeNXDNIntEx(const class CUserDBentry& source, bool group, unsigned int dest, const char* type); virtual void clearNXDNInt(); + virtual void writeM17Int(const char* source, const char* dest, const char* type); + virtual void clearM17Int(); + virtual void writePOCSAGInt(uint32_t ric, const std::string& message); virtual void clearPOCSAGInt();