mirror of
https://github.com/g4klx/MMDVMHost
synced 2025-12-22 08:05:49 +08:00
Refinements of the Nextion displays
* better looking fonts * DMR talker alias is shown (in green) if received * font is automaticly adapted when TA would be too long for display * DMR ID, call or TA (depending on what was shown) goes to gray at voice end * "MMDVM stopped" at rest screen when MMDVMHost application is ended * active network interface and IP address on rest screen so you know how to contact it
This commit is contained in:
93
Nextion.cpp
93
Nextion.cpp
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "Nextion.h"
|
||||
#include "Log.h"
|
||||
#include "Network.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
@@ -25,6 +26,29 @@
|
||||
#include <ctime>
|
||||
#include <clocale>
|
||||
|
||||
/*
|
||||
#include "Nextion.h"
|
||||
#include "Log.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cassert>
|
||||
#include <cstring>
|
||||
#include <ctime>
|
||||
#include <clocale>
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <ifaddrs.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
|
||||
|
||||
//#include <sys/socket.h>
|
||||
#include <netdb.h>
|
||||
//#include <ifaddrs.h>
|
||||
//#include <linux/if_link.h>
|
||||
*/
|
||||
|
||||
|
||||
const unsigned int DSTAR_RSSI_COUNT = 3U; // 3 * 420ms = 1260ms
|
||||
const unsigned int DSTAR_BER_COUNT = 63U; // 63 * 20ms = 1260ms
|
||||
const unsigned int DMR_RSSI_COUNT = 4U; // 4 * 360ms = 1440ms
|
||||
@@ -37,6 +61,7 @@ const unsigned int P25_BER_COUNT = 7U; // 7 * 180ms = 1260ms
|
||||
CNextion::CNextion(const std::string& callsign, unsigned int dmrid, ISerialPort* serial, unsigned int brightness, bool displayClock, bool utc, unsigned int idleBrightness) :
|
||||
CDisplay(),
|
||||
m_callsign(callsign),
|
||||
m_ipaddress("(ip unknown)"),
|
||||
m_dmrid(dmrid),
|
||||
m_serial(serial),
|
||||
m_brightness(brightness),
|
||||
@@ -62,8 +87,13 @@ CNextion::~CNextion()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool CNextion::open()
|
||||
{
|
||||
unsigned char info[100U];
|
||||
CNetworkInfo* m_network;
|
||||
|
||||
bool ret = m_serial->open();
|
||||
if (!ret) {
|
||||
LogError("Cannot open the port for the Nextion display");
|
||||
@@ -71,6 +101,11 @@ bool CNextion::open()
|
||||
return false;
|
||||
}
|
||||
|
||||
info[0]=0;
|
||||
m_network = new CNetworkInfo;
|
||||
m_network->getNetworkInterface(info);
|
||||
m_ipaddress = (char*)info;
|
||||
|
||||
sendCommand("bkcmd=0");
|
||||
|
||||
setIdle();
|
||||
@@ -78,6 +113,7 @@ bool CNextion::open()
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void CNextion::setIdleInt()
|
||||
{
|
||||
sendCommand("page MMDVM");
|
||||
@@ -86,11 +122,15 @@ void CNextion::setIdleInt()
|
||||
::sprintf(command, "dim=%u", m_idleBrightness);
|
||||
sendCommand(command);
|
||||
|
||||
::sprintf(command, "t0.txt=\"%-6s / %u\"", m_callsign.c_str(), m_dmrid);
|
||||
::sprintf(command, "t0.txt=\"%s/%u\"", m_callsign.c_str(), m_dmrid);
|
||||
|
||||
sendCommand(command);
|
||||
sendCommand("t1.txt=\"MMDVM IDLE\"");
|
||||
|
||||
char text[30U];
|
||||
::sprintf(text, "t3.txt=\"%s\"", m_ipaddress.c_str());
|
||||
sendCommand(text);
|
||||
|
||||
m_clockDisplayTimer.start();
|
||||
|
||||
m_mode = MODE_IDLE;
|
||||
@@ -226,10 +266,15 @@ void CNextion::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro
|
||||
if (m_mode != MODE_DMR) {
|
||||
sendCommand("page DMR");
|
||||
|
||||
if (slotNo == 1U)
|
||||
if (slotNo == 1U) {
|
||||
sendCommand("t2.pco=0");
|
||||
sendCommand("t2.font=4");
|
||||
sendCommand("t2.txt=\"2 Listening\"");
|
||||
else
|
||||
} else {
|
||||
sendCommand("t0.pco=0");
|
||||
sendCommand("t0.font=4");
|
||||
sendCommand("t0.txt=\"1 Listening\"");
|
||||
}
|
||||
}
|
||||
|
||||
char text[30U];
|
||||
@@ -238,12 +283,16 @@ void CNextion::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro
|
||||
|
||||
if (slotNo == 1U) {
|
||||
::sprintf(text, "t0.txt=\"1 %s %s\"", type, src.c_str());
|
||||
sendCommand("t0.pco=0");
|
||||
sendCommand("t0.font=4");
|
||||
sendCommand(text);
|
||||
|
||||
::sprintf(text, "t1.txt=\"%s%s\"", group ? "TG" : "", dst.c_str());
|
||||
sendCommand(text);
|
||||
} else {
|
||||
::sprintf(text, "t2.txt=\"2 %s %s\"", type, src.c_str());
|
||||
sendCommand("t2.pco=0");
|
||||
sendCommand("t2.font=4");
|
||||
sendCommand(text);
|
||||
|
||||
::sprintf(text, "t3.txt=\"%s%s\"", group ? "TG" : "", dst.c_str());
|
||||
@@ -306,6 +355,38 @@ void CNextion::writeDMRRSSIInt(unsigned int slotNo, unsigned char rssi)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CNextion::writeDMRTAInt(unsigned int slotNo, unsigned char* talkerAlias, const char* type)
|
||||
{
|
||||
char text[40U];
|
||||
|
||||
if (type[0]==' ') {
|
||||
if (slotNo == 1U) {
|
||||
sendCommand("t0.pco=33808");
|
||||
} else {
|
||||
sendCommand("t2.pco=33808");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (slotNo == 1U) {
|
||||
::sprintf(text, "t0.txt=\"1 %s %s\"",type,talkerAlias);
|
||||
if (strlen((char*)talkerAlias)>16-4) sendCommand("t0.font=3");
|
||||
if (strlen((char*)talkerAlias)>20-4) sendCommand("t0.font=2");
|
||||
if (strlen((char*)talkerAlias)>24-4) sendCommand("t0.font=1");
|
||||
sendCommand("t0.pco=1024");
|
||||
sendCommand(text);
|
||||
} else {
|
||||
::sprintf(text, "t2.txt=\"2 %s %s\"",type,talkerAlias);
|
||||
if (strlen((char*)talkerAlias)>16-4) sendCommand("t2.font=3");
|
||||
if (strlen((char*)talkerAlias)>20-4) sendCommand("t2.font=2");
|
||||
if (strlen((char*)talkerAlias)>24-4) sendCommand("t2.font=1");
|
||||
sendCommand("t2.pco=1024");
|
||||
sendCommand(text);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CNextion::writeDMRBERInt(unsigned int slotNo, float ber)
|
||||
{
|
||||
if (slotNo == 1U) {
|
||||
@@ -353,11 +434,15 @@ void CNextion::clearDMRInt(unsigned int slotNo)
|
||||
{
|
||||
if (slotNo == 1U) {
|
||||
sendCommand("t0.txt=\"1 Listening\"");
|
||||
sendCommand("t0.pco=0");
|
||||
sendCommand("t0.font=4");
|
||||
sendCommand("t1.txt=\"\"");
|
||||
sendCommand("t4.txt=\"\"");
|
||||
sendCommand("t6.txt=\"\"");
|
||||
} else {
|
||||
sendCommand("t2.txt=\"2 Listening\"");
|
||||
sendCommand("t2.pco=0");
|
||||
sendCommand("t2.font=4");
|
||||
sendCommand("t3.txt=\"\"");
|
||||
sendCommand("t5.txt=\"\"");
|
||||
sendCommand("t7.txt=\"\"");
|
||||
@@ -568,6 +653,8 @@ void CNextion::clockInt(unsigned int ms)
|
||||
|
||||
void CNextion::close()
|
||||
{
|
||||
sendCommand("page MMDVM");
|
||||
sendCommand("t1.txt=\"MMDVM STOPPED\"");
|
||||
m_serial->close();
|
||||
delete m_serial;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user