Skip to content

Commit

Permalink
Add a display hang time so quick transmissions aren't missed.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed May 9, 2016
1 parent 617a6cb commit bd5946c
Show file tree
Hide file tree
Showing 20 changed files with 301 additions and 112 deletions.
2 changes: 1 addition & 1 deletion DMRControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include <cassert>
#include <algorithm>

CDMRControl::CDMRControl(unsigned int id, unsigned int colorCode, bool selfOnly, const std::vector<unsigned int>& prefixes, const std::vector<unsigned int>& blackList, unsigned int timeout, CModem* modem, CDMRIPSC* network, IDisplay* display, bool duplex, const std::string& lookupFile) :
CDMRControl::CDMRControl(unsigned int id, unsigned int colorCode, bool selfOnly, const std::vector<unsigned int>& prefixes, const std::vector<unsigned int>& blackList, unsigned int timeout, CModem* modem, CDMRIPSC* network, CDisplay* display, bool duplex, const std::string& lookupFile) :
m_id(id),
m_colorCode(colorCode),
m_selfOnly(selfOnly),
Expand Down
2 changes: 1 addition & 1 deletion DMRControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

class CDMRControl {
public:
CDMRControl(unsigned int id, unsigned int colorCode, bool selfOnly, const std::vector<unsigned int>& prefixes, const std::vector<unsigned int>& blackList, unsigned int timeout, CModem* modem, CDMRIPSC* network, IDisplay* display, bool duplex, const std::string& lookupFile);
CDMRControl(unsigned int id, unsigned int colorCode, bool selfOnly, const std::vector<unsigned int>& prefixes, const std::vector<unsigned int>& blackList, unsigned int timeout, CModem* modem, CDMRIPSC* network, CDisplay* display, bool duplex, const std::string& lookupFile);
~CDMRControl();

bool processWakeup(const unsigned char* data);
Expand Down
4 changes: 2 additions & 2 deletions DMRSlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ std::vector<unsigned int> CDMRSlot::m_prefixes;
std::vector<unsigned int> CDMRSlot::m_blackList;
CModem* CDMRSlot::m_modem = NULL;
CDMRIPSC* CDMRSlot::m_network = NULL;
IDisplay* CDMRSlot::m_display = NULL;
CDisplay* CDMRSlot::m_display = NULL;
bool CDMRSlot::m_duplex = true;
CDMRLookup* CDMRSlot::m_lookup = NULL;

Expand Down Expand Up @@ -1263,7 +1263,7 @@ void CDMRSlot::writeQueueNet(const unsigned char *data)
m_queue.addData(data, len);
}

void CDMRSlot::init(unsigned int id, unsigned int colorCode, bool selfOnly, const std::vector<unsigned int>& prefixes, const std::vector<unsigned int>& blackList, CModem* modem, CDMRIPSC* network, IDisplay* display, bool duplex, CDMRLookup* lookup)
void CDMRSlot::init(unsigned int id, unsigned int colorCode, bool selfOnly, const std::vector<unsigned int>& prefixes, const std::vector<unsigned int>& blackList, CModem* modem, CDMRIPSC* network, CDisplay* display, bool duplex, CDMRLookup* lookup)
{
assert(id != 0U);
assert(modem != NULL);
Expand Down
4 changes: 2 additions & 2 deletions DMRSlot.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class CDMRSlot {

void clock();

static void init(unsigned int id, unsigned int colorCode, bool selfOnly, const std::vector<unsigned int>& prefixes, const std::vector<unsigned int>& blackList, CModem* modem, CDMRIPSC* network, IDisplay* display, bool duplex, CDMRLookup* lookup);
static void init(unsigned int id, unsigned int colorCode, bool selfOnly, const std::vector<unsigned int>& prefixes, const std::vector<unsigned int>& blackList, CModem* modem, CDMRIPSC* network, CDisplay* display, bool duplex, CDMRLookup* lookup);

private:
unsigned int m_slotNo;
Expand Down Expand Up @@ -92,7 +92,7 @@ class CDMRSlot {
static std::vector<unsigned int> m_blackList;
static CModem* m_modem;
static CDMRIPSC* m_network;
static IDisplay* m_display;
static CDisplay* m_display;
static bool m_duplex;
static CDMRLookup* m_lookup;

Expand Down
2 changes: 1 addition & 1 deletion DStarControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ bool CallsignCompare(const std::string& arg, const unsigned char* my)

// #define DUMP_DSTAR

CDStarControl::CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, const std::vector<std::string>& blackList, CDStarNetwork* network, IDisplay* display, unsigned int timeout, bool duplex) :
CDStarControl::CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, const std::vector<std::string>& blackList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex) :
m_callsign(NULL),
m_gateway(NULL),
m_selfOnly(selfOnly),
Expand Down
4 changes: 2 additions & 2 deletions DStarControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

class CDStarControl {
public:
CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, const std::vector<std::string>& blackList, CDStarNetwork* network, IDisplay* display, unsigned int timeout, bool duplex);
CDStarControl(const std::string& callsign, const std::string& module, bool selfOnly, const std::vector<std::string>& blackList, CDStarNetwork* network, CDisplay* display, unsigned int timeout, bool duplex);
~CDStarControl();

bool writeModem(unsigned char* data);
Expand All @@ -51,7 +51,7 @@ class CDStarControl {
bool m_selfOnly;
std::vector<std::string> m_blackList;
CDStarNetwork* m_network;
IDisplay* m_display;
CDisplay* m_display;
bool m_duplex;
CRingBuffer<unsigned char> m_queue;
CDStarHeader m_rfHeader;
Expand Down
163 changes: 162 additions & 1 deletion Display.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,168 @@
*/

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

IDisplay::~IDisplay()
#include <cstdio>
#include <cassert>
#include <cstring>

CDisplay::CDisplay() :
m_timer1(1000U, 3U),
m_timer2(1000U, 3U),
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();

writeDStarInt(my1, my2, your, type, reflector);
}

void CDisplay::clearDStar()
{
if (m_timer1.hasExpired()) {
clearDStarInt();
m_timer1.stop();
} 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);

if (slotNo == 1U)
m_timer1.start();
else
m_timer2.start();

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

void CDisplay::clearDMR(unsigned int slotNo)
{
if (slotNo == 1U) {
if (m_timer1.hasExpired()) {
clearDMRInt(slotNo);
m_timer1.stop();
} else {
m_mode1 = MODE_DMR;
}
} else {
if (m_timer2.hasExpired()) {
clearDMRInt(slotNo);
m_timer2.stop();
} else {
m_mode2 = MODE_DMR;
}
}
}

void CDisplay::writeFusion(const char* source, const char* dest)
{
assert(source != NULL);
assert(dest != NULL);

m_timer1.start();

writeFusionInt(source, dest);
}

void CDisplay::clearFusion()
{
if (m_timer1.hasExpired()) {
clearFusionInt();
m_timer1.stop();
} else {
m_mode1 = MODE_YSF;
}
}

void CDisplay::clock(unsigned int ms)
{
m_timer1.clock(ms);
if (m_timer1.isRunning() && m_timer1.hasExpired()) {
switch (m_mode1) {
case MODE_DSTAR:
clearDStarInt();
break;
case MODE_DMR:
clearDMRInt(1U);
break;
case MODE_YSF:
clearFusionInt();
break;
}

m_mode1 = MODE_IDLE;
m_timer1.stop();
}

m_timer2.clock(ms);
if (m_timer2.isRunning() && m_timer2.hasExpired()) {
switch (m_mode2) {
case MODE_DSTAR:
clearDStarInt();
break;
case MODE_DMR:
clearDMRInt(2U);
break;
case MODE_YSF:
clearFusionInt();
break;
}

m_mode2 = MODE_IDLE;
m_timer2.stop();
}
}
48 changes: 35 additions & 13 deletions Display.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,54 @@
#if !defined(DISPLAY_H)
#define DISPLAY_H

#include "Timer.h"

#include <string>

class IDisplay
class CDisplay
{
public:
virtual ~IDisplay() = 0;
CDisplay();
virtual ~CDisplay() = 0;

virtual bool open() = 0;

void setIdle();
void setLockout();
void setError(const char* text);

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

void writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type);
void clearDMR(unsigned int slotNo);

virtual bool open() = 0;
void writeFusion(const char* source, const char* dest);
void clearFusion();

virtual void setIdle() = 0;
virtual void close() = 0;

virtual void setLockout() = 0;
virtual void setError(const char* text) = 0;
void clock(unsigned int ms);

virtual void writeDStar(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) = 0;
virtual void clearDStar() = 0;
protected:
virtual void setIdleInt() = 0;
virtual void setLockoutInt() = 0;
virtual void setErrorInt(const char* text) = 0;

virtual void writeDMR(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) = 0;
virtual void clearDMR(unsigned int slotNo) = 0;
virtual void writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector) = 0;
virtual void clearDStarInt() = 0;

virtual void writeFusion(const char* source, const char* dest) = 0;
virtual void clearFusion() = 0;
virtual void writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type) = 0;
virtual void clearDMRInt(unsigned int slotNo) = 0;

virtual void close() = 0;
virtual void writeFusionInt(const char* source, const char* dest) = 0;
virtual void clearFusionInt() = 0;

private:
CTimer m_timer1;
CTimer m_timer2;
unsigned char m_mode1;
unsigned char m_mode2;
};

#endif
Loading

0 comments on commit bd5946c

Please sign in to comment.