2016-04-06 20:53:25 +02:00
|
|
|
/*
|
2017-01-05 20:44:52 +01:00
|
|
|
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX
|
2016-04-06 20:53:25 +02:00
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
2017-11-15 11:47:56 +01:00
|
|
|
#include "NetworkInfo.h"
|
2016-04-06 20:53:25 +02:00
|
|
|
#include "Nextion.h"
|
|
|
|
#include "Log.h"
|
|
|
|
|
|
|
|
#include <cstdio>
|
|
|
|
#include <cassert>
|
|
|
|
#include <cstring>
|
2016-06-01 12:55:24 +02:00
|
|
|
#include <ctime>
|
2016-09-09 11:42:01 +02:00
|
|
|
#include <clocale>
|
2017-11-13 21:48:47 +01:00
|
|
|
//#include <unistd.h>
|
2017-10-02 21:04:46 +02:00
|
|
|
|
2017-02-12 19:37:00 +01:00
|
|
|
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
|
|
|
|
const unsigned int DMR_BER_COUNT = 24U; // 24 * 60ms = 1440ms
|
2017-01-05 20:44:52 +01:00
|
|
|
const unsigned int YSF_RSSI_COUNT = 13U; // 13 * 100ms = 1300ms
|
2017-02-12 19:37:00 +01:00
|
|
|
const unsigned int YSF_BER_COUNT = 13U; // 13 * 100ms = 1300ms
|
|
|
|
const unsigned int P25_RSSI_COUNT = 7U; // 7 * 180ms = 1260ms
|
|
|
|
const unsigned int P25_BER_COUNT = 7U; // 7 * 180ms = 1260ms
|
2017-01-05 20:44:52 +01:00
|
|
|
|
2017-11-13 21:48:47 +01:00
|
|
|
CNextion::CNextion(const std::string& callsign, unsigned int dmrid, ISerialPort* serial, unsigned int brightness, bool displayClock, bool utc, unsigned int idleBrightness, unsigned int screenLayout) :
|
2016-05-09 19:14:27 +02:00
|
|
|
CDisplay(),
|
2016-04-08 13:47:05 +02:00
|
|
|
m_callsign(callsign),
|
2017-11-13 21:48:47 +01:00
|
|
|
m_ipaddress("(ip unknown)"),
|
2016-04-08 13:47:05 +02:00
|
|
|
m_dmrid(dmrid),
|
2016-10-06 19:38:16 +02:00
|
|
|
m_serial(serial),
|
2016-04-11 13:21:46 +02:00
|
|
|
m_brightness(brightness),
|
2016-06-01 12:55:24 +02:00
|
|
|
m_mode(MODE_IDLE),
|
|
|
|
m_displayClock(displayClock),
|
|
|
|
m_utc(utc),
|
2016-06-24 11:33:28 +02:00
|
|
|
m_idleBrightness(idleBrightness),
|
2017-11-13 21:48:47 +01:00
|
|
|
m_screenLayout(screenLayout),
|
2017-01-05 20:44:52 +01:00
|
|
|
m_clockDisplayTimer(1000U, 0U, 400U),
|
2017-02-12 19:37:00 +01:00
|
|
|
m_rssiAccum1(0U),
|
|
|
|
m_rssiAccum2(0U),
|
|
|
|
m_berAccum1(0.0F),
|
|
|
|
m_berAccum2(0.0F),
|
2017-02-13 09:20:40 +01:00
|
|
|
m_rssiCount1(0U),
|
|
|
|
m_rssiCount2(0U),
|
|
|
|
m_berCount1(0U),
|
|
|
|
m_berCount2(0U)
|
2016-04-06 20:53:25 +02:00
|
|
|
{
|
2016-10-06 19:38:16 +02:00
|
|
|
assert(serial != NULL);
|
2016-04-06 20:53:25 +02:00
|
|
|
assert(brightness >= 0U && brightness <= 100U);
|
|
|
|
}
|
|
|
|
|
|
|
|
CNextion::~CNextion()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CNextion::open()
|
|
|
|
{
|
2017-11-13 21:48:47 +01:00
|
|
|
unsigned char info[100U];
|
|
|
|
CNetworkInfo* m_network;
|
|
|
|
|
2016-10-06 19:38:16 +02:00
|
|
|
bool ret = m_serial->open();
|
2016-04-06 20:53:25 +02:00
|
|
|
if (!ret) {
|
|
|
|
LogError("Cannot open the port for the Nextion display");
|
2016-10-06 19:38:16 +02:00
|
|
|
delete m_serial;
|
2016-04-06 20:53:25 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-11-13 21:48:47 +01:00
|
|
|
info[0]=0;
|
|
|
|
m_network = new CNetworkInfo;
|
|
|
|
m_network->getNetworkInterface(info);
|
|
|
|
m_ipaddress = (char*)info;
|
|
|
|
|
2016-04-06 20:53:25 +02:00
|
|
|
sendCommand("bkcmd=0");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,0);
|
2016-04-06 20:53:25 +02:00
|
|
|
|
|
|
|
setIdle();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-11-13 21:48:47 +01:00
|
|
|
|
2016-05-09 19:14:27 +02:00
|
|
|
void CNextion::setIdleInt()
|
2016-04-06 20:53:25 +02:00
|
|
|
{
|
|
|
|
sendCommand("page MMDVM");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,1U);
|
2016-04-06 20:53:25 +02:00
|
|
|
|
2017-11-13 21:48:47 +01:00
|
|
|
char command[30U];
|
2016-06-24 11:33:28 +02:00
|
|
|
::sprintf(command, "dim=%u", m_idleBrightness);
|
2016-06-24 09:30:46 +02:00
|
|
|
sendCommand(command);
|
2017-11-13 21:48:47 +01:00
|
|
|
|
|
|
|
::sprintf(command, "t0.txt=\"%s/%u\"", m_callsign.c_str(), m_dmrid);
|
|
|
|
sendCommand(command);
|
2017-12-17 19:09:28 +01:00
|
|
|
if (m_screenLayout > 2U) {
|
|
|
|
::sprintf(command, "t4.txt=\"%s\"", m_callsign.c_str());
|
|
|
|
sendCommand(command);
|
|
|
|
::sprintf(command, "t5.txt=\"%u\"", m_dmrid);
|
|
|
|
sendCommand(command);
|
|
|
|
}
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,17U);
|
2017-10-24 22:55:58 +02:00
|
|
|
|
2017-11-13 21:48:47 +01:00
|
|
|
sendCommand("t1.txt=\"MMDVM IDLE\"");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(1U,11U);
|
2017-10-24 22:55:58 +02:00
|
|
|
|
2017-11-13 21:48:47 +01:00
|
|
|
::sprintf(command, "t3.txt=\"%s\"", m_ipaddress.c_str());
|
2016-04-08 13:47:05 +02:00
|
|
|
sendCommand(command);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(3U,16U);
|
2016-04-11 13:21:46 +02:00
|
|
|
|
2016-06-01 12:55:24 +02:00
|
|
|
m_clockDisplayTimer.start();
|
|
|
|
|
2016-04-11 13:21:46 +02:00
|
|
|
m_mode = MODE_IDLE;
|
2016-04-06 20:53:25 +02:00
|
|
|
}
|
|
|
|
|
2016-05-09 19:14:27 +02:00
|
|
|
void CNextion::setErrorInt(const char* text)
|
2016-04-06 20:53:25 +02:00
|
|
|
{
|
|
|
|
assert(text != NULL);
|
|
|
|
|
|
|
|
sendCommand("page MMDVM");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,1U);
|
2016-04-06 20:53:25 +02:00
|
|
|
|
|
|
|
char command[20];
|
2016-06-24 09:30:46 +02:00
|
|
|
::sprintf(command, "dim=%u", m_brightness);
|
|
|
|
sendCommand(command);
|
|
|
|
|
2016-04-06 20:53:25 +02:00
|
|
|
::sprintf(command, "t0.txt=\"%s\"", text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,13U);
|
2016-04-06 20:53:25 +02:00
|
|
|
|
|
|
|
sendCommand(command);
|
|
|
|
sendCommand("t1.txt=\"ERROR\"");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(1U,14U);
|
2016-04-11 13:21:46 +02:00
|
|
|
|
2016-06-01 12:55:24 +02:00
|
|
|
m_clockDisplayTimer.stop();
|
|
|
|
|
2016-04-11 13:21:46 +02:00
|
|
|
m_mode = MODE_ERROR;
|
2016-04-06 20:53:25 +02:00
|
|
|
}
|
|
|
|
|
2016-05-09 19:14:27 +02:00
|
|
|
void CNextion::setLockoutInt()
|
2016-04-06 20:53:25 +02:00
|
|
|
{
|
|
|
|
sendCommand("page MMDVM");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,1U);
|
2016-04-06 20:53:25 +02:00
|
|
|
|
2016-06-24 09:30:46 +02:00
|
|
|
char command[20];
|
|
|
|
::sprintf(command, "dim=%u", m_brightness);
|
|
|
|
sendCommand(command);
|
|
|
|
|
2016-04-06 20:53:25 +02:00
|
|
|
sendCommand("t0.txt=\"LOCKOUT\"");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,15U);
|
2016-04-06 20:53:25 +02:00
|
|
|
|
2016-06-01 12:55:24 +02:00
|
|
|
m_clockDisplayTimer.stop();
|
|
|
|
|
2016-04-11 13:21:46 +02:00
|
|
|
m_mode = MODE_LOCKOUT;
|
2016-04-06 20:53:25 +02:00
|
|
|
}
|
|
|
|
|
2016-05-09 19:14:27 +02:00
|
|
|
void CNextion::writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector)
|
2016-04-06 20:53:25 +02:00
|
|
|
{
|
|
|
|
assert(my1 != NULL);
|
|
|
|
assert(my2 != NULL);
|
|
|
|
assert(your != NULL);
|
2016-04-12 18:46:48 +02:00
|
|
|
assert(type != NULL);
|
2016-04-16 22:20:18 +02:00
|
|
|
assert(reflector != NULL);
|
2016-04-06 20:53:25 +02:00
|
|
|
|
2017-12-10 21:50:47 +01:00
|
|
|
if (m_mode != MODE_DSTAR) {
|
2017-02-13 09:20:40 +01:00
|
|
|
sendCommand("page DStar");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,2U);
|
|
|
|
}
|
2016-04-11 13:21:46 +02:00
|
|
|
|
2016-04-06 20:53:25 +02:00
|
|
|
char text[30U];
|
2016-06-24 09:30:46 +02:00
|
|
|
::sprintf(text, "dim=%u", m_brightness);
|
|
|
|
sendCommand(text);
|
|
|
|
|
2016-04-12 08:18:01 +02:00
|
|
|
::sprintf(text, "t0.txt=\"%s %.8s/%4.4s\"", type, my1, my2);
|
2016-04-06 20:53:25 +02:00
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,22U);
|
2016-04-06 20:53:25 +02:00
|
|
|
|
2016-05-23 19:36:53 +02:00
|
|
|
::sprintf(text, "t1.txt=\"%.8s\"", your);
|
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(1U,23U);
|
2016-05-23 19:36:53 +02:00
|
|
|
|
|
|
|
if (::strcmp(reflector, " ") != 0) {
|
|
|
|
::sprintf(text, "t2.txt=\"via %.8s\"", reflector);
|
2016-04-27 21:48:20 +02:00
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(2U,24U);
|
2016-04-16 22:20:18 +02:00
|
|
|
}
|
2016-04-11 13:21:46 +02:00
|
|
|
|
2016-06-01 12:55:24 +02:00
|
|
|
m_clockDisplayTimer.stop();
|
|
|
|
|
2016-04-11 13:21:46 +02:00
|
|
|
m_mode = MODE_DSTAR;
|
2017-02-12 19:37:00 +01:00
|
|
|
m_rssiAccum1 = 0U;
|
|
|
|
m_berAccum1 = 0.0F;
|
2017-02-13 09:20:40 +01:00
|
|
|
m_rssiCount1 = 0U;
|
|
|
|
m_berCount1 = 0U;
|
2017-01-05 20:44:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CNextion::writeDStarRSSIInt(unsigned char rssi)
|
|
|
|
{
|
2017-02-13 09:20:40 +01:00
|
|
|
if (m_rssiCount1 == 0U) {
|
|
|
|
char text[20U];
|
|
|
|
::sprintf(text, "t3.txt=\"-%udBm\"", rssi);
|
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(3U,25U);
|
2017-02-13 09:20:40 +01:00
|
|
|
m_rssiCount1 = 1U;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-12 19:37:00 +01:00
|
|
|
m_rssiAccum1 += rssi;
|
|
|
|
m_rssiCount1++;
|
|
|
|
|
|
|
|
if (m_rssiCount1 == DSTAR_RSSI_COUNT) {
|
2017-01-05 20:44:52 +01:00
|
|
|
char text[20U];
|
2017-02-12 19:37:00 +01:00
|
|
|
::sprintf(text, "t3.txt=\"-%udBm\"", m_rssiAccum1 / DSTAR_RSSI_COUNT);
|
2017-01-05 20:44:52 +01:00
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(3U,25U);
|
2017-02-12 19:37:00 +01:00
|
|
|
m_rssiAccum1 = 0U;
|
|
|
|
m_rssiCount1 = 1U;
|
2017-01-05 20:44:52 +01:00
|
|
|
}
|
2017-02-12 19:37:00 +01:00
|
|
|
}
|
2017-01-05 20:44:52 +01:00
|
|
|
|
2017-02-12 19:37:00 +01:00
|
|
|
void CNextion::writeDStarBERInt(float ber)
|
|
|
|
{
|
2017-02-13 09:20:40 +01:00
|
|
|
if (m_berCount1 == 0U) {
|
|
|
|
char text[20U];
|
|
|
|
::sprintf(text, "t4.txt=\"%.1f%%\"", ber);
|
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(4U,26U);
|
2017-02-13 09:20:40 +01:00
|
|
|
m_berCount1 = 1U;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-12 19:37:00 +01:00
|
|
|
m_berAccum1 += ber;
|
|
|
|
m_berCount1++;
|
|
|
|
|
|
|
|
if (m_berCount1 == DSTAR_BER_COUNT) {
|
|
|
|
char text[20U];
|
|
|
|
::sprintf(text, "t4.txt=\"%.1f%%\"", m_berAccum1 / float(DSTAR_BER_COUNT));
|
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(4U,26U);
|
2017-02-12 19:37:00 +01:00
|
|
|
m_berAccum1 = 0.0F;
|
|
|
|
m_berCount1 = 1U;
|
|
|
|
}
|
2016-04-06 20:53:25 +02:00
|
|
|
}
|
|
|
|
|
2016-05-09 19:14:27 +02:00
|
|
|
void CNextion::clearDStarInt()
|
2016-04-06 20:53:25 +02:00
|
|
|
{
|
|
|
|
sendCommand("t0.txt=\"Listening\"");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,21U);
|
2016-04-06 20:53:25 +02:00
|
|
|
sendCommand("t1.txt=\"\"");
|
2016-05-23 19:36:53 +02:00
|
|
|
sendCommand("t2.txt=\"\"");
|
2017-01-05 20:44:52 +01:00
|
|
|
sendCommand("t3.txt=\"\"");
|
2017-02-12 19:37:00 +01:00
|
|
|
sendCommand("t4.txt=\"\"");
|
2016-04-06 20:53:25 +02:00
|
|
|
}
|
|
|
|
|
2016-05-09 19:14:27 +02:00
|
|
|
void CNextion::writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type)
|
2016-04-06 20:53:25 +02:00
|
|
|
{
|
|
|
|
assert(type != NULL);
|
|
|
|
|
2016-04-11 13:21:46 +02:00
|
|
|
if (m_mode != MODE_DMR) {
|
|
|
|
sendCommand("page DMR");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,3U);
|
|
|
|
|
2016-04-11 13:21:46 +02:00
|
|
|
|
2017-11-13 21:48:47 +01:00
|
|
|
if (slotNo == 1U) {
|
2017-11-15 11:47:56 +01:00
|
|
|
if (m_screenLayout == 2U) {
|
2017-11-13 21:48:47 +01:00
|
|
|
sendCommand("t2.pco=0");
|
|
|
|
sendCommand("t2.font=4");
|
|
|
|
}
|
2017-11-15 11:47:56 +01:00
|
|
|
|
2016-04-11 13:21:46 +02:00
|
|
|
sendCommand("t2.txt=\"2 Listening\"");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(2U,31U);
|
2017-11-13 21:48:47 +01:00
|
|
|
} else {
|
2017-11-15 11:47:56 +01:00
|
|
|
if (m_screenLayout == 2U) {
|
2017-11-13 21:48:47 +01:00
|
|
|
sendCommand("t0.pco=0");
|
|
|
|
sendCommand("t0.font=4");
|
|
|
|
}
|
2017-11-15 11:47:56 +01:00
|
|
|
|
2016-04-11 13:21:46 +02:00
|
|
|
sendCommand("t0.txt=\"1 Listening\"");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,31U);
|
2017-11-13 21:48:47 +01:00
|
|
|
}
|
2016-04-11 13:21:46 +02:00
|
|
|
}
|
|
|
|
|
2016-06-24 09:30:46 +02:00
|
|
|
char text[30U];
|
|
|
|
::sprintf(text, "dim=%u", m_brightness);
|
|
|
|
sendCommand(text);
|
2016-04-06 20:53:25 +02:00
|
|
|
|
2016-06-24 09:30:46 +02:00
|
|
|
if (slotNo == 1U) {
|
2016-04-21 14:01:53 +02:00
|
|
|
::sprintf(text, "t0.txt=\"1 %s %s\"", type, src.c_str());
|
2017-11-15 11:47:56 +01:00
|
|
|
|
|
|
|
if (m_screenLayout == 2U) {
|
2017-11-13 21:48:47 +01:00
|
|
|
sendCommand("t0.pco=0");
|
|
|
|
sendCommand("t0.font=4");
|
|
|
|
}
|
2017-11-15 11:47:56 +01:00
|
|
|
|
2016-04-06 20:53:25 +02:00
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,32U);
|
2017-10-24 22:55:58 +02:00
|
|
|
|
2016-04-21 14:01:53 +02:00
|
|
|
::sprintf(text, "t1.txt=\"%s%s\"", group ? "TG" : "", dst.c_str());
|
2016-04-06 20:53:25 +02:00
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(1U,36U);
|
2016-04-06 20:53:25 +02:00
|
|
|
} else {
|
2016-04-21 14:01:53 +02:00
|
|
|
::sprintf(text, "t2.txt=\"2 %s %s\"", type, src.c_str());
|
2017-11-15 11:47:56 +01:00
|
|
|
|
|
|
|
if (m_screenLayout == 2U) {
|
2017-11-13 21:48:47 +01:00
|
|
|
sendCommand("t2.pco=0");
|
|
|
|
sendCommand("t2.font=4");
|
|
|
|
}
|
2017-11-15 11:47:56 +01:00
|
|
|
|
2016-04-06 20:53:25 +02:00
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(2U,32U);
|
2017-10-24 22:55:58 +02:00
|
|
|
|
2016-04-21 14:01:53 +02:00
|
|
|
::sprintf(text, "t3.txt=\"%s%s\"", group ? "TG" : "", dst.c_str());
|
2016-04-06 20:53:25 +02:00
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(3U,36U);
|
2016-04-06 20:53:25 +02:00
|
|
|
}
|
2016-04-11 13:21:46 +02:00
|
|
|
|
2016-06-01 12:55:24 +02:00
|
|
|
m_clockDisplayTimer.stop();
|
|
|
|
|
2016-04-11 13:21:46 +02:00
|
|
|
m_mode = MODE_DMR;
|
2017-02-12 19:37:00 +01:00
|
|
|
m_rssiAccum1 = 0U;
|
|
|
|
m_rssiAccum2 = 0U;
|
|
|
|
m_berAccum1 = 0.0F;
|
|
|
|
m_berAccum2 = 0.0F;
|
2017-02-13 09:20:40 +01:00
|
|
|
m_rssiCount1 = 0U;
|
|
|
|
m_rssiCount2 = 0U;
|
|
|
|
m_berCount1 = 0U;
|
|
|
|
m_berCount2 = 0U;
|
2017-01-05 20:44:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CNextion::writeDMRRSSIInt(unsigned int slotNo, unsigned char rssi)
|
|
|
|
{
|
|
|
|
if (slotNo == 1U) {
|
2017-02-13 09:20:40 +01:00
|
|
|
if (m_rssiCount1 == 0U) {
|
|
|
|
char text[20U];
|
|
|
|
::sprintf(text, "t4.txt=\"-%udBm\"", rssi);
|
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(4U,37U);
|
2017-02-13 09:20:40 +01:00
|
|
|
m_rssiCount1 = 1U;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-12 19:37:00 +01:00
|
|
|
m_rssiAccum1 += rssi;
|
|
|
|
m_rssiCount1++;
|
|
|
|
|
|
|
|
if (m_rssiCount1 == DMR_RSSI_COUNT) {
|
2017-01-05 20:44:52 +01:00
|
|
|
char text[20U];
|
2017-02-12 19:37:00 +01:00
|
|
|
::sprintf(text, "t4.txt=\"-%udBm\"", m_rssiAccum1 / DMR_RSSI_COUNT);
|
2017-01-05 20:44:52 +01:00
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(4U,37U);
|
2017-02-12 19:37:00 +01:00
|
|
|
m_rssiAccum1 = 0U;
|
|
|
|
m_rssiCount1 = 1U;
|
2017-01-05 20:44:52 +01:00
|
|
|
}
|
|
|
|
} else {
|
2017-02-13 09:20:40 +01:00
|
|
|
if (m_rssiCount2 == 0U) {
|
|
|
|
char text[20U];
|
|
|
|
::sprintf(text, "t5.txt=\"-%udBm\"", rssi);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(5U,37U);
|
2017-02-13 09:20:40 +01:00
|
|
|
sendCommand(text);
|
|
|
|
m_rssiCount2 = 1U;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-12 19:37:00 +01:00
|
|
|
m_rssiAccum2 += rssi;
|
|
|
|
m_rssiCount2++;
|
|
|
|
|
|
|
|
if (m_rssiCount2 == DMR_RSSI_COUNT) {
|
2017-01-05 20:44:52 +01:00
|
|
|
char text[20U];
|
2017-02-12 19:37:00 +01:00
|
|
|
::sprintf(text, "t5.txt=\"-%udBm\"", m_rssiAccum2 / DMR_RSSI_COUNT);
|
2017-01-05 20:44:52 +01:00
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(5U,37U);
|
2017-02-12 19:37:00 +01:00
|
|
|
m_rssiAccum2 = 0U;
|
|
|
|
m_rssiCount2 = 1U;
|
2017-01-05 20:44:52 +01:00
|
|
|
}
|
2017-02-12 19:37:00 +01:00
|
|
|
}
|
|
|
|
}
|
2017-01-05 20:44:52 +01:00
|
|
|
|
2017-11-15 11:47:56 +01:00
|
|
|
void CNextion::writeDMRTAInt(unsigned int slotNo, unsigned char* talkerAlias, const char* type)
|
2017-11-13 21:48:47 +01:00
|
|
|
{
|
2017-11-15 11:47:56 +01:00
|
|
|
if (m_screenLayout < 2U)
|
|
|
|
return;
|
2017-11-14 19:46:29 +01:00
|
|
|
|
2017-11-15 11:47:56 +01:00
|
|
|
if (type[0] == ' ') {
|
2017-12-05 20:50:56 +01:00
|
|
|
if (slotNo == 1U) {
|
|
|
|
if (m_screenLayout == 2U) sendCommand("t0.pco=33808");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,34U);
|
2017-12-05 20:50:56 +01:00
|
|
|
} else {
|
|
|
|
if (m_screenLayout == 2U) sendCommand("t2.pco=33808");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(2,34U);
|
2017-12-05 20:50:56 +01:00
|
|
|
}
|
2017-11-15 11:47:56 +01:00
|
|
|
return;
|
2017-12-05 20:50:56 +01:00
|
|
|
}
|
2017-11-13 21:48:47 +01:00
|
|
|
|
2017-11-15 11:47:56 +01:00
|
|
|
if (slotNo == 1U) {
|
|
|
|
char text[40U];
|
|
|
|
::sprintf(text, "t0.txt=\"1 %s %s\"", type, talkerAlias);
|
|
|
|
|
|
|
|
if (m_screenLayout == 2U) {
|
|
|
|
if (::strlen((char*)talkerAlias) > (16U-4U))
|
|
|
|
sendCommand("t0.font=3");
|
|
|
|
if (::strlen((char*)talkerAlias) > (20U-4U))
|
|
|
|
sendCommand("t0.font=2");
|
|
|
|
if (::strlen((char*)talkerAlias) > (24U-4U))
|
|
|
|
sendCommand("t0.font=1");
|
|
|
|
|
2017-12-05 20:50:56 +01:00
|
|
|
sendCommand("t0.pco=1024");
|
|
|
|
}
|
2017-11-15 11:47:56 +01:00
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,33U);
|
2017-11-15 11:47:56 +01:00
|
|
|
} else {
|
|
|
|
char text[40U];
|
|
|
|
::sprintf(text, "t2.txt=\"2 %s %s\"", type, talkerAlias);
|
|
|
|
|
|
|
|
if (m_screenLayout == 2U) {
|
|
|
|
if (::strlen((char*)talkerAlias) > (16U-4U))
|
|
|
|
sendCommand("t2.font=3");
|
|
|
|
if (::strlen((char*)talkerAlias) > (20U-4U))
|
|
|
|
sendCommand("t2.font=2");
|
|
|
|
if (::strlen((char*)talkerAlias) > (24U-4U))
|
|
|
|
sendCommand("t2.font=1");
|
|
|
|
|
2017-12-05 20:50:56 +01:00
|
|
|
sendCommand("t2.pco=1024");
|
|
|
|
}
|
2017-11-15 11:47:56 +01:00
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(2U,33U);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CNextion::writeDMRGPSInt(unsigned int slotNo, float latitude, float longitude, unsigned char positionError)
|
|
|
|
{
|
|
|
|
char Lat,Lon,text[40];
|
|
|
|
|
|
|
|
if (m_screenLayout < 2U)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (latitude<0) {
|
|
|
|
latitude=-latitude;
|
|
|
|
Lat='S';
|
|
|
|
} else {
|
|
|
|
Lat='N';
|
|
|
|
}
|
|
|
|
if (longitude<0) {
|
|
|
|
longitude=-longitude;
|
|
|
|
Lon='W';
|
|
|
|
} else {
|
|
|
|
Lon='E';
|
|
|
|
}
|
|
|
|
int degreeLat = (int)latitude;
|
|
|
|
int minutesLat = (int)((latitude - (float)degreeLat) * 60.0);
|
|
|
|
float secondsLat = (float)((latitude - (float)degreeLat - (float)minutesLat / 60.0) * 60.0 * 60.0);
|
|
|
|
int degreeLon = (int)longitude;
|
|
|
|
int minutesLon = (int)((longitude - (float)degreeLon) * 60.0);
|
|
|
|
float secondsLon = (float)((longitude - (float)degreeLon - (float)minutesLon / 60.0) * 60.0 * 60.0);
|
|
|
|
|
2017-12-12 22:05:51 +01:00
|
|
|
::sprintf(text, "t%d.txt=\"%d%c%d'%.2f\\\" %c %d%c%d'%.2f\\\" %c\"",2*slotNo+7,degreeLat,176U,minutesLat,secondsLat,Lat,degreeLon,176U,minutesLon,secondsLon,Lon);
|
2017-12-10 21:50:47 +01:00
|
|
|
|
|
|
|
if (slotNo == 1U) {
|
|
|
|
sendCommand(text);
|
|
|
|
|
|
|
|
::sprintf(text, "t8.txt=\"%f %f\"", latitude, longitude);
|
|
|
|
sendCommand(text);
|
|
|
|
|
|
|
|
::sprintf(text, "t12.txt=\"%d\"", positionError);
|
|
|
|
sendCommand(text);
|
2017-12-19 21:02:51 +01:00
|
|
|
sendCommandAction(8U,35U);
|
2017-12-10 21:50:47 +01:00
|
|
|
}
|
|
|
|
if (slotNo == 2U) {
|
|
|
|
sendCommand(text);
|
|
|
|
|
|
|
|
::sprintf(text, "t10.txt=\"%f %f\"", latitude, longitude);
|
|
|
|
sendCommand(text);
|
|
|
|
|
|
|
|
::sprintf(text, "t13.txt=\"%d\"", positionError);
|
|
|
|
sendCommand(text);
|
2017-12-19 21:02:51 +01:00
|
|
|
sendCommandAction(10U,35U);
|
2017-12-05 20:50:56 +01:00
|
|
|
}
|
2017-11-13 21:48:47 +01:00
|
|
|
}
|
|
|
|
|
2017-02-12 19:37:00 +01:00
|
|
|
void CNextion::writeDMRBERInt(unsigned int slotNo, float ber)
|
|
|
|
{
|
|
|
|
if (slotNo == 1U) {
|
2017-02-13 09:20:40 +01:00
|
|
|
if (m_berCount1 == 0U) {
|
|
|
|
char text[20U];
|
|
|
|
::sprintf(text, "t6.txt=\"%.1f%%\"", ber);
|
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(6U,38U);
|
2017-02-13 09:20:40 +01:00
|
|
|
m_berCount1 = 1U;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-12 19:37:00 +01:00
|
|
|
m_berAccum1 += ber;
|
|
|
|
m_berCount1++;
|
|
|
|
|
|
|
|
if (m_berCount1 == DMR_BER_COUNT) {
|
|
|
|
char text[20U];
|
|
|
|
::sprintf(text, "t6.txt=\"%.1f%%\"", m_berAccum1 / DMR_BER_COUNT);
|
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(6U,38U);
|
2017-02-12 19:37:00 +01:00
|
|
|
m_berAccum1 = 0U;
|
|
|
|
m_berCount1 = 1U;
|
|
|
|
}
|
|
|
|
} else {
|
2017-02-13 09:20:40 +01:00
|
|
|
if (m_berCount2 == 0U) {
|
|
|
|
char text[20U];
|
|
|
|
::sprintf(text, "t7.txt=\"%.1f%%\"", ber);
|
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(7U,38U);
|
2017-02-13 09:20:40 +01:00
|
|
|
m_berCount2 = 1U;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-12 19:37:00 +01:00
|
|
|
m_berAccum2 += ber;
|
|
|
|
m_berCount2++;
|
|
|
|
|
|
|
|
if (m_berCount2 == DMR_BER_COUNT) {
|
|
|
|
char text[20U];
|
|
|
|
::sprintf(text, "t7.txt=\"%.1f%%\"", m_berAccum2 / DMR_BER_COUNT);
|
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(7U,38U);
|
2017-02-12 19:37:00 +01:00
|
|
|
m_berAccum2 = 0U;
|
|
|
|
m_berCount2 = 1U;
|
|
|
|
}
|
2017-01-05 20:44:52 +01:00
|
|
|
}
|
2016-04-06 20:53:25 +02:00
|
|
|
}
|
|
|
|
|
2016-05-09 19:14:27 +02:00
|
|
|
void CNextion::clearDMRInt(unsigned int slotNo)
|
2016-04-06 20:53:25 +02:00
|
|
|
{
|
|
|
|
if (slotNo == 1U) {
|
|
|
|
sendCommand("t0.txt=\"1 Listening\"");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,31U);
|
2017-11-15 11:47:56 +01:00
|
|
|
|
|
|
|
if (m_screenLayout == 2U) {
|
2017-11-14 19:46:29 +01:00
|
|
|
sendCommand("t0.pco=0");
|
2017-11-13 21:48:47 +01:00
|
|
|
sendCommand("t0.font=4");
|
|
|
|
}
|
2017-11-15 11:47:56 +01:00
|
|
|
|
2016-04-06 20:53:25 +02:00
|
|
|
sendCommand("t1.txt=\"\"");
|
2017-01-05 20:44:52 +01:00
|
|
|
sendCommand("t4.txt=\"\"");
|
2017-02-12 19:37:00 +01:00
|
|
|
sendCommand("t6.txt=\"\"");
|
2017-02-13 09:20:40 +01:00
|
|
|
} else {
|
2016-04-06 20:53:25 +02:00
|
|
|
sendCommand("t2.txt=\"2 Listening\"");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(2U,31U);
|
2017-11-15 11:47:56 +01:00
|
|
|
|
|
|
|
if (m_screenLayout == 2U) {
|
2017-11-14 19:46:29 +01:00
|
|
|
sendCommand("t2.pco=0");
|
2017-11-13 21:48:47 +01:00
|
|
|
sendCommand("t2.font=4");
|
|
|
|
}
|
2017-11-15 11:47:56 +01:00
|
|
|
|
2016-04-06 20:53:25 +02:00
|
|
|
sendCommand("t3.txt=\"\"");
|
2017-01-05 20:44:52 +01:00
|
|
|
sendCommand("t5.txt=\"\"");
|
2017-02-12 19:37:00 +01:00
|
|
|
sendCommand("t7.txt=\"\"");
|
2017-02-13 09:20:40 +01:00
|
|
|
}
|
2016-04-06 20:53:25 +02:00
|
|
|
}
|
|
|
|
|
2016-05-19 20:08:48 +02:00
|
|
|
void CNextion::writeFusionInt(const char* source, const char* dest, const char* type, const char* origin)
|
2016-04-06 20:53:25 +02:00
|
|
|
{
|
|
|
|
assert(source != NULL);
|
|
|
|
assert(dest != NULL);
|
2016-05-16 22:57:32 +02:00
|
|
|
assert(type != NULL);
|
2016-05-19 20:08:48 +02:00
|
|
|
assert(origin != NULL);
|
2016-04-06 20:53:25 +02:00
|
|
|
|
2017-12-10 21:50:47 +01:00
|
|
|
if (m_mode != MODE_YSF) {
|
2016-04-11 13:21:46 +02:00
|
|
|
sendCommand("page YSF");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,4U);
|
|
|
|
}
|
|
|
|
|
2016-04-11 13:21:46 +02:00
|
|
|
|
2016-04-06 20:53:25 +02:00
|
|
|
char text[30U];
|
2016-06-24 09:30:46 +02:00
|
|
|
::sprintf(text, "dim=%u", m_brightness);
|
|
|
|
sendCommand(text);
|
|
|
|
|
2016-05-16 22:57:32 +02:00
|
|
|
::sprintf(text, "t0.txt=\"%s %.10s\"", type, source);
|
2016-04-06 20:53:25 +02:00
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,42U);
|
2016-04-06 20:53:25 +02:00
|
|
|
|
2016-05-21 13:52:56 +02:00
|
|
|
::sprintf(text, "t1.txt=\"%.10s\"", dest);
|
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(1U,43U);
|
2016-05-21 13:52:56 +02:00
|
|
|
if (::strcmp(origin, " ") != 0) {
|
2016-05-23 19:04:17 +02:00
|
|
|
::sprintf(text, "t2.txt=\"at %.10s\"", origin);
|
2016-05-19 20:08:48 +02:00
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(2U,44U);
|
2016-05-19 20:08:48 +02:00
|
|
|
}
|
2016-04-11 13:21:46 +02:00
|
|
|
|
2016-06-01 12:55:24 +02:00
|
|
|
m_clockDisplayTimer.stop();
|
|
|
|
|
2016-04-11 13:21:46 +02:00
|
|
|
m_mode = MODE_YSF;
|
2017-02-12 19:37:00 +01:00
|
|
|
m_rssiAccum1 = 0U;
|
|
|
|
m_berAccum1 = 0.0F;
|
2017-02-13 09:20:40 +01:00
|
|
|
m_rssiCount1 = 0U;
|
|
|
|
m_berCount1 = 0U;
|
2017-01-05 20:44:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CNextion::writeFusionRSSIInt(unsigned char rssi)
|
|
|
|
{
|
2017-02-13 09:20:40 +01:00
|
|
|
if (m_rssiCount1 == 0U) {
|
|
|
|
char text[20U];
|
|
|
|
::sprintf(text, "t3.txt=\"-%udBm\"", rssi);
|
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(3U,45U);
|
2017-02-13 09:20:40 +01:00
|
|
|
m_rssiCount1 = 1U;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-12 19:37:00 +01:00
|
|
|
m_rssiAccum1 += rssi;
|
|
|
|
m_rssiCount1++;
|
|
|
|
|
|
|
|
if (m_rssiCount1 == YSF_RSSI_COUNT) {
|
2017-01-05 20:44:52 +01:00
|
|
|
char text[20U];
|
2017-02-12 19:37:00 +01:00
|
|
|
::sprintf(text, "t3.txt=\"-%udBm\"", m_rssiAccum1 / YSF_RSSI_COUNT);
|
2017-01-05 20:44:52 +01:00
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(3U,45U);
|
2017-02-12 19:37:00 +01:00
|
|
|
m_rssiAccum1 = 0U;
|
|
|
|
m_rssiCount1 = 1U;
|
2017-01-05 20:44:52 +01:00
|
|
|
}
|
2017-02-12 19:37:00 +01:00
|
|
|
}
|
2017-01-05 20:44:52 +01:00
|
|
|
|
2017-02-12 19:37:00 +01:00
|
|
|
void CNextion::writeFusionBERInt(float ber)
|
|
|
|
{
|
2017-02-13 09:20:40 +01:00
|
|
|
if (m_berCount1 == 0U) {
|
|
|
|
char text[20U];
|
|
|
|
::sprintf(text, "t4.txt=\"%.1f%%\"", ber);
|
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(4U,46U);
|
2017-02-13 09:20:40 +01:00
|
|
|
m_berCount1 = 1U;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-12 19:37:00 +01:00
|
|
|
m_berAccum1 += ber;
|
|
|
|
m_berCount1++;
|
|
|
|
|
|
|
|
if (m_berCount1 == YSF_BER_COUNT) {
|
|
|
|
char text[20U];
|
|
|
|
::sprintf(text, "t4.txt=\"%.1f%%\"", m_berAccum1 / float(YSF_BER_COUNT));
|
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(4U,46U);
|
2017-02-12 19:37:00 +01:00
|
|
|
m_berAccum1 = 0.0F;
|
|
|
|
m_berCount1 = 1U;
|
|
|
|
}
|
2016-04-06 20:53:25 +02:00
|
|
|
}
|
|
|
|
|
2016-05-09 19:14:27 +02:00
|
|
|
void CNextion::clearFusionInt()
|
2016-04-06 20:53:25 +02:00
|
|
|
{
|
|
|
|
sendCommand("t0.txt=\"Listening\"");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,41U);
|
2016-04-06 20:53:25 +02:00
|
|
|
sendCommand("t1.txt=\"\"");
|
2016-05-21 13:52:56 +02:00
|
|
|
sendCommand("t2.txt=\"\"");
|
2017-01-05 20:44:52 +01:00
|
|
|
sendCommand("t3.txt=\"\"");
|
2017-02-12 19:37:00 +01:00
|
|
|
sendCommand("t4.txt=\"\"");
|
2016-04-06 20:53:25 +02:00
|
|
|
}
|
|
|
|
|
2016-09-12 21:23:50 +02:00
|
|
|
void CNextion::writeP25Int(const char* source, bool group, unsigned int dest, const char* type)
|
2016-09-12 19:12:32 +02:00
|
|
|
{
|
|
|
|
assert(source != NULL);
|
|
|
|
assert(type != NULL);
|
|
|
|
|
2017-12-10 21:50:47 +01:00
|
|
|
if (m_mode != MODE_P25) {
|
2016-09-12 19:12:32 +02:00
|
|
|
sendCommand("page P25");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,5U);
|
|
|
|
}
|
2016-09-12 19:12:32 +02:00
|
|
|
|
|
|
|
char text[30U];
|
|
|
|
::sprintf(text, "dim=%u", m_brightness);
|
|
|
|
sendCommand(text);
|
|
|
|
|
|
|
|
::sprintf(text, "t0.txt=\"%s %.10s\"", type, source);
|
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,52U);
|
2016-09-12 19:12:32 +02:00
|
|
|
|
2016-09-12 21:23:50 +02:00
|
|
|
::sprintf(text, "t1.txt=\"%s%u\"", group ? "TG" : "", dest);
|
2016-09-12 19:12:32 +02:00
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(1U,53U);
|
2016-09-12 19:12:32 +02:00
|
|
|
|
|
|
|
m_clockDisplayTimer.stop();
|
|
|
|
|
|
|
|
m_mode = MODE_P25;
|
2017-02-12 19:37:00 +01:00
|
|
|
m_rssiAccum1 = 0U;
|
|
|
|
m_berAccum1 = 0.0F;
|
2017-02-13 09:20:40 +01:00
|
|
|
m_rssiCount1 = 0U;
|
|
|
|
m_berCount1 = 0U;
|
2017-01-05 20:44:52 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void CNextion::writeP25RSSIInt(unsigned char rssi)
|
|
|
|
{
|
2017-02-13 09:20:40 +01:00
|
|
|
if (m_rssiCount1 == 0U) {
|
|
|
|
char text[20U];
|
|
|
|
::sprintf(text, "t2.txt=\"-%udBm\"", rssi);
|
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(2U,54U);
|
2017-02-13 09:20:40 +01:00
|
|
|
m_rssiCount1 = 1U;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-12 19:37:00 +01:00
|
|
|
m_rssiAccum1 += rssi;
|
|
|
|
m_rssiCount1++;
|
|
|
|
|
|
|
|
if (m_rssiCount1 == P25_RSSI_COUNT) {
|
2017-01-05 20:44:52 +01:00
|
|
|
char text[20U];
|
2017-02-12 19:37:00 +01:00
|
|
|
::sprintf(text, "t2.txt=\"-%udBm\"", m_rssiAccum1 / P25_RSSI_COUNT);
|
2017-01-05 20:44:52 +01:00
|
|
|
sendCommand(text);
|
2017-12-19 21:02:51 +01:00
|
|
|
sendCommandAction(2U,54U);
|
2017-02-12 19:37:00 +01:00
|
|
|
m_rssiAccum1 = 0U;
|
|
|
|
m_rssiCount1 = 1U;
|
2017-01-05 20:44:52 +01:00
|
|
|
}
|
2017-02-12 19:37:00 +01:00
|
|
|
}
|
2017-01-05 20:44:52 +01:00
|
|
|
|
2017-02-12 19:37:00 +01:00
|
|
|
void CNextion::writeP25BERInt(float ber)
|
|
|
|
{
|
2017-02-13 09:20:40 +01:00
|
|
|
if (m_berCount1 == 0U) {
|
|
|
|
char text[20U];
|
|
|
|
::sprintf(text, "t3.txt=\"%.1f%%\"", ber);
|
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(3U,55U);
|
2017-02-13 09:20:40 +01:00
|
|
|
m_berCount1 = 1U;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-02-12 19:37:00 +01:00
|
|
|
m_berAccum1 += ber;
|
|
|
|
m_berCount1++;
|
|
|
|
|
|
|
|
if (m_berCount1 == P25_BER_COUNT) {
|
|
|
|
char text[20U];
|
|
|
|
::sprintf(text, "t3.txt=\"%.1f%%\"", m_berAccum1 / float(P25_BER_COUNT));
|
|
|
|
sendCommand(text);
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(3U,55U);
|
2017-02-12 19:37:00 +01:00
|
|
|
m_berAccum1 = 0.0F;
|
|
|
|
m_berCount1 = 1U;
|
|
|
|
}
|
2016-09-12 19:12:32 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CNextion::clearP25Int()
|
|
|
|
{
|
|
|
|
sendCommand("t0.txt=\"Listening\"");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,51U);
|
2016-09-12 19:12:32 +02:00
|
|
|
sendCommand("t1.txt=\"\"");
|
|
|
|
sendCommand("t2.txt=\"\"");
|
2017-02-12 19:37:00 +01:00
|
|
|
sendCommand("t3.txt=\"\"");
|
2016-09-12 19:12:32 +02:00
|
|
|
}
|
|
|
|
|
2016-09-15 10:58:55 +02:00
|
|
|
void CNextion::writeCWInt()
|
2016-09-15 10:44:21 +02:00
|
|
|
{
|
2016-09-15 16:28:56 +02:00
|
|
|
sendCommand("t1.txt=\"Sending CW Ident\"");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(1U,12U);
|
2016-09-15 16:57:10 +02:00
|
|
|
m_clockDisplayTimer.start();
|
2016-09-15 15:17:51 +02:00
|
|
|
|
|
|
|
m_mode = MODE_CW;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CNextion::clearCWInt()
|
|
|
|
{
|
2016-09-15 16:27:06 +02:00
|
|
|
sendCommand("t1.txt=\"MMDVM IDLE\"");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(1U,11U);
|
2016-09-15 10:44:21 +02:00
|
|
|
}
|
|
|
|
|
2016-06-01 12:55:24 +02:00
|
|
|
void CNextion::clockInt(unsigned int ms)
|
|
|
|
{
|
|
|
|
// Update the clock display in IDLE mode every 400ms
|
|
|
|
m_clockDisplayTimer.clock(ms);
|
2016-09-15 16:57:10 +02:00
|
|
|
if (m_displayClock && (m_mode == MODE_IDLE || m_mode == MODE_CW) && m_clockDisplayTimer.isRunning() && m_clockDisplayTimer.hasExpired()) {
|
2016-06-01 12:55:24 +02:00
|
|
|
time_t currentTime;
|
|
|
|
struct tm *Time;
|
|
|
|
::time(¤tTime); // Get the current time
|
|
|
|
|
|
|
|
if (m_utc)
|
|
|
|
Time = ::gmtime(¤tTime);
|
|
|
|
else
|
|
|
|
Time = ::localtime(¤tTime);
|
|
|
|
|
2016-07-03 01:14:31 +02:00
|
|
|
setlocale(LC_TIME,"");
|
2016-06-01 12:55:24 +02:00
|
|
|
char text[50U];
|
2016-06-24 17:08:28 +02:00
|
|
|
strftime(text, 50, "t2.txt=\"%x %X\"", Time);
|
2016-06-01 12:55:24 +02:00
|
|
|
sendCommand(text);
|
|
|
|
|
|
|
|
m_clockDisplayTimer.start(); // restart the clock display timer
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-04-06 20:53:25 +02:00
|
|
|
void CNextion::close()
|
|
|
|
{
|
2017-11-13 21:48:47 +01:00
|
|
|
sendCommand("page MMDVM");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(0,1U);
|
2017-11-13 21:48:47 +01:00
|
|
|
sendCommand("t1.txt=\"MMDVM STOPPED\"");
|
2017-12-10 21:50:47 +01:00
|
|
|
sendCommandAction(1U,19U);
|
2016-10-06 19:38:16 +02:00
|
|
|
m_serial->close();
|
|
|
|
delete m_serial;
|
2016-04-06 20:53:25 +02:00
|
|
|
}
|
|
|
|
|
2017-12-05 20:50:56 +01:00
|
|
|
void CNextion::sendCommandAction(unsigned int field, unsigned int status)
|
|
|
|
{
|
|
|
|
if (m_screenLayout<3U) return;
|
|
|
|
|
|
|
|
char text[30U];
|
|
|
|
|
|
|
|
::sprintf(text, "MMDVM.cmd.val=%d", field);
|
|
|
|
sendCommand(text);
|
|
|
|
::sprintf(text, "MMDVM.status.val=%d", status);
|
|
|
|
sendCommand(text);
|
|
|
|
sendCommand("click S0,1");
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-06 20:53:25 +02:00
|
|
|
void CNextion::sendCommand(const char* command)
|
|
|
|
{
|
|
|
|
assert(command != NULL);
|
|
|
|
|
2016-10-06 19:38:16 +02:00
|
|
|
m_serial->write((unsigned char*)command, ::strlen(command));
|
|
|
|
m_serial->write((unsigned char*)"\xFF\xFF\xFF", 3U);
|
2016-04-06 20:53:25 +02:00
|
|
|
}
|