2016-01-14 18:45:04 +00:00
|
|
|
/*
|
2018-01-17 19:04:00 +00:00
|
|
|
* Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX
|
2016-01-14 18:45:04 +00: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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "Display.h"
|
2016-05-09 17:14:27 +00:00
|
|
|
#include "Defines.h"
|
2017-11-13 20:48:47 +00:00
|
|
|
#include "Log.h"
|
2016-01-14 18:45:04 +00:00
|
|
|
|
2016-05-09 17:14:27 +00:00
|
|
|
#include <cstdio>
|
|
|
|
#include <cassert>
|
|
|
|
#include <cstring>
|
|
|
|
|
|
|
|
CDisplay::CDisplay() :
|
2017-11-13 20:48:47 +00:00
|
|
|
m_timer1(3000U, 3U),
|
|
|
|
m_timer2(3000U, 3U),
|
2016-05-09 17:14:27 +00:00
|
|
|
m_mode1(MODE_IDLE),
|
|
|
|
m_mode2(MODE_IDLE)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CDisplay::~CDisplay()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDisplay::setIdle()
|
|
|
|
{
|
|
|
|
m_timer1.stop();
|
|
|
|
m_timer2.stop();
|
|
|
|
|
|
|
|
m_mode1 = MODE_IDLE;
|
|
|
|
m_mode2 = MODE_IDLE;
|
|
|
|
|
|
|
|
setIdleInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDisplay::setLockout()
|
|
|
|
{
|
|
|
|
m_timer1.stop();
|
|
|
|
m_timer2.stop();
|
|
|
|
|
|
|
|
m_mode1 = MODE_IDLE;
|
|
|
|
m_mode2 = MODE_IDLE;
|
|
|
|
|
|
|
|
setLockoutInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDisplay::setError(const char* text)
|
|
|
|
{
|
|
|
|
assert(text != NULL);
|
|
|
|
|
|
|
|
m_timer1.stop();
|
|
|
|
m_timer2.stop();
|
|
|
|
|
|
|
|
m_mode1 = MODE_IDLE;
|
|
|
|
m_mode2 = MODE_IDLE;
|
|
|
|
|
|
|
|
setErrorInt(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDisplay::writeDStar(const char* my1, const char* my2, const char* your, const char* type, const char* reflector)
|
|
|
|
{
|
|
|
|
assert(my1 != NULL);
|
|
|
|
assert(my2 != NULL);
|
|
|
|
assert(your != NULL);
|
|
|
|
assert(type != NULL);
|
|
|
|
assert(reflector != NULL);
|
|
|
|
|
|
|
|
m_timer1.start();
|
2016-05-10 12:28:00 +00:00
|
|
|
m_mode1 = MODE_IDLE;
|
2016-05-09 17:14:27 +00:00
|
|
|
|
|
|
|
writeDStarInt(my1, my2, your, type, reflector);
|
|
|
|
}
|
|
|
|
|
2017-01-05 19:44:52 +00:00
|
|
|
void CDisplay::writeDStarRSSI(unsigned char rssi)
|
|
|
|
{
|
|
|
|
if (rssi != 0U)
|
|
|
|
writeDStarRSSIInt(rssi);
|
|
|
|
}
|
|
|
|
|
2017-02-12 18:37:00 +00:00
|
|
|
void CDisplay::writeDStarBER(float ber)
|
|
|
|
{
|
2017-02-13 08:54:25 +00:00
|
|
|
writeDStarBERInt(ber);
|
2017-02-12 18:37:00 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 17:14:27 +00:00
|
|
|
void CDisplay::clearDStar()
|
2016-01-14 18:45:04 +00:00
|
|
|
{
|
2016-05-09 17:14:27 +00:00
|
|
|
if (m_timer1.hasExpired()) {
|
|
|
|
clearDStarInt();
|
|
|
|
m_timer1.stop();
|
2016-05-10 12:28:00 +00:00
|
|
|
m_mode1 = MODE_IDLE;
|
2016-05-09 17:14:27 +00:00
|
|
|
} else {
|
|
|
|
m_mode1 = MODE_DSTAR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDisplay::writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type)
|
|
|
|
{
|
|
|
|
assert(type != NULL);
|
|
|
|
|
2016-05-10 12:28:00 +00:00
|
|
|
if (slotNo == 1U) {
|
2016-05-09 17:14:27 +00:00
|
|
|
m_timer1.start();
|
2016-05-10 12:28:00 +00:00
|
|
|
m_mode1 = MODE_IDLE;
|
|
|
|
} else {
|
2016-05-09 17:14:27 +00:00
|
|
|
m_timer2.start();
|
2016-05-10 12:28:00 +00:00
|
|
|
m_mode2 = MODE_IDLE;
|
|
|
|
}
|
2016-05-09 17:14:27 +00:00
|
|
|
writeDMRInt(slotNo, src, group, dst, type);
|
|
|
|
}
|
|
|
|
|
2017-01-05 19:44:52 +00:00
|
|
|
void CDisplay::writeDMRRSSI(unsigned int slotNo, unsigned char rssi)
|
|
|
|
{
|
|
|
|
if (rssi != 0U)
|
|
|
|
writeDMRRSSIInt(slotNo, rssi);
|
|
|
|
}
|
|
|
|
|
2017-11-13 20:48:47 +00:00
|
|
|
void CDisplay::writeDMRTA(unsigned int slotNo, unsigned char* talkerAlias, const char* type)
|
|
|
|
{
|
|
|
|
char TA[32U];
|
|
|
|
unsigned char *b;
|
|
|
|
unsigned char c;
|
|
|
|
int j;
|
|
|
|
unsigned int i,t1,t2, TAsize, TAformat;
|
|
|
|
|
|
|
|
if (strcmp(type," ")==0) { writeDMRTAInt(slotNo, (unsigned char*)TA, type); return; }
|
|
|
|
|
|
|
|
TAformat=(talkerAlias[0]>>6U) & 0x03U;
|
|
|
|
TAsize = (talkerAlias[0]>>1U) & 0x1FU;
|
|
|
|
::strcpy(TA,"(could not decode)");
|
|
|
|
switch (TAformat) {
|
|
|
|
case 0U: // 7 bit
|
|
|
|
::memset (&TA,0,32U);
|
|
|
|
b=&talkerAlias[0];
|
|
|
|
t1=0; t2=0; c=0;
|
|
|
|
for (i=0;(i<32U)&&(t2<TAsize);i++) {
|
|
|
|
for (j=7U;j>=0;j--) {
|
|
|
|
c = (c<<1U) | (b[i] >> j);
|
|
|
|
if (++t1==7U) { if (i>0) {TA[t2++]=c & 0x7FU; } t1=0; c=0; }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 1U: // ISO 8 bit
|
|
|
|
case 2U: // UTF8
|
|
|
|
::strcpy(TA,(char*)talkerAlias+1U);
|
|
|
|
break;
|
|
|
|
case 3U: // UTF16 poor man's conversion
|
|
|
|
t2=0;
|
|
|
|
::memset (&TA,0,32U);
|
|
|
|
for(i=0;(i<15)&&(t2<TAsize);i++) {
|
|
|
|
if (talkerAlias[2U*i+1U]==0)
|
|
|
|
TA[t2++]=talkerAlias[2U*i+2U]; else TA[t2++]='?';
|
|
|
|
}
|
|
|
|
TA[TAsize]=0;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
LogMessage("DMR Talker Alias (Data Format %u, Received %u/%u char): '%s'", TAformat, ::strlen(TA), TAsize, TA);
|
|
|
|
if (::strlen(TA)>TAsize) { if (strlen(TA)<29U) strcat(TA," ?"); else strcpy(TA+28U," ?"); }
|
|
|
|
if (strlen((char*)TA)>=4U) writeDMRTAInt(slotNo, (unsigned char*)TA, type);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-02-12 18:37:00 +00:00
|
|
|
void CDisplay::writeDMRBER(unsigned int slotNo, float ber)
|
|
|
|
{
|
2017-02-13 08:54:25 +00:00
|
|
|
writeDMRBERInt(slotNo, ber);
|
2017-02-12 18:37:00 +00:00
|
|
|
}
|
2016-05-09 17:14:27 +00:00
|
|
|
void CDisplay::clearDMR(unsigned int slotNo)
|
|
|
|
{
|
|
|
|
if (slotNo == 1U) {
|
|
|
|
if (m_timer1.hasExpired()) {
|
|
|
|
clearDMRInt(slotNo);
|
|
|
|
m_timer1.stop();
|
2016-05-10 12:28:00 +00:00
|
|
|
m_mode1 = MODE_IDLE;
|
2016-05-09 17:14:27 +00:00
|
|
|
} else {
|
|
|
|
m_mode1 = MODE_DMR;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (m_timer2.hasExpired()) {
|
|
|
|
clearDMRInt(slotNo);
|
|
|
|
m_timer2.stop();
|
2016-05-10 12:28:00 +00:00
|
|
|
m_mode2 = MODE_IDLE;
|
2016-05-09 17:14:27 +00:00
|
|
|
} else {
|
|
|
|
m_mode2 = MODE_DMR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-19 18:08:48 +00:00
|
|
|
void CDisplay::writeFusion(const char* source, const char* dest, const char* type, const char* origin)
|
2016-05-09 17:14:27 +00:00
|
|
|
{
|
|
|
|
assert(source != NULL);
|
|
|
|
assert(dest != NULL);
|
2016-05-16 20:57:32 +00:00
|
|
|
assert(type != NULL);
|
2016-05-19 18:08:48 +00:00
|
|
|
assert(origin != NULL);
|
2016-05-09 17:14:27 +00:00
|
|
|
|
|
|
|
m_timer1.start();
|
2016-05-10 12:28:00 +00:00
|
|
|
m_mode1 = MODE_IDLE;
|
2016-05-09 17:14:27 +00:00
|
|
|
|
2016-05-19 18:08:48 +00:00
|
|
|
writeFusionInt(source, dest, type, origin);
|
2016-05-09 17:14:27 +00:00
|
|
|
}
|
|
|
|
|
2017-01-05 19:44:52 +00:00
|
|
|
void CDisplay::writeFusionRSSI(unsigned char rssi)
|
|
|
|
{
|
|
|
|
if (rssi != 0U)
|
|
|
|
writeFusionRSSIInt(rssi);
|
|
|
|
}
|
|
|
|
|
2017-02-12 18:37:00 +00:00
|
|
|
void CDisplay::writeFusionBER(float ber)
|
|
|
|
{
|
2017-02-13 08:54:25 +00:00
|
|
|
writeFusionBERInt(ber);
|
2017-02-12 18:37:00 +00:00
|
|
|
}
|
|
|
|
|
2016-05-09 17:14:27 +00:00
|
|
|
void CDisplay::clearFusion()
|
|
|
|
{
|
|
|
|
if (m_timer1.hasExpired()) {
|
|
|
|
clearFusionInt();
|
|
|
|
m_timer1.stop();
|
2016-05-10 12:28:00 +00:00
|
|
|
m_mode1 = MODE_IDLE;
|
2016-05-09 17:14:27 +00:00
|
|
|
} else {
|
|
|
|
m_mode1 = MODE_YSF;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-12 19:23:50 +00:00
|
|
|
void CDisplay::writeP25(const char* source, bool group, unsigned int dest, const char* type)
|
2016-09-12 17:12:32 +00:00
|
|
|
{
|
|
|
|
assert(source != NULL);
|
|
|
|
assert(type != NULL);
|
|
|
|
|
|
|
|
m_timer1.start();
|
|
|
|
m_mode1 = MODE_IDLE;
|
|
|
|
|
|
|
|
writeP25Int(source, group, dest, type);
|
|
|
|
}
|
|
|
|
|
2017-01-05 19:44:52 +00:00
|
|
|
void CDisplay::writeP25RSSI(unsigned char rssi)
|
|
|
|
{
|
|
|
|
if (rssi != 0U)
|
|
|
|
writeP25RSSIInt(rssi);
|
|
|
|
}
|
|
|
|
|
2017-02-12 18:37:00 +00:00
|
|
|
void CDisplay::writeP25BER(float ber)
|
|
|
|
{
|
2017-02-13 08:54:25 +00:00
|
|
|
writeP25BERInt(ber);
|
2017-02-12 18:37:00 +00:00
|
|
|
}
|
|
|
|
|
2016-09-12 17:12:32 +00:00
|
|
|
void CDisplay::clearP25()
|
|
|
|
{
|
|
|
|
if (m_timer1.hasExpired()) {
|
|
|
|
clearP25Int();
|
|
|
|
m_timer1.stop();
|
|
|
|
m_mode1 = MODE_IDLE;
|
|
|
|
} else {
|
|
|
|
m_mode1 = MODE_P25;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-17 19:04:00 +00:00
|
|
|
void CDisplay::writeNXDN(const char* source, bool group, unsigned int dest, const char* type)
|
|
|
|
{
|
|
|
|
assert(source != NULL);
|
|
|
|
assert(type != NULL);
|
|
|
|
|
|
|
|
m_timer1.start();
|
|
|
|
m_mode1 = MODE_IDLE;
|
|
|
|
|
|
|
|
writeNXDNInt(source, group, dest, type);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDisplay::writeNXDNRSSI(unsigned char rssi)
|
|
|
|
{
|
|
|
|
if (rssi != 0U)
|
|
|
|
writeNXDNRSSIInt(rssi);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDisplay::writeNXDNBER(float ber)
|
|
|
|
{
|
|
|
|
writeNXDNBERInt(ber);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDisplay::clearNXDN()
|
|
|
|
{
|
|
|
|
if (m_timer1.hasExpired()) {
|
|
|
|
clearNXDNInt();
|
|
|
|
m_timer1.stop();
|
|
|
|
m_mode1 = MODE_IDLE;
|
|
|
|
} else {
|
|
|
|
m_mode1 = MODE_NXDN;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-11 20:30:49 +00:00
|
|
|
void CDisplay::writePOCSAG(uint32_t ric, const std::string& message)
|
|
|
|
{
|
|
|
|
m_timer1.start();
|
|
|
|
m_mode1 = MODE_POCSAG;
|
|
|
|
|
|
|
|
writePOCSAGInt(ric, message);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDisplay::clearPOCSAG()
|
|
|
|
{
|
|
|
|
if (m_timer1.hasExpired()) {
|
|
|
|
clearPOCSAGInt();
|
|
|
|
m_timer1.stop();
|
|
|
|
m_mode1 = MODE_IDLE;
|
|
|
|
} else {
|
|
|
|
m_mode1 = MODE_POCSAG;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-09-15 09:50:35 +00:00
|
|
|
void CDisplay::writeCW()
|
|
|
|
{
|
2016-09-15 13:17:51 +00:00
|
|
|
m_timer1.start();
|
|
|
|
m_mode1 = MODE_CW;
|
|
|
|
|
2016-09-15 09:50:35 +00:00
|
|
|
writeCWInt();
|
|
|
|
}
|
|
|
|
|
2016-05-09 17:14:27 +00:00
|
|
|
void CDisplay::clock(unsigned int ms)
|
|
|
|
{
|
|
|
|
m_timer1.clock(ms);
|
|
|
|
if (m_timer1.isRunning() && m_timer1.hasExpired()) {
|
|
|
|
switch (m_mode1) {
|
|
|
|
case MODE_DSTAR:
|
|
|
|
clearDStarInt();
|
2016-05-10 12:28:00 +00:00
|
|
|
m_mode1 = MODE_IDLE;
|
|
|
|
m_timer1.stop();
|
2016-05-09 17:14:27 +00:00
|
|
|
break;
|
|
|
|
case MODE_DMR:
|
|
|
|
clearDMRInt(1U);
|
2016-05-10 12:28:00 +00:00
|
|
|
m_mode1 = MODE_IDLE;
|
|
|
|
m_timer1.stop();
|
2016-05-09 17:14:27 +00:00
|
|
|
break;
|
|
|
|
case MODE_YSF:
|
|
|
|
clearFusionInt();
|
2016-05-10 12:28:00 +00:00
|
|
|
m_mode1 = MODE_IDLE;
|
|
|
|
m_timer1.stop();
|
|
|
|
break;
|
2016-09-12 17:12:32 +00:00
|
|
|
case MODE_P25:
|
|
|
|
clearP25Int();
|
|
|
|
m_mode1 = MODE_IDLE;
|
|
|
|
m_timer1.stop();
|
|
|
|
break;
|
2018-01-17 19:04:00 +00:00
|
|
|
case MODE_NXDN:
|
|
|
|
clearNXDNInt();
|
|
|
|
m_mode1 = MODE_IDLE;
|
|
|
|
m_timer1.stop();
|
|
|
|
break;
|
2018-06-11 20:30:49 +00:00
|
|
|
case MODE_POCSAG:
|
|
|
|
clearPOCSAGInt();
|
|
|
|
m_mode1 = MODE_IDLE;
|
|
|
|
m_timer1.stop();
|
|
|
|
break;
|
2016-09-15 13:17:51 +00:00
|
|
|
case MODE_CW:
|
|
|
|
clearCWInt();
|
|
|
|
m_mode1 = MODE_IDLE;
|
|
|
|
m_timer1.stop();
|
|
|
|
break;
|
2016-05-10 12:28:00 +00:00
|
|
|
default:
|
2016-05-09 17:14:27 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-10 12:28:00 +00:00
|
|
|
// Timer/mode 2 are only used for DMR
|
2016-05-09 17:14:27 +00:00
|
|
|
m_timer2.clock(ms);
|
|
|
|
if (m_timer2.isRunning() && m_timer2.hasExpired()) {
|
2016-05-10 12:28:00 +00:00
|
|
|
if (m_mode2 == MODE_DMR) {
|
2016-05-09 17:14:27 +00:00
|
|
|
clearDMRInt(2U);
|
2016-05-10 12:28:00 +00:00
|
|
|
m_mode2 = MODE_IDLE;
|
|
|
|
m_timer2.stop();
|
2016-05-09 17:14:27 +00:00
|
|
|
}
|
|
|
|
}
|
2016-05-21 11:28:09 +00:00
|
|
|
|
|
|
|
clockInt(ms);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDisplay::clockInt(unsigned int ms)
|
|
|
|
{
|
2016-01-14 18:45:04 +00:00
|
|
|
}
|
2017-01-05 19:44:52 +00:00
|
|
|
|
|
|
|
void CDisplay::writeDStarRSSIInt(unsigned char rssi)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-02-12 18:37:00 +00:00
|
|
|
void CDisplay::writeDStarBERInt(float ber)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-01-05 19:44:52 +00:00
|
|
|
void CDisplay::writeDMRRSSIInt(unsigned int slotNo, unsigned char rssi)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-11-13 20:48:47 +00:00
|
|
|
void CDisplay::writeDMRTAInt(unsigned int slotNo, unsigned char* talkerAlias, const char* type)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-02-12 18:37:00 +00:00
|
|
|
void CDisplay::writeDMRBERInt(unsigned int slotNo, float ber)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-01-05 19:44:52 +00:00
|
|
|
void CDisplay::writeFusionRSSIInt(unsigned char rssi)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-02-12 18:37:00 +00:00
|
|
|
void CDisplay::writeFusionBERInt(float ber)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2017-01-05 19:44:52 +00:00
|
|
|
void CDisplay::writeP25RSSIInt(unsigned char rssi)
|
|
|
|
{
|
|
|
|
}
|
2017-02-12 18:37:00 +00:00
|
|
|
|
|
|
|
void CDisplay::writeP25BERInt(float ber)
|
|
|
|
{
|
|
|
|
}
|
2018-01-17 19:04:00 +00:00
|
|
|
|
|
|
|
void CDisplay::writeNXDNRSSIInt(unsigned char rssi)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void CDisplay::writeNXDNBERInt(float ber)
|
|
|
|
{
|
|
|
|
}
|