Skip to content

Commit

Permalink
add UserDB display for OLED
Browse files Browse the repository at this point in the history
To display UserDB on DMR mode, set Slot1=0 and Slot2=1 in [DMR Network]
section.
  • Loading branch information
jg1uaa committed Sep 24, 2020
1 parent d77d44f commit e818d0f
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 16 deletions.
73 changes: 57 additions & 16 deletions OLED.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ bool COLED::open()
}

// init done
m_display.setTextWrap(false); // disable text wrap as default
m_display.clearDisplay(); // clears the screen buffer
m_display.display(); // display it (clear display)

Expand Down Expand Up @@ -271,8 +272,10 @@ void COLED::setErrorInt(const char* text)
m_display.clearDisplay();
OLED_statusbar();

m_display.setTextWrap(true); // text wrap temorally enable
m_display.setCursor(0,OLED_LINE1);
m_display.printf("%s\n",text);
m_display.setTextWrap(false);

m_display.display();
}
Expand Down Expand Up @@ -360,6 +363,16 @@ void COLED::clearDStarInt()
}

void COLED::writeDMRInt(unsigned int slotNo,const std::string& src,bool group,const std::string& dst,const char* type)
{
CUserDBentry tmp;

tmp.set(keyCALLSIGN, src);
writeDMRIntEx(slotNo, tmp, group, dst, type);
}

#define CALLandNAME(u) ((u).get(keyCALLSIGN) + " " + (u).get(keyFIRST_NAME))

int COLED::writeDMRIntEx(unsigned int slotNo, const class CUserDBentry& src, bool group, const std::string& dst, const char* type)
{

if (m_mode != MODE_DMR) {
Expand All @@ -368,48 +381,55 @@ void COLED::writeDMRInt(unsigned int slotNo,const std::string& src,bool group,co
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 single slot, use lines 2-3
if ( m_slot1Enabled && m_slot2Enabled ) {

if (slotNo == 1U) {
m_display.fillRect(0,OLED_LINE2,m_display.width(),40,BLACK);
m_display.setCursor(0,OLED_LINE2);
m_display.printf("%s",src.c_str());
m_display.printf("%s",CALLandNAME(src).c_str());
m_display.setCursor(0,OLED_LINE3);
m_display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG: " : "",dst.c_str());
}
else
{
m_display.fillRect(0,OLED_LINE4,m_display.width(),40,BLACK);
m_display.setCursor(0,OLED_LINE4);
m_display.printf("%s",src.c_str());
m_display.printf("%s",CALLandNAME(src).c_str());
m_display.setCursor(0,OLED_LINE5);
m_display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG: " : "",dst.c_str());
}

m_display.fillRect(0,OLED_LINE6,m_display.width(),20,BLACK);
m_display.setCursor(0,OLED_LINE6);
m_display.printf("%s",m_ipaddress.c_str());
}
else
{
m_display.fillRect(0,OLED_LINE3,m_display.width(),20,BLACK);
m_display.fillRect(0,OLED_LINE2,m_display.width(),m_display.height(),BLACK);
m_display.setCursor(0,OLED_LINE2);
m_display.printf("%s",CALLandNAME(src).c_str());
m_display.setCursor(0,OLED_LINE3);
m_display.printf("%s",src.c_str());
m_display.setCursor(0,OLED_LINE4);
m_display.printf("Slot: %i %s %s%s",slotNo,type,group ? "TG: " : "",dst.c_str());
m_display.setCursor(0,OLED_LINE4);
m_display.printf("%s",src.get(keyCITY).c_str());
m_display.setCursor(0,OLED_LINE5);
m_display.printf("%s",src.get(keySTATE).c_str());
m_display.setCursor(0,OLED_LINE6);
m_display.printf("%s",src.get(keyCOUNTRY).c_str());
}

m_display.fillRect(0,OLED_LINE6,m_display.width(),20,BLACK);
m_display.setCursor(0,OLED_LINE6);
m_display.printf("%s",m_ipaddress.c_str());

OLED_statusbar();
m_display.display();

// must be 0, to avoid calling writeDMRInt() from CDisplay::writeDMR()
return 0;
}

void COLED::clearDMRInt(unsigned int 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 single slot, use lines 2-3
if ( m_slot1Enabled && m_slot2Enabled ){
if (slotNo == 1U) {
m_display.fillRect(0, OLED_LINE3, m_display.width(), 40, BLACK);
Expand All @@ -423,8 +443,8 @@ void COLED::clearDMRInt(unsigned int slotNo)
}
}
else {
m_display.fillRect(0, OLED_LINE4, m_display.width(), 40, BLACK);
m_display.setCursor(0,OLED_LINE4);
m_display.fillRect(0, OLED_LINE2, m_display.width(), m_display.height(), BLACK);
m_display.setCursor(0,OLED_LINE3);
m_display.printf("Slot: %i Listening",slotNo);
}

Expand Down Expand Up @@ -497,28 +517,47 @@ void COLED::clearP25Int()
}

void COLED::writeNXDNInt(const char* source, bool group, unsigned int dest, const char* type)
{
CUserDBentry tmp;

tmp.set(keyCALLSIGN, source);
writeNXDNIntEx(tmp, group, dest, type);
}

int COLED::writeNXDNIntEx(const class CUserDBentry& source, bool group, unsigned int dest, const char* type)
{
m_mode = MODE_NXDN;

m_display.clearDisplay();
m_display.fillRect(0, OLED_LINE2, m_display.width(), m_display.height(), BLACK);

m_display.setCursor(0,OLED_LINE2);
m_display.printf("%s %s", type, CALLandNAME(source).c_str());

m_display.setCursor(0,OLED_LINE3);
m_display.printf("%s %.10s", type, source);
m_display.printf(" %s%u", group ? "TG" : "", dest);

m_display.setCursor(0,OLED_LINE4);
m_display.printf("%s",source.get(keyCITY).c_str());

m_display.setCursor(0,OLED_LINE5);
m_display.printf(" %s%u", group ? "TG" : "", dest);
m_display.printf("%s",source.get(keySTATE).c_str());

m_display.setCursor(0,OLED_LINE6);
m_display.printf("%s",source.get(keyCOUNTRY).c_str());

OLED_statusbar();
m_display.display();

// must be 0, to avoid calling writeNXDNInt() from CDisplay::writeNXDN()
return 0;
}

void COLED::clearNXDNInt()
{
m_display.fillRect(0, OLED_LINE2, m_display.width(), m_display.height(), BLACK);

m_display.setCursor(40,OLED_LINE4);
m_display.setCursor(40,OLED_LINE3);
m_display.print("Listening");

m_display.setCursor(0,OLED_LINE6);
Expand All @@ -537,8 +576,10 @@ void COLED::writePOCSAGInt(uint32_t ric, const std::string& message)
m_display.setCursor(0,OLED_LINE3);
m_display.printf("RIC: %u", ric);

m_display.setTextWrap(true); // text wrap temorally enable
m_display.setCursor(0,OLED_LINE5);
m_display.printf("MSG: %s", message.c_str());
m_display.setTextWrap(false);

OLED_statusbar();
m_display.display();
Expand Down
3 changes: 3 additions & 0 deletions OLED.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

#include "Display.h"
#include "Defines.h"
#include "UserDBentry.h"

#include <string>

Expand Down Expand Up @@ -56,6 +57,7 @@ class COLED : public CDisplay
virtual void clearDStarInt();

virtual void writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type);
virtual int writeDMRIntEx(unsigned int slotNo, const class CUserDBentry& src, bool group, const std::string& dst, const char* type);
virtual void clearDMRInt(unsigned int slotNo);

virtual void writeFusionInt(const char* source, const char* dest, unsigned char dgid, const char* type, const char* origin);
Expand All @@ -65,6 +67,7 @@ class COLED : public CDisplay
virtual void clearP25Int();

virtual void writeNXDNInt(const char* source, bool group, unsigned int dest, const char* type);
virtual int writeNXDNIntEx(const class CUserDBentry& source, bool group, unsigned int dest, const char* type);
virtual void clearNXDNInt();

virtual void writePOCSAGInt(uint32_t ric, const std::string& message);
Expand Down

0 comments on commit e818d0f

Please sign in to comment.