From e14b650106edf54b27fa3b4badadfbed177cb530 Mon Sep 17 00:00:00 2001 From: KD4Z Date: Sat, 7 Apr 2018 11:49:12 -0400 Subject: [PATCH 1/9] OLED Display - Add IP address to display format Add IP address to bottom of screen by adjusting existing lines upward as far as possible. --- NetworkInfo.cpp | 4 ++-- OLED.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++------- OLED.h | 17 ++++++++++------ 3 files changed, 60 insertions(+), 15 deletions(-) diff --git a/NetworkInfo.cpp b/NetworkInfo.cpp index 1f97866..eb3ed6e 100644 --- a/NetworkInfo.cpp +++ b/NetworkInfo.cpp @@ -116,10 +116,10 @@ void CNetworkInfo::getNetworkInterface(unsigned char* info) } if (family == AF_INET) { - ::sprintf(interfacelist[ifnr], "%s: %s", ifa->ifa_name, host); + ::sprintf(interfacelist[ifnr], "%s:%s", ifa->ifa_name, host); LogInfo(" IPv4: %s", interfacelist[ifnr]); } else { - ::sprintf(interfacelist[ifnr], "%s: %s", ifa->ifa_name, host); + ::sprintf(interfacelist[ifnr], "%s:%s", ifa->ifa_name, host); LogInfo(" IPv6: %s", interfacelist[ifnr]); } diff --git a/OLED.cpp b/OLED.cpp index 1c64ec9..e3593f5 100644 --- a/OLED.cpp +++ b/OLED.cpp @@ -17,6 +17,10 @@ */ #include "OLED.h" +#include "Log.h" + +static bool networkInfoInitialized = false; +static unsigned char passCounter = 0; //Logo MMDVM for Idle Screen static unsigned char logo_glcd_bmp[] = @@ -117,6 +121,7 @@ COLED::~COLED() bool COLED::open() { + // SPI if (display.oled_is_spi_proto(m_displayType)) { @@ -131,6 +136,7 @@ bool COLED::open() return false; } + display.begin(); display.invertDisplay(m_displayInvert ? 1 : 0); @@ -163,6 +169,26 @@ void COLED::setIdleInt() // display.setTextSize(1); display.startscrolldiagright(0x00,0x0f); //the MMDVM logo scrolls the whole screen display.display(); + + unsigned char info[100U]; + CNetworkInfo* m_network; + + passCounter ++; + if (passCounter > 253U) + networkInfoInitialized = false; + + if (! networkInfoInitialized) { + LogMessage("Initialize CNetworkInfo"); + info[0]=0; + m_network = new CNetworkInfo; + m_network->getNetworkInterface(info); + m_ipaddress = (char*)info; + delete m_network; + + networkInfoInitialized = true; + passCounter = 0; + } + } void COLED::setErrorInt(const char* text) @@ -217,8 +243,11 @@ void COLED::clearDStarInt() { display.fillRect(0,OLED_LINE1, display.width(),display.height(),BLACK); //clear everything beneath the logo - display.setCursor(40,38); + display.setCursor(40,OLED_LINE2); display.print("Listening"); + + display.setCursor(0,OLED_LINE5); + display.printf("%s",m_ipaddress.c_str()); display.display(); } @@ -243,7 +272,6 @@ void COLED::writeDMRInt(unsigned int slotNo,const std::string& src,bool group,co display.fillRect(0,OLED_LINE2,display.width(),20,BLACK); //20=> clear 2 lines display.setCursor(0,OLED_LINE2); display.print("1 Listening"); - } } @@ -263,7 +291,8 @@ void COLED::writeDMRInt(unsigned int slotNo,const std::string& src,bool group,co display.setCursor(0,OLED_LINE5); display.printf("%s%s", group ? "TG" : "", dst.c_str()); } - + display.setCursor(0,OLED_LINE6); + display.printf("%s",m_ipaddress.c_str()); OLED_statusbar(); display.display(); } @@ -281,8 +310,10 @@ void COLED::clearDMRInt(unsigned int slotNo) display.fillRect(0, OLED_LINE4, display.width(), 20, BLACK); display.setCursor(0, OLED_LINE4); display.print("2 Listening"); - } + } + display.setCursor(0,OLED_LINE6); + display.printf("%s",m_ipaddress.c_str()); display.display(); } @@ -308,8 +339,11 @@ void COLED::clearFusionInt() { display.fillRect(0, OLED_LINE1, display.width(), display.height(), BLACK); - display.setCursor(40,38); + display.setCursor(40,OLED_LINE2); display.print("Listening"); + + display.setCursor(0,OLED_LINE5); + display.printf("%s",m_ipaddress.c_str()); display.display(); } @@ -335,8 +369,11 @@ void COLED::clearP25Int() { display.fillRect(0, OLED_LINE1, display.width(), display.height(), BLACK); - display.setCursor(40,38); + display.setCursor(40,OLED_LINE2); display.print("Listening"); + + display.setCursor(0,OLED_LINE5); + display.printf("%s",m_ipaddress.c_str()); display.display(); } @@ -362,8 +399,11 @@ void COLED::clearNXDNInt() { display.fillRect(0, OLED_LINE1, display.width(), display.height(), BLACK); - display.setCursor(40,38); + display.setCursor(40,OLED_LINE2); display.print("Listening"); + + display.setCursor(0,OLED_LINE5); + display.printf("%s",m_ipaddress.c_str()); display.display(); } diff --git a/OLED.h b/OLED.h index 06c4739..cb94581 100644 --- a/OLED.h +++ b/OLED.h @@ -20,11 +20,12 @@ #define OLED_H #define OLED_STATUSBAR 0 -#define OLED_LINE1 16 -#define OLED_LINE2 26 -#define OLED_LINE3 36 -#define OLED_LINE4 46 -#define OLED_LINE5 56 +#define OLED_LINE1 8 //16 +#define OLED_LINE2 18 //26 +#define OLED_LINE3 28 //36 +#define OLED_LINE4 37 //46 +#define OLED_LINE5 47 //56 +#define OLED_LINE6 57 #include "Display.h" #include "Defines.h" @@ -34,6 +35,7 @@ #include "ArduiPi_OLED_lib.h" #include "Adafruit_GFX.h" #include "ArduiPi_OLED.h" +#include "NetworkInfo.h" class COLED : public CDisplay { @@ -76,9 +78,12 @@ private: unsigned char m_displayBrightness; bool m_displayInvert; bool m_displayScroll; - + std::string m_ipaddress; + ArduiPi_OLED display; void OLED_statusbar(); + + }; #endif From c623ba8730e47b21fa1ab9e33f3cccc83207be1a Mon Sep 17 00:00:00 2001 From: KD4Z Date: Sat, 7 Apr 2018 18:39:29 -0400 Subject: [PATCH 2/9] Screen layout changes Fusion / D-Star line position adjustments --- OLED.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/OLED.cpp b/OLED.cpp index e3593f5..0935f22 100644 --- a/OLED.cpp +++ b/OLED.cpp @@ -224,15 +224,15 @@ void COLED::writeDStarInt(const char* my1, const char* my2, const char* your, co m_mode = MODE_DSTAR; display.clearDisplay(); - display.fillRect(0,OLED_LINE1,display.width(),display.height(),BLACK); //clear everything beneath logo + display.fillRect(0,OLED_LINE3,display.width(),display.height(),BLACK); //clear everything beneath logo - display.setCursor(0,OLED_LINE2); + display.setCursor(0,OLED_LINE4); display.printf("%s %.8s/%4.4s",type,my1,my2); - display.setCursor(0,OLED_LINE3); + display.setCursor(0,OLED_LINE5); display.printf("-> %.8s",your); - display.setCursor(0,OLED_LINE5); + display.setCursor(0,OLED_LINE6); display.printf("via %.8s",reflector); OLED_statusbar(); @@ -241,9 +241,9 @@ void COLED::writeDStarInt(const char* my1, const char* my2, const char* your, co void COLED::clearDStarInt() { - display.fillRect(0,OLED_LINE1, display.width(),display.height(),BLACK); //clear everything beneath the logo + display.fillRect(0,OLED_LINE3, display.width(),display.height(),BLACK); //clear everything beneath the logo - display.setCursor(40,OLED_LINE2); + display.setCursor(40,OLED_LINE3); display.print("Listening"); display.setCursor(0,OLED_LINE5); @@ -323,12 +323,12 @@ void COLED::writeFusionInt(const char* source, const char* dest, const char* typ m_mode = MODE_YSF; display.clearDisplay(); - display.fillRect(0,OLED_LINE1,display.width(),display.height(),BLACK); + display.fillRect(0,OLED_LINE2,display.width(),display.height(),BLACK); - display.setCursor(0,OLED_LINE2); + display.setCursor(0,OLED_LINE4); display.printf("%s %.10s", type, source); - display.setCursor(0,OLED_LINE3); + display.setCursor(0,OLED_LINE5); display.printf(" %.10s", dest); OLED_statusbar(); @@ -337,12 +337,12 @@ void COLED::writeFusionInt(const char* source, const char* dest, const char* typ void COLED::clearFusionInt() { - display.fillRect(0, OLED_LINE1, display.width(), display.height(), BLACK); + display.fillRect(0, OLED_LINE2, display.width(), display.height(), BLACK); - display.setCursor(40,OLED_LINE2); + display.setCursor(40,OLED_LINE4); display.print("Listening"); - display.setCursor(0,OLED_LINE5); + display.setCursor(0,OLED_LINE6); display.printf("%s",m_ipaddress.c_str()); display.display(); @@ -355,10 +355,10 @@ void COLED::writeP25Int(const char* source, bool group, unsigned int dest, const display.clearDisplay(); display.fillRect(0, OLED_LINE1, display.width(), display.height(), BLACK); - display.setCursor(0,OLED_LINE2); + display.setCursor(0,OLED_LINE3); display.printf("%s %.10s", type, source); - display.setCursor(0,OLED_LINE3); + display.setCursor(0,OLED_LINE4); display.printf(" %s%u", group ? "TG" : "", dest); OLED_statusbar(); @@ -369,10 +369,10 @@ void COLED::clearP25Int() { display.fillRect(0, OLED_LINE1, display.width(), display.height(), BLACK); - display.setCursor(40,OLED_LINE2); + display.setCursor(40,OLED_LINE4); display.print("Listening"); - display.setCursor(0,OLED_LINE5); + display.setCursor(0,OLED_LINE6); display.printf("%s",m_ipaddress.c_str()); display.display(); @@ -385,10 +385,10 @@ void COLED::writeNXDNInt(const char* source, bool group, unsigned int dest, cons display.clearDisplay(); display.fillRect(0, OLED_LINE1, display.width(), display.height(), BLACK); - display.setCursor(0,OLED_LINE2); + display.setCursor(0,OLED_LINE3); display.printf("%s %.10s", type, source); - display.setCursor(0,OLED_LINE3); + display.setCursor(0,OLED_LINE5); display.printf(" %s%u", group ? "TG" : "", dest); OLED_statusbar(); @@ -399,10 +399,10 @@ void COLED::clearNXDNInt() { display.fillRect(0, OLED_LINE1, display.width(), display.height(), BLACK); - display.setCursor(40,OLED_LINE2); + display.setCursor(40,OLED_LINE4); display.print("Listening"); - display.setCursor(0,OLED_LINE5); + display.setCursor(0,OLED_LINE6); display.printf("%s",m_ipaddress.c_str()); display.display(); From c1d7c0972f64bdf2e1038df38ec5898b5bb53d71 Mon Sep 17 00:00:00 2001 From: KD4Z Date: Sun, 8 Apr 2018 18:29:35 -0400 Subject: [PATCH 3/9] OLED Display - Hide unused slot and center active one If one slot is disabled, show active slot information only --- OLED.cpp | 113 +++++++++++++++++++++++++++++++------------------------ OLED.h | 6 +-- 2 files changed, 66 insertions(+), 53 deletions(-) diff --git a/OLED.cpp b/OLED.cpp index 0935f22..3e2fdd8 100644 --- a/OLED.cpp +++ b/OLED.cpp @@ -107,11 +107,13 @@ const unsigned char logo_fusion_bmp [] = }; -COLED::COLED(unsigned char displayType, unsigned char displayBrightness, bool displayInvert, bool displayScroll) : +COLED::COLED(unsigned char displayType, unsigned char displayBrightness, bool displayInvert, bool displayScroll, bool slot1Enabled, bool slot2Enabled) : m_displayType(displayType), m_displayBrightness(displayBrightness), m_displayInvert(displayInvert), -m_displayScroll(displayScroll) +m_displayScroll(displayScroll), +m_slot1Enabled(slot1Enabled), +m_slot2Enabled(slot2Enabled) { } @@ -148,7 +150,7 @@ bool COLED::open() display.display(); // display it (clear display) OLED_statusbar(); - display.setCursor(0,OLED_LINE1); + display.setCursor(0,OLED_LINE3); display.print("Startup"); display.display(); @@ -257,41 +259,41 @@ void COLED::writeDMRInt(unsigned int slotNo,const std::string& src,bool group,co if (m_mode != MODE_DMR) { - display.clearDisplay(); - - m_mode = MODE_DMR; - - if (slotNo == 1U) - { - display.fillRect(0,OLED_LINE4,display.width(),20,BLACK); //20=> clear 2 lines - display.setCursor(0,OLED_LINE4); - display.print("2 Listening"); - } - else - { - display.fillRect(0,OLED_LINE2,display.width(),20,BLACK); //20=> clear 2 lines - display.setCursor(0,OLED_LINE2); - display.print("1 Listening"); - } + display.clearDisplay(); + m_mode = MODE_DMR; + clearDMRInt(slotNo); + } - - if (slotNo == 1U) - { - display.fillRect(0,OLED_LINE2,display.width(),20,BLACK); - display.setCursor(0,OLED_LINE2); - display.printf("%i %s %s",slotNo,type,src.c_str()); - display.setCursor(0,OLED_LINE3); - display.printf("%s%s",group ? "TG" : "",dst.c_str()); - } - else - { - display.fillRect(0,OLED_LINE4,display.width(),20,BLACK); - display.setCursor(0,OLED_LINE4); - display.printf("%i %s %s",slotNo,type,src.c_str()); - display.setCursor(0,OLED_LINE5); - display.printf("%s%s", group ? "TG" : "", dst.c_str()); - } - display.setCursor(0,OLED_LINE6); + // if both slots, use lines 2-3 for slot 1, lines 4-5 for slot 2 + // if single slot, use lines 3-4 + if ( m_slot1Enabled && m_slot2Enabled ){ + if (slotNo == 1U) + { + display.fillRect(0,OLED_LINE2,display.width(),40,BLACK); + display.setCursor(0,OLED_LINE2); + display.printf("%i %s %s",slotNo,type,src.c_str()); + display.setCursor(0,OLED_LINE3); + display.printf("%s%s",group ? "TG" : "",dst.c_str()); + } + else + { + display.fillRect(0,OLED_LINE4,display.width(),40,BLACK); + display.setCursor(0,OLED_LINE4); + display.printf("%i %s %s",slotNo,type,src.c_str()); + display.setCursor(0,OLED_LINE5); + display.printf("%s%s", group ? "TG" : "", dst.c_str()); + } + } + else { + display.fillRect(0,OLED_LINE3,display.width(),40,BLACK); + display.setCursor(0,OLED_LINE3); + display.printf("%i %s %s",slotNo,type,src.c_str()); + display.setCursor(0,OLED_LINE4); + display.printf("%s%s",group ? "TG" : "",dst.c_str()); + } + + display.fillRect(0,OLED_LINE6,display.width(),20,BLACK); + display.setCursor(0,OLED_LINE6); display.printf("%s",m_ipaddress.c_str()); OLED_statusbar(); display.display(); @@ -299,20 +301,31 @@ void COLED::writeDMRInt(unsigned int slotNo,const std::string& src,bool group,co void COLED::clearDMRInt(unsigned int slotNo) { - if (slotNo == 1U) - { - display.fillRect(0, OLED_LINE2, display.width(), 20, BLACK); - display.setCursor(0,OLED_LINE2); - display.print("1 Listening"); - } - else - { - display.fillRect(0, OLED_LINE4, display.width(), 20, BLACK); - display.setCursor(0, OLED_LINE4); - display.print("2 Listening"); + // if both slots, use lines 2-3 for slot 1, lines 4-5 for slot 2 + // if single slot, use lines 3-4 + if ( m_slot1Enabled && m_slot2Enabled ){ + if (slotNo == 1U) + { + display.fillRect(0, OLED_LINE2, display.width(), 40, BLACK); + display.setCursor(0,OLED_LINE2); + display.print("1 Listening"); + } + else + { + display.fillRect(0, OLED_LINE4, display.width(), 40, BLACK); + display.setCursor(0, OLED_LINE4); + display.print("2 Listening"); + } + } + else { + display.fillRect(0, OLED_LINE3, display.width(), 40, BLACK); + display.setCursor(0,OLED_LINE3); + display.printf("%i Listening",slotNo); + } - } - display.setCursor(0,OLED_LINE6); + + display.fillRect(0, OLED_LINE5, display.width(), 20, BLACK); + display.setCursor(0,OLED_LINE5); display.printf("%s",m_ipaddress.c_str()); display.display(); } diff --git a/OLED.h b/OLED.h index cb94581..0379acd 100644 --- a/OLED.h +++ b/OLED.h @@ -40,7 +40,7 @@ class COLED : public CDisplay { public: - COLED(unsigned char displayType, unsigned char displayBrighness, bool displayInvert, bool displayScroll); + COLED(unsigned char displayType, unsigned char displayBrighness, bool displayInvert, bool displayScroll, bool slot1Enabled, bool slot2Enabled); virtual ~COLED(); virtual bool open(); @@ -78,12 +78,12 @@ private: unsigned char m_displayBrightness; bool m_displayInvert; bool m_displayScroll; + bool m_slot1Enabled; + bool m_slot2Enabled; std::string m_ipaddress; ArduiPi_OLED display; void OLED_statusbar(); - - }; #endif From e790ea3f71a81a615bb097058b5f3e8c78be795f Mon Sep 17 00:00:00 2001 From: KD4Z Date: Mon, 9 Apr 2018 12:53:57 -0400 Subject: [PATCH 4/9] OLED Display - missing ref forgot to include the hook to pass the slot enables down into the driver --- MMDVMHost.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 3ad78b0..0cf02a9 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -1389,7 +1389,7 @@ void CMMDVMHost::createDisplay() unsigned char brightness = m_conf.getOLEDBrightness(); bool invert = m_conf.getOLEDInvert(); bool scroll = m_conf.getOLEDScroll(); - m_display = new COLED(type, brightness, invert, scroll); + m_display = new COLED(type, brightness, invert, scroll, m_conf.getDMRNetworkSlot1(), m_conf.getDMRNetworkSlot2()); #endif } else { m_display = new CNullDisplay; From 98da418700112549e5f88437cca516bc0e6e510e Mon Sep 17 00:00:00 2001 From: KD4Z Date: Mon, 9 Apr 2018 17:24:03 -0400 Subject: [PATCH 5/9] OLED Display - Add first name with callsign Rearrainged layout somewhat. --- OLED.cpp | 78 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 38 deletions(-) diff --git a/OLED.cpp b/OLED.cpp index 3e2fdd8..047f2e3 100644 --- a/OLED.cpp +++ b/OLED.cpp @@ -258,46 +258,48 @@ void COLED::writeDMRInt(unsigned int slotNo,const std::string& src,bool group,co { if (m_mode != MODE_DMR) { - display.clearDisplay(); m_mode = MODE_DMR; clearDMRInt(slotNo); - - } + } // if both slots, use lines 2-3 for slot 1, lines 4-5 for slot 2 // if single slot, use lines 3-4 - if ( m_slot1Enabled && m_slot2Enabled ){ - if (slotNo == 1U) - { - display.fillRect(0,OLED_LINE2,display.width(),40,BLACK); - display.setCursor(0,OLED_LINE2); - display.printf("%i %s %s",slotNo,type,src.c_str()); - display.setCursor(0,OLED_LINE3); - display.printf("%s%s",group ? "TG" : "",dst.c_str()); - } + if ( m_slot1Enabled && m_slot2Enabled ) { + + if (slotNo == 1U) { + display.fillRect(0,OLED_LINE2,display.width(),40,BLACK); + display.setCursor(0,OLED_LINE2); + display.printf("%s",src.c_str()); + display.setCursor(0,OLED_LINE3); + display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG" : "",dst.c_str()); + } else - { - display.fillRect(0,OLED_LINE4,display.width(),40,BLACK); - display.setCursor(0,OLED_LINE4); - display.printf("%i %s %s",slotNo,type,src.c_str()); - display.setCursor(0,OLED_LINE5); - display.printf("%s%s", group ? "TG" : "", dst.c_str()); - } + { + display.fillRect(0,OLED_LINE4,display.width(),40,BLACK); + display.setCursor(0,OLED_LINE4); + display.printf("%s",src.c_str()); + display.setCursor(0,OLED_LINE5); + display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG" : "",dst.c_str()); + } + } - else { - display.fillRect(0,OLED_LINE3,display.width(),40,BLACK); - display.setCursor(0,OLED_LINE3); - display.printf("%i %s %s",slotNo,type,src.c_str()); - display.setCursor(0,OLED_LINE4); - display.printf("%s%s",group ? "TG" : "",dst.c_str()); + else + { + display.fillRect(0,OLED_LINE3,display.width(),20,BLACK); + display.setCursor(0,OLED_LINE3); + display.printf("%s",src.c_str()); + display.setCursor(0,OLED_LINE4); + display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG" : "",dst.c_str()); } - + display.fillRect(0,OLED_LINE6,display.width(),20,BLACK); display.setCursor(0,OLED_LINE6); display.printf("%s",m_ipaddress.c_str()); + OLED_statusbar(); display.display(); -} + + } void COLED::clearDMRInt(unsigned int slotNo) { @@ -306,26 +308,26 @@ void COLED::clearDMRInt(unsigned int slotNo) if ( m_slot1Enabled && m_slot2Enabled ){ if (slotNo == 1U) { - display.fillRect(0, OLED_LINE2, display.width(), 40, BLACK); - display.setCursor(0,OLED_LINE2); - display.print("1 Listening"); + display.fillRect(0, OLED_LINE3, display.width(), 40, BLACK); + display.setCursor(0,OLED_LINE3); + display.print("Slot: 1 Listening"); } else { - display.fillRect(0, OLED_LINE4, display.width(), 40, BLACK); - display.setCursor(0, OLED_LINE4); - display.print("2 Listening"); + display.fillRect(0, OLED_LINE5, display.width(), 40, BLACK); + display.setCursor(0, OLED_LINE5); + display.print("Slot: 2 Listening"); } } else { - display.fillRect(0, OLED_LINE3, display.width(), 40, BLACK); - display.setCursor(0,OLED_LINE3); - display.printf("%i Listening",slotNo); + display.fillRect(0, OLED_LINE4, display.width(), 40, BLACK); + display.setCursor(0,OLED_LINE4); + display.printf("Slot: %i Listening",slotNo); } - display.fillRect(0, OLED_LINE5, display.width(), 20, BLACK); - display.setCursor(0,OLED_LINE5); + display.fillRect(0, OLED_LINE6, display.width(), 20, BLACK); + display.setCursor(0,OLED_LINE6); display.printf("%s",m_ipaddress.c_str()); display.display(); } From 9d6bcb7ec880d8b8a97e4b9383724e57f31948fb Mon Sep 17 00:00:00 2001 From: KD4Z Date: Tue, 10 Apr 2018 18:08:48 -0400 Subject: [PATCH 6/9] Fix dashboard conflict, add IP address to D-Star screen Tag: Version "v20180328.3z" --- DMRLookup.cpp | 50 +++++++++++++++++++++++++++++++++++++++++++++----- DMRLookup.h | 1 + DMRSlot.cpp | 6 +++--- OLED.cpp | 17 ++++++++++------- 4 files changed, 59 insertions(+), 15 deletions(-) diff --git a/DMRLookup.cpp b/DMRLookup.cpp index d41df5d..8842a60 100644 --- a/DMRLookup.cpp +++ b/DMRLookup.cpp @@ -81,7 +81,7 @@ void CDMRLookup::stop() wait(); } -std::string CDMRLookup::find(unsigned int id) +std::string CDMRLookup::findwithname(unsigned int id) { std::string callsign; @@ -92,6 +92,40 @@ std::string CDMRLookup::find(unsigned int id) try { callsign = m_table.at(id); + LogDebug("Findwithname Found =%s",callsign.c_str()); + + } catch (...) { + char text[10U]; + ::sprintf(text, "%u", id); + callsign = std::string(text); + } + + m_mutex.unlock(); + + return callsign; +} +std::string CDMRLookup::find(unsigned int id) +{ + std::string callsign; + std::string b; + + + if (id == 0xFFFFFFU) + return std::string("ALL"); + + m_mutex.lock(); + + try { + b = m_table.at(id); + size_t n = b.find(" "); + if (n > 0) { + callsign = b.substr(0,n); + + } else { + LogDebug("b=%s",b.c_str()); + callsign = b; + } + } catch (...) { char text[10U]; ::sprintf(text, "%u", id); @@ -133,13 +167,19 @@ bool CDMRLookup::load() continue; char* p1 = ::strtok(buffer, " \t\r\n"); - char* p2 = ::strtok(NULL, " \t\r\n"); + char* p2 = ::strtok(NULL, " \r\n"); // tokenize to eol to capture name as well if (p1 != NULL && p2 != NULL) { unsigned int id = (unsigned int)::atoi(p1); - for (char* p = p2; *p != 0x00U; p++) - *p = ::toupper(*p); - + for (char* p = p2; *p != 0x00U; p++) { + + if(*p == 0x09U) + *p = 0x20U; + + else + *p = ::toupper(*p); + + } m_table[id] = std::string(p2); } } diff --git a/DMRLookup.h b/DMRLookup.h index ed09ac2..54b78e7 100644 --- a/DMRLookup.h +++ b/DMRLookup.h @@ -35,6 +35,7 @@ public: virtual void entry(); std::string find(unsigned int id); + std::string findwithname(unsigned int id); bool exists(unsigned int id); diff --git a/DMRSlot.cpp b/DMRSlot.cpp index 001c6f4..913a97f 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -1067,16 +1067,16 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) m_netState = RS_NET_AUDIO; setShortLC(m_slotNo, dstId, flco, ACTIVITY_VOICE); - std::string src = m_lookup->find(srcId); std::string dst = m_lookup->find(dstId); - - m_display->writeDMR(m_slotNo, src, flco == FLCO_GROUP, dst, "N"); + std::string cn = m_lookup->findwithname(srcId); + m_display->writeDMR(m_slotNo, cn, flco == FLCO_GROUP, dst, "N"); #if defined(DUMP_DMR) openFile(); writeFile(data); #endif + LogMessage("DMR Slot %u, received network voice header from %s to %s%s", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str()); } else if (dataType == DT_VOICE_PI_HEADER) { if (m_netState != RS_NET_AUDIO) { diff --git a/OLED.cpp b/OLED.cpp index 047f2e3..eeef003 100644 --- a/OLED.cpp +++ b/OLED.cpp @@ -180,7 +180,7 @@ void COLED::setIdleInt() networkInfoInitialized = false; if (! networkInfoInitialized) { - LogMessage("Initialize CNetworkInfo"); + //LogMessage("Initialize CNetworkInfo"); info[0]=0; m_network = new CNetworkInfo; m_network->getNetworkInterface(info); @@ -228,14 +228,17 @@ void COLED::writeDStarInt(const char* my1, const char* my2, const char* your, co display.clearDisplay(); display.fillRect(0,OLED_LINE3,display.width(),display.height(),BLACK); //clear everything beneath logo - display.setCursor(0,OLED_LINE4); + display.setCursor(0,OLED_LINE3); display.printf("%s %.8s/%4.4s",type,my1,my2); - display.setCursor(0,OLED_LINE5); + display.setCursor(0,OLED_LINE4); display.printf("-> %.8s",your); - display.setCursor(0,OLED_LINE6); + display.setCursor(0,OLED_LINE5); display.printf("via %.8s",reflector); + + display.setCursor(0,OLED_LINE6); + display.printf("%s",m_ipaddress.c_str()); OLED_statusbar(); display.display(); @@ -271,7 +274,7 @@ void COLED::writeDMRInt(unsigned int slotNo,const std::string& src,bool group,co display.setCursor(0,OLED_LINE2); display.printf("%s",src.c_str()); display.setCursor(0,OLED_LINE3); - display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG" : "",dst.c_str()); + display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG: " : "",dst.c_str()); } else { @@ -279,7 +282,7 @@ void COLED::writeDMRInt(unsigned int slotNo,const std::string& src,bool group,co display.setCursor(0,OLED_LINE4); display.printf("%s",src.c_str()); display.setCursor(0,OLED_LINE5); - display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG" : "",dst.c_str()); + display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG: " : "",dst.c_str()); } } @@ -289,7 +292,7 @@ void COLED::writeDMRInt(unsigned int slotNo,const std::string& src,bool group,co display.setCursor(0,OLED_LINE3); display.printf("%s",src.c_str()); display.setCursor(0,OLED_LINE4); - display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG" : "",dst.c_str()); + display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG: " : "",dst.c_str()); } display.fillRect(0,OLED_LINE6,display.width(),20,BLACK); From db762d992c51712eec02b99e0cc683f25eaf3581 Mon Sep 17 00:00:00 2001 From: KD4Z Date: Wed, 11 Apr 2018 21:34:25 -0400 Subject: [PATCH 7/9] Add graphic banners for P25 and NXDN modes --- OLED.cpp | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) diff --git a/OLED.cpp b/OLED.cpp index eeef003..84e2b14 100644 --- a/OLED.cpp +++ b/OLED.cpp @@ -106,6 +106,47 @@ const unsigned char logo_fusion_bmp [] = 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + //Logo P25 128x16px + const unsigned char logo_P25_bmp [] = + { +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xf8, 0x00, 0x00, 0x00, 0x7f, 0xff, 0xfc, 0x00, 0x00, 0x3f, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x7f, +0xf8, 0x00, 0x00, 0x00, 0x03, 0xff, 0xc0, 0x00, 0x00, 0x03, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x7f, +0xf8, 0x00, 0xe0, 0x00, 0x00, 0xff, 0x00, 0x07, 0xc0, 0x00, 0xff, 0xe0, 0x00, 0x00, 0x00, 0xff, +0xf0, 0x01, 0xff, 0xfc, 0x00, 0x7e, 0x00, 0x3f, 0xf8, 0x00, 0xff, 0xe0, 0x0f, 0xff, 0xff, 0xff, +0xf0, 0x01, 0xff, 0xfe, 0x00, 0x7c, 0x00, 0x7f, 0xfc, 0x00, 0x7f, 0xe0, 0x0f, 0xff, 0xff, 0xff, +0xf0, 0x01, 0xff, 0xfe, 0x00, 0x7e, 0x00, 0x7f, 0xf8, 0x00, 0xff, 0xe0, 0x00, 0x00, 0x01, 0xff, +0xf0, 0x01, 0xff, 0xc0, 0x00, 0xff, 0xff, 0xff, 0xe0, 0x01, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x1f, +0xf0, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0x00, 0x07, 0xff, 0xff, 0x9f, 0xff, 0x80, 0x07, +0xf0, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xf8, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x03, +0xf0, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0x80, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x03, +0xf0, 0x01, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x1f, 0xff, 0xff, 0xc0, 0xff, 0xff, 0xc0, 0x03, +0xf0, 0x01, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x7f, 0xff, 0xfe, 0x00, 0x0f, 0xfe, 0x00, 0x0f, +0xf0, 0x01, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x80, 0x00, 0x00, 0x00, 0x3f, +0xf0, 0x01, 0xff, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xf8, 0x00, 0x00, 0x03, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff + }; + + //Logo NXDN 128x16px +const unsigned char logo_NXDN_bmp [] = + { +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xe0, 0x3f, 0xfe, 0x03, 0xc0, 0x3f, 0xfc, 0x07, 0xe0, 0x00, 0x0f, 0xff, 0xe0, 0x1f, 0xfe, 0x03, +0xe0, 0x0f, 0xfe, 0x03, 0xf0, 0x1f, 0xf0, 0x0f, 0xc0, 0x00, 0x00, 0x7f, 0xe0, 0x0f, 0xfe, 0x03, +0xe0, 0x07, 0xfe, 0x03, 0xf8, 0x07, 0xe0, 0x1f, 0xc0, 0x00, 0x00, 0x1f, 0xe0, 0x07, 0xfe, 0x03, +0xe0, 0x03, 0xfe, 0x03, 0xfe, 0x03, 0xc0, 0x7f, 0xc0, 0x7f, 0xf8, 0x07, 0xe0, 0x01, 0xfe, 0x03, +0xe0, 0x00, 0xfe, 0x03, 0xff, 0x01, 0x00, 0xff, 0xc0, 0x7f, 0xfc, 0x07, 0xe0, 0x00, 0xfe, 0x03, +0xe0, 0x20, 0x7e, 0x03, 0xff, 0x80, 0x03, 0xff, 0xc0, 0x7f, 0xfe, 0x03, 0xe0, 0x20, 0x7e, 0x03, +0xe0, 0x30, 0x3e, 0x03, 0xff, 0xe0, 0x07, 0xff, 0xc0, 0x7f, 0xfe, 0x03, 0xe0, 0x30, 0x1e, 0x03, +0xe0, 0x3c, 0x0e, 0x03, 0xff, 0xe0, 0x0f, 0xff, 0xc0, 0x7f, 0xfe, 0x03, 0xe0, 0x3c, 0x0e, 0x03, +0xe0, 0x3e, 0x06, 0x03, 0xff, 0xc0, 0x03, 0xff, 0xc0, 0x7f, 0xfe, 0x03, 0xe0, 0x3e, 0x06, 0x03, +0xe0, 0x3f, 0x02, 0x03, 0xff, 0x00, 0x01, 0xff, 0xc0, 0x7f, 0xfc, 0x07, 0xe0, 0x3f, 0x00, 0x03, +0xe0, 0x3f, 0xc0, 0x03, 0xfe, 0x01, 0x80, 0x7f, 0xc0, 0x7f, 0xf8, 0x07, 0xe0, 0x3f, 0xc0, 0x03, +0xe0, 0x3f, 0xe0, 0x03, 0xfc, 0x07, 0xc0, 0x3f, 0xc0, 0x7f, 0xe0, 0x0f, 0xe0, 0x3f, 0xe0, 0x03, +0xe0, 0x3f, 0xf0, 0x03, 0xf0, 0x0f, 0xf0, 0x0f, 0xc0, 0x00, 0x00, 0x3f, 0xe0, 0x3f, 0xf8, 0x03, +0xe0, 0x3f, 0xfc, 0x03, 0xe0, 0x3f, 0xf8, 0x07, 0xc0, 0x00, 0x00, 0xff, 0xe0, 0x3f, 0xfc, 0x03, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff +}; COLED::COLED(unsigned char displayType, unsigned char displayBrightness, bool displayInvert, bool displayScroll, bool slot1Enabled, bool slot2Enabled) : m_displayType(displayType), @@ -479,9 +520,9 @@ void COLED::OLED_statusbar() else if (m_mode == MODE_YSF) display.drawBitmap(0, 0, logo_fusion_bmp, 128, 16, WHITE); else if (m_mode == MODE_P25) - display.print("P25"); + display.drawBitmap(0, 0, logo_P25_bmp, 128, 16, WHITE); else if (m_mode == MODE_NXDN) - display.print("NXDN"); + display.drawBitmap(0, 0, logo_NXDN_bmp, 128, 16, WHITE); else display.drawBitmap(0, 0, logo_glcd_bmp, 128, 16, WHITE); From 4737fcb93570ab4770e4ddf08cce3009b0995925 Mon Sep 17 00:00:00 2001 From: KD4Z Date: Thu, 12 Apr 2018 08:36:17 -0400 Subject: [PATCH 8/9] OLED Display - update NXDN graphic --- OLED.cpp | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/OLED.cpp b/OLED.cpp index 84e2b14..d718a2a 100644 --- a/OLED.cpp +++ b/OLED.cpp @@ -127,24 +127,24 @@ const unsigned char logo_fusion_bmp [] = 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; - //Logo NXDN 128x16px +// Logo NXDN_sm, 128x16px const unsigned char logo_NXDN_bmp [] = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, -0xe0, 0x3f, 0xfe, 0x03, 0xc0, 0x3f, 0xfc, 0x07, 0xe0, 0x00, 0x0f, 0xff, 0xe0, 0x1f, 0xfe, 0x03, -0xe0, 0x0f, 0xfe, 0x03, 0xf0, 0x1f, 0xf0, 0x0f, 0xc0, 0x00, 0x00, 0x7f, 0xe0, 0x0f, 0xfe, 0x03, -0xe0, 0x07, 0xfe, 0x03, 0xf8, 0x07, 0xe0, 0x1f, 0xc0, 0x00, 0x00, 0x1f, 0xe0, 0x07, 0xfe, 0x03, -0xe0, 0x03, 0xfe, 0x03, 0xfe, 0x03, 0xc0, 0x7f, 0xc0, 0x7f, 0xf8, 0x07, 0xe0, 0x01, 0xfe, 0x03, -0xe0, 0x00, 0xfe, 0x03, 0xff, 0x01, 0x00, 0xff, 0xc0, 0x7f, 0xfc, 0x07, 0xe0, 0x00, 0xfe, 0x03, -0xe0, 0x20, 0x7e, 0x03, 0xff, 0x80, 0x03, 0xff, 0xc0, 0x7f, 0xfe, 0x03, 0xe0, 0x20, 0x7e, 0x03, -0xe0, 0x30, 0x3e, 0x03, 0xff, 0xe0, 0x07, 0xff, 0xc0, 0x7f, 0xfe, 0x03, 0xe0, 0x30, 0x1e, 0x03, -0xe0, 0x3c, 0x0e, 0x03, 0xff, 0xe0, 0x0f, 0xff, 0xc0, 0x7f, 0xfe, 0x03, 0xe0, 0x3c, 0x0e, 0x03, -0xe0, 0x3e, 0x06, 0x03, 0xff, 0xc0, 0x03, 0xff, 0xc0, 0x7f, 0xfe, 0x03, 0xe0, 0x3e, 0x06, 0x03, -0xe0, 0x3f, 0x02, 0x03, 0xff, 0x00, 0x01, 0xff, 0xc0, 0x7f, 0xfc, 0x07, 0xe0, 0x3f, 0x00, 0x03, -0xe0, 0x3f, 0xc0, 0x03, 0xfe, 0x01, 0x80, 0x7f, 0xc0, 0x7f, 0xf8, 0x07, 0xe0, 0x3f, 0xc0, 0x03, -0xe0, 0x3f, 0xe0, 0x03, 0xfc, 0x07, 0xc0, 0x3f, 0xc0, 0x7f, 0xe0, 0x0f, 0xe0, 0x3f, 0xe0, 0x03, -0xe0, 0x3f, 0xf0, 0x03, 0xf0, 0x0f, 0xf0, 0x0f, 0xc0, 0x00, 0x00, 0x3f, 0xe0, 0x3f, 0xf8, 0x03, -0xe0, 0x3f, 0xfc, 0x03, 0xe0, 0x3f, 0xf8, 0x07, 0xc0, 0x00, 0x00, 0xff, 0xe0, 0x3f, 0xfc, 0x03, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xf0, 0x1f, 0xf8, 0x0f, 0x00, 0xff, 0x80, 0x7c, 0x00, 0x0f, 0xff, 0x80, 0x7f, 0xe0, 0x7f, +0xff, 0xe0, 0x0f, 0xf0, 0x1f, 0x80, 0x7e, 0x01, 0xf8, 0x00, 0x00, 0x7f, 0x00, 0x3f, 0xc0, 0x7f, +0xff, 0xc0, 0x07, 0xe0, 0x3f, 0x80, 0x38, 0x07, 0xf0, 0x00, 0x00, 0x3e, 0x00, 0x3f, 0x80, 0xff, +0xff, 0x80, 0x03, 0xc0, 0x3f, 0xc0, 0x00, 0x3f, 0xe0, 0x1f, 0x80, 0x3e, 0x00, 0x1f, 0x01, 0xff, +0xff, 0x00, 0x03, 0x80, 0x7f, 0xe0, 0x00, 0xff, 0xc0, 0x3f, 0x80, 0x3c, 0x00, 0x0e, 0x03, 0xff, +0xfe, 0x00, 0x01, 0x00, 0xff, 0xe0, 0x03, 0xff, 0x80, 0x7f, 0x80, 0x78, 0x08, 0x04, 0x03, 0xff, +0xfc, 0x03, 0x00, 0x01, 0xff, 0x80, 0x01, 0xff, 0x00, 0xff, 0x00, 0xf0, 0x1c, 0x00, 0x07, 0xff, +0xfc, 0x07, 0x80, 0x03, 0xfc, 0x00, 0x01, 0xfe, 0x01, 0xfc, 0x01, 0xe0, 0x1e, 0x00, 0x0f, 0xff, +0xf8, 0x0f, 0xc0, 0x07, 0xf0, 0x0e, 0x00, 0xfc, 0x00, 0x00, 0x07, 0xc0, 0x3f, 0x00, 0x1f, 0xff, +0xf0, 0x1f, 0xe0, 0x0f, 0x80, 0x3f, 0x00, 0x7c, 0x00, 0x00, 0x3f, 0xc0, 0x7f, 0x80, 0x3f, 0xff, +0xe0, 0x3f, 0xf0, 0x0e, 0x01, 0xff, 0x80, 0x38, 0x00, 0x07, 0xff, 0x80, 0xff, 0x80, 0x7f, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, +0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; From 08f8a07945f8264c421a768ba1154336dcce1d7d Mon Sep 17 00:00:00 2001 From: KD4Z Date: Fri, 13 Apr 2018 17:40:54 -0400 Subject: [PATCH 9/9] Camel case findWithName() --- DMRLookup.cpp | 4 ++-- DMRLookup.h | 2 +- DMRSlot.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/DMRLookup.cpp b/DMRLookup.cpp index 8842a60..8fc67c3 100644 --- a/DMRLookup.cpp +++ b/DMRLookup.cpp @@ -81,7 +81,7 @@ void CDMRLookup::stop() wait(); } -std::string CDMRLookup::findwithname(unsigned int id) +std::string CDMRLookup::findWithName(unsigned int id) { std::string callsign; @@ -92,7 +92,7 @@ std::string CDMRLookup::findwithname(unsigned int id) try { callsign = m_table.at(id); - LogDebug("Findwithname Found =%s",callsign.c_str()); + LogDebug("FindWithName =%s",callsign.c_str()); } catch (...) { char text[10U]; diff --git a/DMRLookup.h b/DMRLookup.h index 54b78e7..1156270 100644 --- a/DMRLookup.h +++ b/DMRLookup.h @@ -35,7 +35,7 @@ public: virtual void entry(); std::string find(unsigned int id); - std::string findwithname(unsigned int id); + std::string findWithName(unsigned int id); bool exists(unsigned int id); diff --git a/DMRSlot.cpp b/DMRSlot.cpp index 913a97f..f50a783 100644 --- a/DMRSlot.cpp +++ b/DMRSlot.cpp @@ -1069,7 +1069,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData) setShortLC(m_slotNo, dstId, flco, ACTIVITY_VOICE); std::string src = m_lookup->find(srcId); std::string dst = m_lookup->find(dstId); - std::string cn = m_lookup->findwithname(srcId); + std::string cn = m_lookup->findWithName(srcId); m_display->writeDMR(m_slotNo, cn, flco == FLCO_GROUP, dst, "N"); #if defined(DUMP_DMR)