Skip to content

Commit

Permalink
Display the RSSI on the Nextion screen.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Jan 5, 2017
1 parent af721f8 commit 3c9666e
Show file tree
Hide file tree
Showing 10 changed files with 164 additions and 9 deletions.
5 changes: 5 additions & 0 deletions DMRSlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ void CDMRSlot::writeModem(unsigned char *data, unsigned int len)
if (m_netState == RS_NET_IDLE) {
setShortLC(m_slotNo, dstId, flco, true);
m_display->writeDMR(m_slotNo, src, flco == FLCO_GROUP, dst, "R");
m_display->writeDMRRSSI(m_slotNo, m_rssi);
}

LogMessage("DMR Slot %u, received RF voice header from %s to %s%s", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str());
Expand Down Expand Up @@ -337,6 +338,7 @@ void CDMRSlot::writeModem(unsigned char *data, unsigned int len)
if (m_netState == RS_NET_IDLE) {
setShortLC(m_slotNo, dstId, gi ? FLCO_GROUP : FLCO_USER_USER, false);
m_display->writeDMR(m_slotNo, src, gi, dst, "R");
m_display->writeDMRRSSI(m_slotNo, m_rssi);
}

LogMessage("DMR Slot %u, received RF data header from %s to %s%s, %u blocks", m_slotNo, src.c_str(), gi ? "TG ": "", dst.c_str(), m_rfFrames);
Expand Down Expand Up @@ -475,6 +477,8 @@ void CDMRSlot::writeModem(unsigned char *data, unsigned int len)
writeQueueRF(data);

writeNetworkRF(data, DT_VOICE_SYNC, errors);

m_display->writeDMRRSSI(m_slotNo, m_rssi);
} else if (m_rfState == RS_RF_LISTENING) {
m_rfEmbeddedLC.reset();
m_rfState = RS_RF_LATE_ENTRY;
Expand Down Expand Up @@ -614,6 +618,7 @@ void CDMRSlot::writeModem(unsigned char *data, unsigned int len)
if (m_netState == RS_NET_IDLE) {
setShortLC(m_slotNo, dstId, flco, true);
m_display->writeDMR(m_slotNo, src, flco == FLCO_GROUP, dst, "R");
m_display->writeDMRRSSI(m_slotNo, m_rssi);
}

LogMessage("DMR Slot %u, received RF late entry from %s to %s%s", m_slotNo, src.c_str(), flco == FLCO_GROUP ? "TG " : "", dst.c_str());
Expand Down
14 changes: 10 additions & 4 deletions DStarControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,10 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)

m_rfState = RS_RF_AUDIO;

if (m_netState == RS_NET_IDLE)
if (m_netState == RS_NET_IDLE) {
m_display->writeDStar((char*)my1, (char*)my2, (char*)your, "R", " ");
m_display->writeDStarRSSI(m_rssi);
}

LogMessage("D-Star, received RF header from %8.8s/%4.4s to %8.8s", my1, my2, your);
} else if (type == TAG_EOT) {
Expand Down Expand Up @@ -304,9 +306,11 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)
if (::memcmp(data + 1U + DSTAR_VOICE_FRAME_LENGTH_BYTES, DSTAR_SYNC_BYTES, DSTAR_DATA_FRAME_LENGTH_BYTES) == 0)
m_rfN = 0U;

// Regenerate the sync
if (m_rfN == 0U)
// Regenerate the sync and send the RSSI data to the display
if (m_rfN == 0U) {
CSync::addDStarSync(data + 1U);
m_display->writeDStarRSSI(m_rssi);
}

LogDebug("D-Star, audio sequence no. %u, errs: %u/48", m_rfN, errors);

Expand Down Expand Up @@ -438,8 +442,10 @@ bool CDStarControl::writeModem(unsigned char *data, unsigned int len)

m_rfN = (m_rfN + 1U) % 21U;

if (m_netState == RS_NET_IDLE)
if (m_netState == RS_NET_IDLE) {
m_display->writeDStar((char*)my1, (char*)my2, (char*)your, "R", " ");
m_display->writeDStarRSSI(m_rssi);
}

LogMessage("D-Star, received RF late entry from %8.8s/%4.4s to %8.8s", my1, my2, your);
}
Expand Down
42 changes: 41 additions & 1 deletion Display.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017 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
Expand Down Expand Up @@ -84,6 +84,12 @@ void CDisplay::writeDStar(const char* my1, const char* my2, const char* your, co
writeDStarInt(my1, my2, your, type, reflector);
}

void CDisplay::writeDStarRSSI(unsigned char rssi)
{
if (rssi != 0U)
writeDStarRSSIInt(rssi);
}

void CDisplay::clearDStar()
{
if (m_timer1.hasExpired()) {
Expand All @@ -110,6 +116,12 @@ void CDisplay::writeDMR(unsigned int slotNo, const std::string& src, bool group,
writeDMRInt(slotNo, src, group, dst, type);
}

void CDisplay::writeDMRRSSI(unsigned int slotNo, unsigned char rssi)
{
if (rssi != 0U)
writeDMRRSSIInt(slotNo, rssi);
}

void CDisplay::clearDMR(unsigned int slotNo)
{
if (slotNo == 1U) {
Expand Down Expand Up @@ -144,6 +156,12 @@ void CDisplay::writeFusion(const char* source, const char* dest, const char* typ
writeFusionInt(source, dest, type, origin);
}

void CDisplay::writeFusionRSSI(unsigned char rssi)
{
if (rssi != 0U)
writeFusionRSSIInt(rssi);
}

void CDisplay::clearFusion()
{
if (m_timer1.hasExpired()) {
Expand All @@ -166,6 +184,12 @@ void CDisplay::writeP25(const char* source, bool group, unsigned int dest, const
writeP25Int(source, group, dest, type);
}

void CDisplay::writeP25RSSI(unsigned char rssi)
{
if (rssi != 0U)
writeP25RSSIInt(rssi);
}

void CDisplay::clearP25()
{
if (m_timer1.hasExpired()) {
Expand Down Expand Up @@ -236,3 +260,19 @@ void CDisplay::clock(unsigned int ms)
void CDisplay::clockInt(unsigned int ms)
{
}

void CDisplay::writeDStarRSSIInt(unsigned char rssi)
{
}

void CDisplay::writeDMRRSSIInt(unsigned int slotNo, unsigned char rssi)
{
}

void CDisplay::writeFusionRSSIInt(unsigned char rssi)
{
}

void CDisplay::writeP25RSSIInt(unsigned char rssi)
{
}
10 changes: 9 additions & 1 deletion Display.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017 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
Expand Down Expand Up @@ -36,15 +36,19 @@ class CDisplay
void setError(const char* text);

void writeDStar(const char* my1, const char* my2, const char* your, const char* type, const char* reflector);
void writeDStarRSSI(unsigned char rssi);
void clearDStar();

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 clearDMR(unsigned int slotNo);

void writeFusion(const char* source, const char* dest, const char* type, const char* origin);
void writeFusionRSSI(unsigned char rssi);
void clearFusion();

void writeP25(const char* source, bool group, unsigned int dest, const char* type);
void writeP25RSSI(unsigned char rssi);
void clearP25();

void writeCW();
Expand All @@ -60,15 +64,19 @@ class CDisplay
virtual void setErrorInt(const char* text) = 0;

virtual void writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) = 0;
virtual void writeDStarRSSIInt(unsigned char rssi);
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 void writeDMRRSSIInt(unsigned int slotNo, unsigned char rssi);
virtual void clearDMRInt(unsigned int slotNo) = 0;

virtual void writeFusionInt(const char* source, const char* dest, const char* type, const char* origin) = 0;
virtual void writeFusionRSSIInt(unsigned char rssi);
virtual void clearFusionInt() = 0;

virtual void writeP25Int(const char* source, bool group, unsigned int dest, const char* type) = 0;
virtual void writeP25RSSIInt(unsigned char rssi);
virtual void clearP25Int() = 0;

virtual void writeCWInt() = 0;
Expand Down
84 changes: 82 additions & 2 deletions Nextion.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017 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
Expand All @@ -25,6 +25,11 @@
#include <ctime>
#include <clocale>

const unsigned int DSTAR_RSSI_COUNT = 3U; // 3 * 420ms = 1260ms
const unsigned int DMR_RSSI_COUNT = 4U; // 4 * 360ms = 1440ms
const unsigned int YSF_RSSI_COUNT = 13U; // 13 * 100ms = 1300ms
const unsigned int P25_RSSI_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),
Expand All @@ -35,7 +40,9 @@ m_mode(MODE_IDLE),
m_displayClock(displayClock),
m_utc(utc),
m_idleBrightness(idleBrightness),
m_clockDisplayTimer(1000U, 0U, 400U)
m_clockDisplayTimer(1000U, 0U, 400U),
m_rssiCount1(0U),
m_rssiCount2(0U)
{
assert(serial != NULL);
assert(brightness >= 0U && brightness <= 100U);
Expand Down Expand Up @@ -143,13 +150,28 @@ void CNextion::writeDStarInt(const char* my1, const char* my2, const char* your,
m_clockDisplayTimer.stop();

m_mode = MODE_DSTAR;
m_rssiCount1 = 0U;
}

void CNextion::writeDStarRSSIInt(unsigned char rssi)
{
if (m_rssiCount1 == 0U) {
char text[20U];
::sprintf(text, "t3.txt=\"-%u dBm\"", rssi);
sendCommand(text);
}

m_rssiCount1++;
if (m_rssiCount1 >= DSTAR_RSSI_COUNT)
m_rssiCount1 = 0U;
}

void CNextion::clearDStarInt()
{
sendCommand("t0.txt=\"Listening\"");
sendCommand("t1.txt=\"\"");
sendCommand("t2.txt=\"\"");
sendCommand("t3.txt=\"\"");
}

void CNextion::writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type)
Expand Down Expand Up @@ -186,16 +208,45 @@ void CNextion::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro
m_clockDisplayTimer.stop();

m_mode = MODE_DMR;
m_rssiCount1 = 0U;
m_rssiCount2 = 0U;
}

void CNextion::writeDMRRSSIInt(unsigned int slotNo, unsigned char rssi)
{
if (slotNo == 1U) {
if (m_rssiCount1 == 0U) {
char text[20U];
::sprintf(text, "t4.txt=\"-%u dBm\"", rssi);
sendCommand(text);
}

m_rssiCount1++;
if (m_rssiCount1 >= DMR_RSSI_COUNT)
m_rssiCount1 = 0U;
} else {
if (m_rssiCount2 == 0U) {
char text[20U];
::sprintf(text, "t5.txt=\"-%u dBm\"", rssi);
sendCommand(text);
}

m_rssiCount2++;
if (m_rssiCount2 >= DMR_RSSI_COUNT)
m_rssiCount2 = 0U;
}
}

void CNextion::clearDMRInt(unsigned int slotNo)
{
if (slotNo == 1U) {
sendCommand("t0.txt=\"1 Listening\"");
sendCommand("t1.txt=\"\"");
sendCommand("t4.txt=\"\"");
} else {
sendCommand("t2.txt=\"2 Listening\"");
sendCommand("t3.txt=\"\"");
sendCommand("t5.txt=\"\"");
}
}

Expand Down Expand Up @@ -226,13 +277,28 @@ void CNextion::writeFusionInt(const char* source, const char* dest, const char*
m_clockDisplayTimer.stop();

m_mode = MODE_YSF;
m_rssiCount1 = 0U;
}

void CNextion::writeFusionRSSIInt(unsigned char rssi)
{
if (m_rssiCount1 == 0U) {
char text[20U];
::sprintf(text, "t3.txt=\"-%u dBm\"", rssi);
sendCommand(text);
}

m_rssiCount1++;
if (m_rssiCount1 >= YSF_RSSI_COUNT)
m_rssiCount1 = 0U;
}

void CNextion::clearFusionInt()
{
sendCommand("t0.txt=\"Listening\"");
sendCommand("t1.txt=\"\"");
sendCommand("t2.txt=\"\"");
sendCommand("t3.txt=\"\"");
}

void CNextion::writeP25Int(const char* source, bool group, unsigned int dest, const char* type)
Expand All @@ -256,6 +322,20 @@ void CNextion::writeP25Int(const char* source, bool group, unsigned int dest, co
m_clockDisplayTimer.stop();

m_mode = MODE_P25;
m_rssiCount1 = 0U;
}

void CNextion::writeP25RSSIInt(unsigned char rssi)
{
if (m_rssiCount1 == 0U) {
char text[20U];
::sprintf(text, "t2.txt=\"-%u dBm\"", rssi);
sendCommand(text);
}

m_rssiCount1++;
if (m_rssiCount1 >= P25_RSSI_COUNT)
m_rssiCount1 = 0U;
}

void CNextion::clearP25Int()
Expand Down
8 changes: 7 additions & 1 deletion Nextion.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017 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
Expand Down Expand Up @@ -42,15 +42,19 @@ class CNextion : public CDisplay
virtual void setLockoutInt();

virtual void writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector);
virtual void writeDStarRSSIInt(unsigned char rssi);
virtual void clearDStarInt();

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

virtual void writeFusionInt(const char* source, const char* dest, const char* type, const char* origin);
virtual void writeFusionRSSIInt(unsigned char rssi);
virtual void clearFusionInt();

virtual void writeP25Int(const char* source, bool group, unsigned int dest, const char* type);
virtual void writeP25RSSIInt(unsigned char rssi);
virtual void clearP25Int();

virtual void writeCWInt();
Expand All @@ -68,6 +72,8 @@ class CNextion : public CDisplay
bool m_utc;
unsigned int m_idleBrightness;
CTimer m_clockDisplayTimer;
unsigned int m_rssiCount1;
unsigned int m_rssiCount2;

void sendCommand(const char* command);
};
Expand Down
Binary file modified Nextion/NX3224K024.HMI
Binary file not shown.
Binary file modified Nextion/NX3224K024.tft
Binary file not shown.
Loading

0 comments on commit 3c9666e

Please sign in to comment.