Skip to content

Commit

Permalink
Refinements of the Nextion displays
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
root committed Oct 2, 2017
1 parent 56ebac2 commit 3a9c011
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 12 deletions.
37 changes: 33 additions & 4 deletions DMRSlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ m_rfEmbeddedData(NULL),
m_rfEmbeddedReadN(0U),
m_rfEmbeddedWriteN(1U),
m_rfTalkerId(TALKER_ID_NONE),
m_rfTalkerAlias(NULL),
m_netEmbeddedLC(),
m_netEmbeddedData(NULL),
m_netEmbeddedReadN(0U),
Expand Down Expand Up @@ -113,6 +114,7 @@ m_aveRSSI(0U),
m_rssiCount(0U),
m_fp(NULL)
{
m_rfTalkerAlias = new unsigned char[32]; //TA max length is 31 chars
m_lastFrame = new unsigned char[DMR_FRAME_LENGTH_BYTES + 2U];

m_rfEmbeddedData = new CDMREmbeddedData[2U];
Expand Down Expand Up @@ -331,7 +333,7 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
LogMessage("DMR Slot %u, received RF end of voice transmission, %.1f seconds, BER: %.1f%%, RSSI: -%u/-%u/-%u dBm", m_slotNo, float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits), m_minRSSI, m_maxRSSI, m_aveRSSI / m_rssiCount);
else
LogMessage("DMR Slot %u, received RF end of voice transmission, %.1f seconds, BER: %.1f%%", m_slotNo, float(m_rfFrames) / 16.667F, float(m_rfErrs * 100U) / float(m_rfBits));

m_display->writeDMRTA(m_slotNo,NULL," ");
if (m_rfTimeout) {
writeEndRF();
return false;
Expand Down Expand Up @@ -583,7 +585,6 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
bool ret = m_rfEmbeddedData[m_rfEmbeddedWriteN].addData(data + 2U, lcss);
if (ret) {
FLCO flco = m_rfEmbeddedData[m_rfEmbeddedWriteN].getFLCO();

unsigned char data[9U];
m_rfEmbeddedData[m_rfEmbeddedWriteN].getRawData(data);

Expand All @@ -609,6 +610,10 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
m_network->writeTalkerAlias(m_rfLC->getSrcId(), 0U, data);

if (!(m_rfTalkerId & TALKER_ID_HEADER)) {
if (!m_rfTalkerId) memset(m_rfTalkerAlias,0,32);
::memcpy(m_rfTalkerAlias, data, 6);
m_display->writeDMRTA(m_slotNo, m_rfTalkerAlias,"R");

if (m_dumpTAData) {
::sprintf(text, "DMR Slot %u, Embedded Talker Alias Header", m_slotNo);
CUtils::dump(2U, text, data, 9U);
Expand All @@ -623,6 +628,11 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
m_network->writeTalkerAlias(m_rfLC->getSrcId(), 1U, data);

if (!(m_rfTalkerId & TALKER_ID_BLOCK1)) {
if (!m_rfTalkerId) memset(m_rfTalkerAlias,0,32);

::memcpy(m_rfTalkerAlias+6, data, 7);
m_display->writeDMRTA(m_slotNo, m_rfTalkerAlias,"R");

if (m_dumpTAData) {
::sprintf(text, "DMR Slot %u, Embedded Talker Alias Block 1", m_slotNo);
CUtils::dump(2U, text, data, 9U);
Expand All @@ -637,12 +647,16 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
m_network->writeTalkerAlias(m_rfLC->getSrcId(), 2U, data);

if (!(m_rfTalkerId & TALKER_ID_BLOCK2)) {
if (!m_rfTalkerId) memset(m_rfTalkerAlias,0,32);
m_rfTalkerId |= TALKER_ID_BLOCK2;
::memcpy(m_rfTalkerAlias+6+7, data, 7);
m_display->writeDMRTA(m_slotNo, m_rfTalkerAlias,"R");

if (m_dumpTAData) {
::sprintf(text, "DMR Slot %u, Embedded Talker Alias Block 2", m_slotNo);
CUtils::dump(2U, text, data, 9U);
}

m_rfTalkerId |= TALKER_ID_BLOCK2;
}
break;

Expand All @@ -651,6 +665,9 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
m_network->writeTalkerAlias(m_rfLC->getSrcId(), 3U, data);

if (!(m_rfTalkerId & TALKER_ID_BLOCK3)) {
if (!m_rfTalkerId) memset(m_rfTalkerAlias,0,32);
::memcpy(m_rfTalkerAlias+6+7+7, data, 7);
m_display->writeDMRTA(m_slotNo, m_rfTalkerAlias,"R");
if (m_dumpTAData) {
::sprintf(text, "DMR Slot %u, Embedded Talker Alias Block 3", m_slotNo);
CUtils::dump(2U, text, data, 9U);
Expand Down Expand Up @@ -1163,7 +1180,7 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
// We've received the voice header and terminator haven't we?
m_netFrames += 2U;
LogMessage("DMR Slot %u, received network end of voice transmission, %.1f seconds, %u%% packet loss, BER: %.1f%%", m_slotNo, float(m_netFrames) / 16.667F, (m_netLost * 100U) / m_netFrames, float(m_netErrs * 100U) / float(m_netBits));

m_display->writeDMRTA(m_slotNo,NULL," ");
writeEndNet();
} else if (dataType == DT_DATA_HEADER) {
if (m_netState == RS_NET_DATA)
Expand Down Expand Up @@ -1374,6 +1391,9 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
break;
case FLCO_TALKER_ALIAS_HEADER:
if (!(m_netTalkerId & TALKER_ID_HEADER)) {
if (!m_netTalkerId) memset(m_rfTalkerAlias,0,32);
::memcpy(m_rfTalkerAlias, data+2, 7);
m_display->writeDMRTA(m_slotNo, m_rfTalkerAlias,"N");
if (m_dumpTAData) {
::sprintf(text, "DMR Slot %u, Embedded Talker Alias Header", m_slotNo);
CUtils::dump(2U, text, data, 9U);
Expand All @@ -1384,6 +1404,9 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
break;
case FLCO_TALKER_ALIAS_BLOCK1:
if (!(m_netTalkerId & TALKER_ID_BLOCK1)) {
if (!m_netTalkerId) memset(m_rfTalkerAlias,0,32);
::memcpy(m_rfTalkerAlias+7, data+2, 7);
m_display->writeDMRTA(m_slotNo, m_rfTalkerAlias,"N");
if (m_dumpTAData) {
::sprintf(text, "DMR Slot %u, Embedded Talker Alias Block 1", m_slotNo);
CUtils::dump(2U, text, data, 9U);
Expand All @@ -1394,6 +1417,9 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
break;
case FLCO_TALKER_ALIAS_BLOCK2:
if (!(m_netTalkerId & TALKER_ID_BLOCK2)) {
if (!m_netTalkerId) memset(m_rfTalkerAlias,0,32);
::memcpy(m_rfTalkerAlias+7+7, data+2, 7);
m_display->writeDMRTA(m_slotNo, m_rfTalkerAlias,"N");
if (m_dumpTAData) {
::sprintf(text, "DMR Slot %u, Embedded Talker Alias Block 2", m_slotNo);
CUtils::dump(2U, text, data, 9U);
Expand All @@ -1404,6 +1430,9 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
break;
case FLCO_TALKER_ALIAS_BLOCK3:
if (!(m_netTalkerId & TALKER_ID_BLOCK3)) {
if (!m_netTalkerId) memset(m_rfTalkerAlias,0,32);
::memcpy(m_rfTalkerAlias+7+7+7, data+2, 7);
m_display->writeDMRTA(m_slotNo, m_rfTalkerAlias,"N");
if (m_dumpTAData) {
::sprintf(text, "DMR Slot %u, Embedded Talker Alias Block 3", m_slotNo);
CUtils::dump(2U, text, data, 9U);
Expand Down
1 change: 1 addition & 0 deletions DMRSlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class CDMRSlot {
unsigned int m_rfEmbeddedReadN;
unsigned int m_rfEmbeddedWriteN;
unsigned char m_rfTalkerId;
unsigned char* m_rfTalkerAlias;
CDMREmbeddedData m_netEmbeddedLC;
CDMREmbeddedData* m_netEmbeddedData;
unsigned int m_netEmbeddedReadN;
Expand Down
47 changes: 43 additions & 4 deletions Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@

#include "Display.h"
#include "Defines.h"
#include "Log.h"

#include <cstdio>
#include <cassert>
#include <cstring>

CDisplay::CDisplay() :
m_timer1(1000U, 3U),
m_timer2(1000U, 3U),
m_timer1(3000U, 3U),
m_timer2(3000U, 3U),
m_mode1(MODE_IDLE),
m_mode2(MODE_IDLE)
{
Expand Down Expand Up @@ -117,7 +118,6 @@ void CDisplay::writeDMR(unsigned int slotNo, const std::string& src, bool group,
m_timer2.start();
m_mode2 = MODE_IDLE;
}

writeDMRInt(slotNo, src, group, dst, type);
}

Expand All @@ -127,11 +127,46 @@ void CDisplay::writeDMRRSSI(unsigned int slotNo, unsigned char rssi)
writeDMRRSSIInt(slotNo, rssi);
}

void CDisplay::writeDMRTA(unsigned int slotNo, unsigned char* talkerAlias, const char* type)
{
unsigned char format;
char TA[32];
int i,j;

if (strcmp(type," ")==0) { writeDMRTAInt(slotNo, (unsigned char*)TA, type); return; }


format=talkerAlias[0]>>6;
strcpy(TA,"(could not decode)");
switch (format) {
case 0: // 7 bit
break;
case 1: // ISO 8 bit
case 2: // UTF8
strcpy(TA,(char*)talkerAlias+1);
break;
case 3: // UTF16
j=0;
memset (&TA,0,32);
for(i=0;i<15;i++) {
if (talkerAlias[2*i+1]==0)
TA[j++]=talkerAlias[2*i+2]; else TA[j++]='?';
}
TA[j]=0;
break;
}
i=strlen(TA);
j=(talkerAlias[0]&0x3F)>>1;
LogMessage("DMR Talker Alias (Data Format %u, Received %d/%d char): '%s'", format, i, j, TA);
if (i>j) { if (strlen(TA)<29) strcat(TA," ?"); else strcpy(TA+28," ?"); }
if (strlen((char*)TA)>4) writeDMRTAInt(slotNo, (unsigned char*)TA, type);

}

void CDisplay::writeDMRBER(unsigned int slotNo, float ber)
{
writeDMRBERInt(slotNo, ber);
}

void CDisplay::clearDMR(unsigned int slotNo)
{
if (slotNo == 1U) {
Expand Down Expand Up @@ -293,6 +328,10 @@ void CDisplay::writeDMRRSSIInt(unsigned int slotNo, unsigned char rssi)
{
}

void CDisplay::writeDMRTAInt(unsigned int slotNo, unsigned char* talkerAlias, const char* type)
{
}

void CDisplay::writeDMRBERInt(unsigned int slotNo, float ber)
{
}
Expand Down
2 changes: 2 additions & 0 deletions Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class CDisplay
void writeDMR(unsigned int slotNo, const std::string& 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, unsigned char* talkerAlias, const char* type);
void clearDMR(unsigned int slotNo);

void writeFusion(const char* source, const char* dest, const char* type, const char* origin);
Expand Down Expand Up @@ -74,6 +75,7 @@ class CDisplay

virtual void writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) = 0;
virtual void writeDMRRSSIInt(unsigned int slotNo, unsigned char rssi);
virtual void writeDMRTAInt(unsigned int slotNo, unsigned char* talkerAlias, const char* type);
virtual void writeDMRBERInt(unsigned int slotNo, float ber);
virtual void clearDMRInt(unsigned int slotNo) = 0;

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LDFLAGS = -g
OBJECTS = \
AMBEFEC.o BCH.o BPTC19696.o Conf.o CRC.o Display.o DMRControl.o DMRCSBK.o DMRData.o DMRDataHeader.o DMREMB.o DMREmbeddedData.o DMRFullLC.o DMRLookup.o DMRLC.o \
DMRNetwork.o DMRShortLC.o DMRSlot.o DMRSlotType.o DMRAccessControl.o DMRTrellis.o DStarControl.o DStarHeader.o DStarNetwork.o DStarSlowData.o Golay2087.o \
Golay24128.o Hamming.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o Nextion.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o \
Golay24128.o Hamming.o LCDproc.o Log.o MMDVMHost.o Modem.o ModemSerialPort.o Mutex.o Nextion.o Network.o NullDisplay.o P25Audio.o P25Control.o P25Data.o P25LowSpeedData.o \
P25Network.o P25NID.o P25Utils.o QR1676.o RS129.o RS241213.o RSSIInterpolator.o SerialController.o SerialPort.o SHA256.o StopWatch.o Sync.o TFTSerial.o Thread.o \
Timer.o UDPSocket.o UMP.o Utils.o YSFControl.o YSFConvolution.o YSFFICH.o YSFNetwork.o YSFPayload.o

Expand Down
Loading

0 comments on commit 3a9c011

Please sign in to comment.