Refresh the display handlers.

This commit is contained in:
Jonathan Naylor
2023-10-03 16:20:29 +01:00
parent 3df5c6041c
commit 45821b1881
11 changed files with 642 additions and 639 deletions

View File

@@ -42,11 +42,11 @@ void CCASTInfo::setIdleInt()
unsigned char info[100U];
CNetworkInfo* m_network;
passCounter ++;
passCounter++;
if (passCounter > 253U)
networkInfoInitialized = false;
if (! networkInfoInitialized) {
if (!networkInfoInitialized) {
//LogMessage("Initialize CNetworkInfo");
info[0]=0;
m_network = new CNetworkInfo;
@@ -60,8 +60,6 @@ void CCASTInfo::setIdleInt()
networkInfoInitialized = true;
passCounter = 0;
}
}
void CCASTInfo::setErrorInt(const char* text)

View File

@@ -50,7 +50,7 @@ public:
void clearDStar();
void writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type);
void writeDMR(unsigned int slotNo, const class CUserDBentry& src, bool group, const std::string& dst, const char* type);
void writeDMR(unsigned int slotNo, const CUserDBentry& src, bool group, const std::string& dst, const char* type);
void writeDMRRSSI(unsigned int slotNo, unsigned char rssi);
void writeDMRBER(unsigned int slotNo, float ber);
void writeDMRTA(unsigned int slotNo, const unsigned char* talkerAlias, const char* type);
@@ -67,7 +67,7 @@ public:
void clearP25();
void writeNXDN(const char* source, bool group, unsigned int dest, const char* type);
void writeNXDN(const class CUserDBentry& source, bool group, unsigned int dest, const char* type);
void writeNXDN(const CUserDBentry& source, bool group, unsigned int dest, const char* type);
void writeNXDNRSSI(unsigned char rssi);
void writeNXDNBER(float ber);
void clearNXDN();
@@ -101,7 +101,7 @@ protected:
virtual void clearDStarInt() = 0;
virtual void writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) = 0;
virtual int writeDMRIntEx(unsigned int slotNo, const class CUserDBentry& src, bool group, const std::string& dst, const char* type);
virtual int writeDMRIntEx(unsigned int slotNo, const CUserDBentry& src, bool group, const std::string& dst, const char* type);
virtual void writeDMRRSSIInt(unsigned int slotNo, unsigned char rssi);
virtual void writeDMRTAInt(unsigned int slotNo, const unsigned char* talkerAlias, const char* type);
virtual void writeDMRBERInt(unsigned int slotNo, float ber);
@@ -118,7 +118,7 @@ protected:
virtual void clearP25Int() = 0;
virtual void writeNXDNInt(const char* source, bool group, unsigned int dest, const char* type) = 0;
virtual int writeNXDNIntEx(const class CUserDBentry& source, bool group, unsigned int dest, const char* type);
virtual int writeNXDNIntEx(const CUserDBentry& source, bool group, unsigned int dest, const char* type);
virtual void writeNXDNRSSIInt(unsigned char rssi);
virtual void writeNXDNBERInt(float ber);
virtual void clearNXDNInt() = 0;

View File

@@ -137,7 +137,7 @@ void CNextion::setIdleInt()
sendCommand("page MMDVM");
sendCommandAction(1U);
if (m_brightness>0) {
if (m_brightness > 0U) {
::sprintf(command, "dim=%u", m_idleBrightness);
sendCommand(command);
}
@@ -203,7 +203,7 @@ void CNextion::setErrorInt(const char* text)
sendCommandAction(1U);
char command[20];
if (m_brightness>0) {
if (m_brightness > 0U) {
::sprintf(command, "dim=%u", m_brightness);
sendCommand(command);
}
@@ -226,7 +226,7 @@ void CNextion::setLockoutInt()
sendCommandAction(1U);
char command[20];
if (m_brightness>0) {
if (m_brightness > 0U) {
::sprintf(command, "dim=%u", m_brightness);
sendCommand(command);
}
@@ -245,7 +245,7 @@ void CNextion::setQuitInt()
sendCommandAction(1U);
char command[100];
if (m_brightness>0) {
if (m_brightness > 0U) {
::sprintf(command, "dim=%u", m_idleBrightness);
sendCommand(command);
}
@@ -268,7 +268,7 @@ void CNextion::setFMInt()
sendCommandAction(1U);
char command[20];
if (m_brightness > 0) {
if (m_brightness > 0U) {
::sprintf(command, "dim=%u", m_brightness);
sendCommand(command);
}
@@ -295,7 +295,7 @@ void CNextion::writeDStarInt(const char* my1, const char* my2, const char* your,
}
char text[50U];
if (m_brightness>0) {
if (m_brightness > 0U) {
::sprintf(text, "dim=%u", m_brightness);
sendCommand(text);
}
@@ -396,7 +396,7 @@ void CNextion::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro
}
char text[50U];
if (m_brightness>0) {
if (m_brightness > 0U) {
::sprintf(text, "dim=%u", m_brightness);
sendCommand(text);
}
@@ -614,7 +614,7 @@ void CNextion::writeFusionInt(const char* source, const char* dest, unsigned cha
char text[30U];
if (m_brightness>0) {
if (m_brightness > 0U) {
::sprintf(text, "dim=%u", m_brightness);
sendCommand(text);
}
@@ -693,7 +693,7 @@ void CNextion::writeP25Int(const char* source, bool group, unsigned int dest, co
}
char text[30U];
if (m_brightness>0) {
if (m_brightness > 0U) {
::sprintf(text, "dim=%u", m_brightness);
sendCommand(text);
}
@@ -765,7 +765,7 @@ void CNextion::writeNXDNInt(const char* source, bool group, unsigned int dest, c
}
char text[30U];
if (m_brightness>0) {
if (m_brightness > 0U) {
::sprintf(text, "dim=%u", m_brightness);
sendCommand(text);
}
@@ -838,7 +838,7 @@ void CNextion::writeM17Int(const char* source, const char* dest, const char* typ
}
char text[30U];
if (m_brightness > 0) {
if (m_brightness > 0U) {
::sprintf(text, "dim=%u", m_brightness);
sendCommand(text);
}
@@ -907,7 +907,7 @@ void CNextion::writePOCSAGInt(uint32_t ric, const std::string& message)
}
char text[200U];
if (m_brightness>0) {
if (m_brightness > 0U) {
::sprintf(text, "dim=%u", m_brightness);
sendCommand(text);
}
@@ -984,6 +984,7 @@ void CNextion::sendCommandAction(unsigned int status)
char text[30U];
::sprintf(text, "MMDVM.status.val=%d", status);
sendCommand(text);
sendCommand("click S0,1");
}
@@ -993,8 +994,10 @@ void CNextion::sendCommand(const char* command)
m_serial->write((unsigned char*)command, (unsigned int)::strlen(command));
m_serial->write((unsigned char*)"\xFF\xFF\xFF", 3U);
// Since we just firing commands at the display, and not listening for the response,
// we must add a bit of a delay to allow the display to process the commands, else some are getting mangled.
// 10 ms is just a guess, but seems to be sufficient.
CThread::sleep(10U);
}

283
OLED.cpp
View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016,2017,2018,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017,2018,2020,2023 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,7 +20,7 @@
#include "Log.h"
static bool networkInfoInitialized = false;
static unsigned char passCounter = 0;
static unsigned char passCounter = 0U;
//Logo MMDVM for Idle Screen
static unsigned char logo_glcd_bmp[] =
@@ -86,7 +86,7 @@ static unsigned char logo_dmr_bmp[] =
};
//Logo Fusion 128x16
const unsigned char logo_fusion_bmp [] =
const unsigned char logo_fusion_bmp[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -107,7 +107,7 @@ const unsigned char logo_fusion_bmp [] =
};
//Logo P25 128x16px
const unsigned char logo_P25_bmp [] =
const unsigned char logo_P25_bmp[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x01, 0xff, 0xff, 0xff, 0xf0, 0x00, 0x03, 0xff, 0xff, 0xc0, 0x01, 0xff, 0xff, 0xff, 0xf8, 0x00,
@@ -128,7 +128,7 @@ const unsigned char logo_P25_bmp [] =
};
// Logo NXDN_sm, 128x16px
const unsigned char logo_NXDN_bmp [] =
const unsigned char logo_NXDN_bmp[] =
{
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,
@@ -149,7 +149,7 @@ const unsigned char logo_NXDN_bmp [] =
};
// Logo M17_sm, 128x16px
const unsigned char logo_M17_bmp [] =
const unsigned char logo_M17_bmp[] =
{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
@@ -170,7 +170,7 @@ const unsigned char logo_M17_bmp [] =
};
// Logo POCASG/DAPNET, 128x16px
const unsigned char logo_POCSAG_bmp [] =
const unsigned char logo_POCSAG_bmp[] =
{
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xf8, 0x7f, 0xfe, 0x03, 0xfe, 0xfe, 0x03, 0xdf, 0xf6, 0x00, 0x00, 0x1f, 0xff,
@@ -191,6 +191,7 @@ const unsigned char logo_POCSAG_bmp [] =
};
COLED::COLED(unsigned char displayType, unsigned char displayBrightness, bool displayInvert, bool displayScroll, bool displayRotate, bool displayLogoScreensaver, bool duplex) :
CDisplay(),
m_displayType(displayType),
m_displayBrightness(displayBrightness),
m_displayInvert(displayInvert),
@@ -198,7 +199,6 @@ m_displayScroll(displayScroll),
m_displayRotate(displayRotate),
m_displayLogoScreensaver(displayLogoScreensaver),
m_duplex(duplex),
//m_duplex(true), // uncomment to force duplex display for testing!
m_ipaddress(),
m_display()
{
@@ -210,22 +210,17 @@ COLED::~COLED()
bool COLED::open()
{
// SPI
if (m_display.oled_is_spi_proto(m_displayType))
{
if (m_display.oled_is_spi_proto(m_displayType)) {
// SPI change parameters to fit to your LCD
if ( !m_display.init(OLED_SPI_DC,OLED_SPI_RESET,OLED_SPI_CS, m_displayType) )
if (!m_display.init(OLED_SPI_DC, OLED_SPI_RESET, OLED_SPI_CS, m_displayType))
return false;
}
else
{
} else {
// I2C change parameters to fit to your LCD
if ( !m_display.init(OLED_I2C_RESET, m_displayType) )
if (!m_display.init(OLED_I2C_RESET, m_displayType))
return false;
}
m_display.begin();
m_display.invertDisplay(m_displayInvert ? 1 : 0);
@@ -237,13 +232,14 @@ bool COLED::open()
m_display.sendCommand(0xA0);
}
// init done
// 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)
OLED_statusbar();
m_display.setCursor(0,OLED_LINE4);
m_display.setCursor(0, OLED_LINE4);
m_display.setTextSize(1);
m_display.print(" -Initializing-");
m_display.display();
@@ -272,36 +268,37 @@ void COLED::setIdleInt()
m_mode = MODE_IDLE;
m_display.clearDisplay();
OLED_statusbar();
if (m_displayScroll && m_displayLogoScreensaver)
m_display.startscrolldiagleft(0x00,0x0f); //the MMDVM logo scrolls the whole screen
m_display.startscrolldiagleft(0x00, 0x0f); //the MMDVM logo scrolls the whole screen
unsigned char info[100U];
CNetworkInfo* m_network;
passCounter ++;
passCounter++;
if (passCounter > 253U)
networkInfoInitialized = false;
if (! networkInfoInitialized) {
if (!networkInfoInitialized) {
//LogMessage("Initialize CNetworkInfo");
info[0]=0;
info[0] = 0;
m_network = new CNetworkInfo;
m_network->getNetworkInterface(info);
m_ipaddress = (char*)info;
delete m_network;
networkInfoInitialized = true;
passCounter = 0;
passCounter = 0U;
}
// Let's let the users know if they are in Auto-AP mode...
if (m_ipaddress.find("wlan0_ap") != std::string::npos) {
size_t pos = m_ipaddress.find("wlan0_ap");
if (pos != std::string::npos) {
if (pos != std::string::npos)
m_ipaddress.erase(pos, 9); // remove redundant/superfluous "wlan0_ap" from string
}
// Read ssid value from /etc/hostapd.conf if it exists...
std::string ssid;
std::ifstream configFile("/etc/hostapd/hostapd.conf");
@@ -317,6 +314,7 @@ void COLED::setIdleInt()
}
}
}
configFile.close();
} else {
ssid = "Unknown"; // `/etc/hostapd.conf` does not exist...
@@ -335,7 +333,7 @@ void COLED::setIdleInt()
}
} else { // Connected to network - no Auto-AP mode; normal display layout...
if (m_displayLogoScreensaver) {
m_display.setCursor(0,OLED_LINE2);
m_display.setCursor(0, OLED_LINE2);
m_display.setTextSize(1);
m_display.print(" -IDLE-");
m_display.setCursor(0, OLED_LINE4);
@@ -352,8 +350,8 @@ void COLED::setIdleInt()
}
}
}
m_display.display();
m_display.display();
}
void COLED::setErrorInt(const char* text)
@@ -364,8 +362,8 @@ void COLED::setErrorInt(const char* text)
OLED_statusbar();
m_display.setTextWrap(true); // text wrap temorally enable
m_display.setCursor(0,OLED_LINE1);
m_display.printf("%s\n",text);
m_display.setCursor(0, OLED_LINE1);
m_display.printf("%s\n", text);
m_display.setTextWrap(false);
m_display.display();
@@ -378,7 +376,7 @@ void COLED::setLockoutInt()
m_display.clearDisplay();
OLED_statusbar();
m_display.setCursor(0,30);
m_display.setCursor(0, 30);
m_display.setTextSize(3);
m_display.print("Lockout");
@@ -393,7 +391,7 @@ void COLED::setQuitInt()
m_display.clearDisplay();
OLED_statusbar();
m_display.setCursor(0,30);
m_display.setCursor(0, 30);
m_display.setTextSize(2);
m_display.print(" Stopping");
@@ -409,7 +407,7 @@ void COLED::setFMInt()
m_display.clearDisplay();
OLED_statusbar();
m_display.setCursor(0,30);
m_display.setCursor(0, 30);
m_display.setTextSize(3);
m_display.print("FM");
@@ -422,95 +420,93 @@ void COLED::writeDStarInt(const char* my1, const char* my2, const char* your, co
m_mode = MODE_DSTAR;
m_display.clearDisplay();
m_display.fillRect(0,OLED_LINE3,m_display.width(),m_display.height(),BLACK); //clear everything beneath logo
m_display.fillRect(0, OLED_LINE3, m_display.width(), m_display.height(), BLACK); //clear everything beneath logo
m_display.setCursor(0,OLED_LINE3);
m_display.printf("%s %.8s/%4.4s",type,my1,my2);
m_display.setCursor(0, OLED_LINE3);
m_display.printf("%s %.8s/%4.4s", type, my1, my2);
m_display.setCursor(0,OLED_LINE4);
m_display.printf("-> %.8s",your);
m_display.setCursor(0, OLED_LINE4);
m_display.printf("-> %.8s", your);
m_display.setCursor(0,OLED_LINE5);
m_display.printf("via %.8s",reflector);
m_display.setCursor(0, OLED_LINE5);
m_display.printf("via %.8s", reflector);
m_display.setCursor(0,OLED_LINE6);
m_display.printf("%s",m_ipaddress.c_str());
m_display.setCursor(0, OLED_LINE6);
m_display.printf("%s", m_ipaddress.c_str());
OLED_statusbar();
m_display.display();
}
void COLED::clearDStarInt()
{
m_display.fillRect(0,OLED_LINE3, m_display.width(),m_display.height(),BLACK); //clear everything beneath the logo
m_display.fillRect(0, OLED_LINE3, m_display.width(),m_display.height(), BLACK); //clear everything beneath the logo
m_display.setCursor(40,OLED_LINE3);
m_display.setCursor(40, OLED_LINE3);
m_display.print("Standby");
m_display.setCursor(0,OLED_LINE5);
m_display.printf("%s",m_ipaddress.c_str());
m_display.setCursor(0, OLED_LINE5);
m_display.printf("%s", m_ipaddress.c_str());
m_display.display();
}
void COLED::writeDMRInt(unsigned int slotNo,const std::string& src,bool group,const std::string& dst,const char* type)
void COLED::writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type)
{
CUserDBentry tmp;
CUserDB entry 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)
int COLED::writeDMRIntEx(unsigned int slotNo, const CUserDBentry& src, bool group, const std::string& dst, const char* type)
{
if (m_mode != MODE_DMR) {
m_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 2-3
if ( m_duplex ) {
if (m_duplex) {
if (slotNo == 1U) {
m_display.fillRect(0,OLED_LINE2,m_display.width(),40,BLACK);
m_display.setCursor(0,OLED_LINE2);
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",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_LINE2, m_display.width(), 40, BLACK);
m_display.setCursor(0, OLED_LINE2);
m_display.printf("%s", CALLandNAME(src).c_str());
m_display.setCursor(0, OLED_LINE3);
m_display.printf("Slot: %i %s %s%s", slotNo, type.c_str(), 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", CALLandNAME(src).c_str());
m_display.setCursor(0, OLED_LINE5);
m_display.printf("Slot: %i %s %s%s", slotNo, type.c_str(), 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_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("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());
} else {
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("Slot: %i %s %s%s", slotNo, type.c_str(), 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());
}
OLED_statusbar();
m_display.display();
// must be 0, to avoid calling writeDMRInt() from CDisplay::writeDMR()
@@ -521,27 +517,26 @@ 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 2-3
if ( m_duplex ){
if (m_duplex){
if (slotNo == 1U) {
m_display.fillRect(0, OLED_LINE3, m_display.width(), 40, BLACK);
m_display.setCursor(0,OLED_LINE3);
m_display.setCursor(0, OLED_LINE3);
m_display.print("Slot: 1 Standby");
}
else {
} else {
m_display.fillRect(0, OLED_LINE5, m_display.width(), 40, BLACK);
m_display.setCursor(0, OLED_LINE5);
m_display.print("Slot: 2 Standby");
}
}
else {
} else {
m_display.fillRect(0, OLED_LINE2, m_display.width(), m_display.height(), BLACK);
m_display.setCursor(0,OLED_LINE3);
m_display.printf("Slot: %i Standby",slotNo);
m_display.setCursor(0, OLED_LINE3);
m_display.printf("Slot: %i Standby", slotNo);
}
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());
m_display.setCursor(0, OLED_LINE6);
m_display.printf("%s", m_ipaddress.c_str());
m_display.display();
}
@@ -550,12 +545,12 @@ void COLED::writeFusionInt(const char* source, const char* dest, unsigned char d
m_mode = MODE_YSF;
m_display.clearDisplay();
m_display.fillRect(0,OLED_LINE2,m_display.width(),m_display.height(),BLACK);
m_display.fillRect(0, OLED_LINE2, m_display.width(), m_display.height(), BLACK);
m_display.setCursor(0,OLED_LINE4);
m_display.setCursor(0, OLED_LINE4);
m_display.printf("%s %.10s", type, source);
m_display.setCursor(0,OLED_LINE5);
m_display.setCursor(0, OLED_LINE5);
m_display.printf(" DG-ID %u", dgid);
OLED_statusbar();
@@ -567,11 +562,11 @@ void COLED::clearFusionInt()
{
m_display.fillRect(0, OLED_LINE2, m_display.width(), m_display.height(), BLACK);
m_display.setCursor(40,OLED_LINE4);
m_display.setCursor(40, OLED_LINE4);
m_display.print("Standby");
m_display.setCursor(0,OLED_LINE6);
m_display.printf("%s",m_ipaddress.c_str());
m_display.setCursor(0, OLED_LINE6);
m_display.printf("%s", m_ipaddress.c_str());
m_display.display();
}
@@ -583,13 +578,14 @@ void COLED::writeP25Int(const char* source, bool group, unsigned int dest, const
m_display.clearDisplay();
m_display.fillRect(0, OLED_LINE2, m_display.width(), m_display.height(), BLACK);
m_display.setCursor(0,OLED_LINE3);
m_display.setCursor(0, OLED_LINE3);
m_display.printf("%s %.10s", type, source);
m_display.setCursor(0,OLED_LINE4);
m_display.setCursor(0, OLED_LINE4);
m_display.printf(" %s%u", group ? "TG" : "", dest);
OLED_statusbar();
m_display.display();
}
@@ -597,11 +593,11 @@ void COLED::clearP25Int()
{
m_display.fillRect(0, OLED_LINE2, m_display.width(), m_display.height(), BLACK);
m_display.setCursor(40,OLED_LINE4);
m_display.setCursor(40, OLED_LINE4);
m_display.print("Standby");
m_display.setCursor(0,OLED_LINE6);
m_display.printf("%s",m_ipaddress.c_str());
m_display.setCursor(0, OLED_LINE6);
m_display.printf("%s", m_ipaddress.c_str());
m_display.display();
}
@@ -611,32 +607,34 @@ void COLED::writeNXDNInt(const char* source, bool group, unsigned int dest, cons
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)
int COLED::writeNXDNIntEx(const 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.setCursor(0, OLED_LINE2);
m_display.printf("%s %s", type, CALLandNAME(source).c_str());
m_display.setCursor(0,OLED_LINE3);
m_display.setCursor(0, OLED_LINE3);
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_LINE4);
m_display.printf("%s", source.get(keyCITY).c_str());
m_display.setCursor(0,OLED_LINE5);
m_display.printf("%s",source.get(keySTATE).c_str());
m_display.setCursor(0, OLED_LINE5);
m_display.printf("%s", source.get(keySTATE).c_str());
m_display.setCursor(0,OLED_LINE6);
m_display.printf("%s",source.get(keyCOUNTRY).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()
@@ -647,11 +645,11 @@ void COLED::clearNXDNInt()
{
m_display.fillRect(0, OLED_LINE2, m_display.width(), m_display.height(), BLACK);
m_display.setCursor(40,OLED_LINE3);
m_display.setCursor(40, OLED_LINE3);
m_display.print("Standby");
m_display.setCursor(0,OLED_LINE6);
m_display.printf("%s",m_ipaddress.c_str());
m_display.setCursor(0, OLED_LINE6);
m_display.printf("%s", m_ipaddress.c_str());
m_display.display();
}
@@ -663,17 +661,17 @@ void COLED::writeM17Int(const char* source, const char* dest, const char* type)
m_display.clearDisplay();
m_display.fillRect(0, OLED_LINE2, m_display.width(), m_display.height(), BLACK);
m_display.setCursor(0,OLED_LINE3);
m_display.setCursor(0, OLED_LINE3);
m_display.printf("from: %s %s", type, source);
m_display.setCursor(0,OLED_LINE4);
m_display.setCursor(0, OLED_LINE4);
m_display.printf("to: %s", dest);
m_display.setCursor(0,OLED_LINE6);
m_display.printf("%s",m_ipaddress.c_str());
m_display.setCursor(0, OLED_LINE6);
m_display.printf("%s", m_ipaddress.c_str());
OLED_statusbar();
m_display.display();
}
@@ -681,11 +679,11 @@ void COLED::clearM17Int()
{
m_display.fillRect(0, OLED_LINE2, m_display.width(), m_display.height(), BLACK);
m_display.setCursor(40,OLED_LINE4);
m_display.setCursor(40, OLED_LINE4);
m_display.print("Standby");
m_display.setCursor(0,OLED_LINE6);
m_display.printf("%s",m_ipaddress.c_str());
m_display.setCursor(0, OLED_LINE6);
m_display.printf("%s", m_ipaddress.c_str());
m_display.display();
}
@@ -727,14 +725,13 @@ void COLED::writePOCSAGInt(uint32_t ric, const std::string& message)
m_display.clearDisplay();
m_display.fillRect(0, OLED_LINE2, m_display.width(), m_display.height(), BLACK);
m_display.setCursor(0,OLED_LINE2);
m_display.setCursor(0, OLED_LINE2);
m_display.printf("RIC: %u", ric);
if (!rublic.empty()) {
if (!rublic.empty())
m_display.printf(" / %s", rublic.c_str());
}
m_display.setTextWrap(true); // text wrap temorally enable
m_display.setCursor(0,OLED_LINE3);
m_display.setCursor(0, OLED_LINE3);
// no room to display "MSG: " header
// due to limitation of AdaFruit_GFX::vprintf() (in ArduiPi_OLED),
@@ -749,6 +746,7 @@ void COLED::writePOCSAGInt(uint32_t ric, const std::string& message)
m_display.setTextWrap(false);
OLED_statusbar();
m_display.display();
}
@@ -756,11 +754,11 @@ void COLED::clearPOCSAGInt()
{
m_display.fillRect(0, OLED_LINE2, m_display.width(), m_display.height(), BLACK);
m_display.setCursor(40,OLED_LINE3);
m_display.setCursor(40, OLED_LINE3);
m_display.print("Standby");
m_display.setCursor(0,OLED_LINE6);
m_display.printf("%s",m_ipaddress.c_str());
m_display.setCursor(0, OLED_LINE6);
m_display.printf("%s", m_ipaddress.c_str());
m_display.display();
}
@@ -769,26 +767,27 @@ void COLED::writeCWInt()
{
m_display.clearDisplay();
m_display.setCursor(0,30);
m_display.setCursor(0, 30);
m_display.setTextSize(2);
m_display.print("CW ID TX");
m_display.setTextSize(1);
m_display.display();
if (m_displayScroll)
m_display.startscrollleft(0x02,0x0f);
m_display.startscrollleft(0x02, 0x0f);
}
void COLED::clearCWInt()
{
m_display.clearDisplay();
m_display.setCursor(0,OLED_LINE1);
m_display.setCursor(0, OLED_LINE1);
m_display.setTextSize(2);
m_display.setTextSize(1);
m_display.print(" -IDLE-");
m_display.setCursor(0,OLED_LINE3);
m_display.printf("%s",m_ipaddress.c_str());
m_display.setCursor(0, OLED_LINE3);
m_display.printf("%s", m_ipaddress.c_str());
// Display temperature
float tempCelsius = readTemperature("/sys/class/thermal/thermal_zone0/temp");
@@ -801,19 +800,20 @@ void COLED::clearCWInt()
}
if (m_displayScroll)
m_display.startscrolldiagleft(0x00,0x0f);
m_display.startscrolldiagleft(0x00, 0x0f);
m_display.display();
}
void COLED::close()
{
m_display.clearDisplay();
m_display.fillRect(0, 0, m_display.width(), 16, BLACK);
if (m_displayScroll)
m_display.startscrollleft(0x00,0x01);
m_display.setCursor(0,OLED_LINE3);
m_display.startscrollleft(0x00, 0x01);
m_display.setCursor(0, OLED_LINE3);
m_display.setTextSize(2);
m_display.print(" -OFFLINE-");
m_display.display();
@@ -846,5 +846,6 @@ void COLED::OLED_statusbar()
m_display.drawBitmap(0, 0, logo_glcd_bmp, 128, 16, WHITE);
if (m_displayScroll)
m_display.startscrollleft(0x00,0x01);
m_display.startscrollleft(0x00, 0x01);
}

17
OLED.h
View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016,2017,2018,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017,2018,2020,2023 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -45,13 +45,15 @@
class COLED : public CDisplay
{
public:
COLED(unsigned char displayType, unsigned char displayBrighness, bool displayInvert, bool displayScroll, bool displayRotate, bool displayLogoScreensaver, bool duplex);
COLED(char displayType, unsigned char displayBrighness, bool displayInvert, bool displayScroll, bool displayRotate, bool displayLogoScreensaver, bool duplex);
virtual ~COLED();
virtual bool open();
virtual void setIdleInt();
virtual void close();
protected:
virtual void setIdleInt();
virtual void setErrorInt(const char* text);
virtual void setLockoutInt();
virtual void setQuitInt();
@@ -61,7 +63,7 @@ public:
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 int writeDMRIntEx(unsigned int slotNo, const 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);
@@ -71,7 +73,7 @@ public:
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 int writeNXDNIntEx(const 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);
@@ -83,8 +85,6 @@ public:
virtual void writeCWInt();
virtual void clearCWInt();
virtual void close();
private:
const char* m_slot1_state;
const char* m_slot2_state;
@@ -99,9 +99,10 @@ private:
std::string m_ipaddress;
ArduiPi_OLED m_display;
float readTemperature(const std::string& filePath);
float readTemperature(const char* filePath);
void OLED_statusbar();
};
#endif

View File

@@ -235,7 +235,7 @@ void CTFTSurenoo::writeDMRInt(unsigned int slotNo, const std::string& src, bool
m_mode = MODE_DMR;
}
int CTFTSurenoo::writeDMRIntEx(unsigned int slotNo, const class CUserDBentry& src, bool group, const std::string& dst, const char* type)
int CTFTSurenoo::writeDMRIntEx(unsigned int slotNo, const CUserDBentry& src, bool group, const std::string& dst, const char* type)
{
assert(type != NULL);
@@ -335,7 +335,7 @@ void CTFTSurenoo::writeNXDNInt(const char* source, bool group, unsigned int dest
m_mode = MODE_NXDN;
}
int CTFTSurenoo::writeNXDNIntEx(const class CUserDBentry& source, bool group, unsigned int dest, const char* type)
int CTFTSurenoo::writeNXDNIntEx(const CUserDBentry& source, bool group, unsigned int dest, const char* type)
{
assert(type != NULL);

View File

@@ -48,7 +48,7 @@ protected:
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 int writeDMRIntEx(unsigned int slotNo, const 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);
@@ -58,7 +58,7 @@ protected:
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 int writeNXDNIntEx(const 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);
@@ -87,9 +87,9 @@ private:
void setLineBuffer(char *buf, const char *text, int maxchar);
void setModeLine(const char *text);
void setStatusLine(unsigned int line, const char *text);
void refreshDisplay(void);
void refreshDisplay();
void lcdReset(void);
void lcdReset();
void clearScreen(unsigned char colour);
void setBackground(unsigned char colour);
void setRotation(unsigned char rotation);