From 14a06e7182e0457c84ec86675159a6d60ed3ff91 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 5 Feb 2018 19:07:23 +0000 Subject: [PATCH] Calculate the RSSI and BER correctly on the Nextion. --- Nextion.cpp | 114 ++++++---------------------------------------------- 1 file changed, 13 insertions(+), 101 deletions(-) diff --git a/Nextion.cpp b/Nextion.cpp index d0495ba..cbdc9c1 100644 --- a/Nextion.cpp +++ b/Nextion.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016,2017 by Jonathan Naylor G4KLX + * Copyright (C) 2016,2017,2018 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 @@ -205,15 +205,6 @@ void CNextion::writeDStarInt(const char* my1, const char* my2, const char* your, void CNextion::writeDStarRSSIInt(unsigned char rssi) { - if (m_rssiCount1 == 0U) { - char text[20U]; - ::sprintf(text, "t3.txt=\"-%udBm\"", rssi); - sendCommand(text); - sendCommandAction(47U); - m_rssiCount1 = 1U; - return; - } - m_rssiAccum1 += rssi; m_rssiCount1++; @@ -223,21 +214,12 @@ void CNextion::writeDStarRSSIInt(unsigned char rssi) sendCommand(text); sendCommandAction(47U); m_rssiAccum1 = 0U; - m_rssiCount1 = 1U; + m_rssiCount1 = 0U; } } void CNextion::writeDStarBERInt(float ber) { - if (m_berCount1 == 0U) { - char text[20U]; - ::sprintf(text, "t4.txt=\"%.1f%%\"", ber); - sendCommand(text); - sendCommandAction(48U); - m_berCount1 = 1U; - return; - } - m_berAccum1 += ber; m_berCount1++; @@ -247,7 +229,7 @@ void CNextion::writeDStarBERInt(float ber) sendCommand(text); sendCommandAction(48U); m_berAccum1 = 0.0F; - m_berCount1 = 1U; + m_berCount1 = 0U; } } @@ -339,15 +321,6 @@ void CNextion::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro void CNextion::writeDMRRSSIInt(unsigned int slotNo, unsigned char rssi) { if (slotNo == 1U) { - if (m_rssiCount1 == 0U) { - char text[20U]; - ::sprintf(text, "t4.txt=\"-%udBm\"", rssi); - sendCommand(text); - sendCommandAction(66U); - m_rssiCount1 = 1U; - return; - } - m_rssiAccum1 += rssi; m_rssiCount1++; @@ -357,18 +330,9 @@ void CNextion::writeDMRRSSIInt(unsigned int slotNo, unsigned char rssi) sendCommand(text); sendCommandAction(66U); m_rssiAccum1 = 0U; - m_rssiCount1 = 1U; + m_rssiCount1 = 0U; } } else { - if (m_rssiCount2 == 0U) { - char text[20U]; - ::sprintf(text, "t5.txt=\"-%udBm\"", rssi); - sendCommandAction(74U); - sendCommand(text); - m_rssiCount2 = 1U; - return; - } - m_rssiAccum2 += rssi; m_rssiCount2++; @@ -378,7 +342,7 @@ void CNextion::writeDMRRSSIInt(unsigned int slotNo, unsigned char rssi) sendCommand(text); sendCommandAction(74U); m_rssiAccum2 = 0U; - m_rssiCount2 = 1U; + m_rssiCount2 = 0U; } } } @@ -396,6 +360,7 @@ void CNextion::writeDMRTAInt(unsigned int slotNo, unsigned char* talkerAlias, co if (m_screenLayout == 2U) sendCommand("t2.pco=33808"); sendCommandAction(72U); } + return; } @@ -413,6 +378,7 @@ void CNextion::writeDMRTAInt(unsigned int slotNo, unsigned char* talkerAlias, co sendCommand("t0.pco=1024"); } + sendCommand(text); sendCommandAction(63U); } else { @@ -437,15 +403,6 @@ void CNextion::writeDMRTAInt(unsigned int slotNo, unsigned char* talkerAlias, co void CNextion::writeDMRBERInt(unsigned int slotNo, float ber) { if (slotNo == 1U) { - if (m_berCount1 == 0U) { - char text[20U]; - ::sprintf(text, "t6.txt=\"%.1f%%\"", ber); - sendCommand(text); - sendCommandAction(67U); - m_berCount1 = 1U; - return; - } - m_berAccum1 += ber; m_berCount1++; @@ -455,18 +412,9 @@ void CNextion::writeDMRBERInt(unsigned int slotNo, float ber) sendCommand(text); sendCommandAction(67U); m_berAccum1 = 0U; - m_berCount1 = 1U; + m_berCount1 = 0U; } } else { - if (m_berCount2 == 0U) { - char text[20U]; - ::sprintf(text, "t7.txt=\"%.1f%%\"", ber); - sendCommand(text); - sendCommandAction(75U); - m_berCount2 = 1U; - return; - } - m_berAccum2 += ber; m_berCount2++; @@ -476,7 +424,7 @@ void CNextion::writeDMRBERInt(unsigned int slotNo, float ber) sendCommand(text); sendCommandAction(75U); m_berAccum2 = 0U; - m_berCount2 = 1U; + m_berCount2 = 0U; } } } @@ -551,15 +499,6 @@ void CNextion::writeFusionInt(const char* source, const char* dest, const char* void CNextion::writeFusionRSSIInt(unsigned char rssi) { - if (m_rssiCount1 == 0U) { - char text[20U]; - ::sprintf(text, "t3.txt=\"-%udBm\"", rssi); - sendCommand(text); - sendCommandAction(85U); - m_rssiCount1 = 1U; - return; - } - m_rssiAccum1 += rssi; m_rssiCount1++; @@ -569,21 +508,12 @@ void CNextion::writeFusionRSSIInt(unsigned char rssi) sendCommand(text); sendCommandAction(85U); m_rssiAccum1 = 0U; - m_rssiCount1 = 1U; + m_rssiCount1 = 0U; } } void CNextion::writeFusionBERInt(float ber) { - if (m_berCount1 == 0U) { - char text[20U]; - ::sprintf(text, "t4.txt=\"%.1f%%\"", ber); - sendCommand(text); - sendCommandAction(86U); - m_berCount1 = 1U; - return; - } - m_berAccum1 += ber; m_berCount1++; @@ -593,7 +523,7 @@ void CNextion::writeFusionBERInt(float ber) sendCommand(text); sendCommandAction(86U); m_berAccum1 = 0.0F; - m_berCount1 = 1U; + m_berCount1 = 0U; } } @@ -640,15 +570,6 @@ void CNextion::writeP25Int(const char* source, bool group, unsigned int dest, co void CNextion::writeP25RSSIInt(unsigned char rssi) { - if (m_rssiCount1 == 0U) { - char text[20U]; - ::sprintf(text, "t2.txt=\"-%udBm\"", rssi); - sendCommand(text); - sendCommandAction(104U); - m_rssiCount1 = 1U; - return; - } - m_rssiAccum1 += rssi; m_rssiCount1++; @@ -658,21 +579,12 @@ void CNextion::writeP25RSSIInt(unsigned char rssi) sendCommand(text); sendCommandAction(104U); m_rssiAccum1 = 0U; - m_rssiCount1 = 1U; + m_rssiCount1 = 0U; } } void CNextion::writeP25BERInt(float ber) { - if (m_berCount1 == 0U) { - char text[20U]; - ::sprintf(text, "t3.txt=\"%.1f%%\"", ber); - sendCommand(text); - sendCommandAction(105U); - m_berCount1 = 1U; - return; - } - m_berAccum1 += ber; m_berCount1++; @@ -682,7 +594,7 @@ void CNextion::writeP25BERInt(float ber) sendCommand(text); sendCommandAction(105U); m_berAccum1 = 0.0F; - m_berCount1 = 1U; + m_berCount1 = 0U; } }