Add an error display.

This commit is contained in:
Jonathan Naylor 2016-03-21 22:47:58 +00:00
parent a3c25766c0
commit b19c46ff2c
11 changed files with 74 additions and 3 deletions

View file

@ -24,6 +24,7 @@ const unsigned char MODE_DSTAR = 1U;
const unsigned char MODE_DMR = 2U; const unsigned char MODE_DMR = 2U;
const unsigned char MODE_YSF = 3U; const unsigned char MODE_YSF = 3U;
const unsigned char MODE_LOCKOUT = 99U; const unsigned char MODE_LOCKOUT = 99U;
const unsigned char MODE_ERROR = 100U;
const unsigned char TAG_HEADER = 0x00U; const unsigned char TAG_HEADER = 0x00U;
const unsigned char TAG_DATA = 0x01U; const unsigned char TAG_DATA = 0x01U;

View file

@ -31,6 +31,7 @@ public:
virtual void setIdle() = 0; virtual void setIdle() = 0;
virtual void setLockout() = 0; virtual void setLockout() = 0;
virtual void setError(const char* text) = 0;
virtual void setDStar() = 0; virtual void setDStar() = 0;
virtual void writeDStar(const char* my1, const char* my2, const char* your) = 0; virtual void writeDStar(const char* my1, const char* my2, const char* your) = 0;

View file

@ -68,6 +68,19 @@ void CHD44780::setIdle()
::lcdPuts(m_fd, "Idle"); ::lcdPuts(m_fd, "Idle");
} }
void CHD44780::setError(const char* text)
{
assert(text != NULL);
::lcdClear(m_fd);
::lcdPosition(m_fd, 0, 0);
::lcdPuts(m_fd, "MMDVM");
::lcdPosition(m_fd, 0, 1);
::lcdPrintf(m_fd, "%s ERROR", text);
}
void CHD44780::setLockout() void CHD44780::setLockout()
{ {
::lcdClear(m_fd); ::lcdClear(m_fd);

View file

@ -33,6 +33,7 @@ public:
virtual void setIdle(); virtual void setIdle();
virtual void setError(const char* text);
virtual void setLockout(); virtual void setLockout();
virtual void setDStar(); virtual void setDStar();

View file

@ -192,6 +192,12 @@ int CMMDVMHost::run()
else if (!lockout && m_mode == MODE_LOCKOUT) else if (!lockout && m_mode == MODE_LOCKOUT)
setMode(MODE_IDLE); setMode(MODE_IDLE);
bool error = m_modem->hasError();
if (error && m_mode != MODE_ERROR)
setMode(MODE_ERROR);
else if (!error && m_mode == MODE_ERROR)
setMode(MODE_IDLE);
unsigned char data[200U]; unsigned char data[200U];
unsigned int len; unsigned int len;
bool ret; bool ret;
@ -632,6 +638,18 @@ void CMMDVMHost::setMode(unsigned char mode, bool logging)
m_modeTimer.stop(); m_modeTimer.stop();
break; break;
case MODE_ERROR:
if (logging)
LogMessage("Mode set to Error");
if (m_dstarNetwork != NULL)
m_dstarNetwork->enable(false);
if (m_dmrNetwork != NULL)
m_dmrNetwork->enable(false);
m_display->setError("MODEM");
m_mode = MODE_ERROR;
m_modeTimer.stop();
break;
default: default:
if (logging) if (logging)
LogMessage("Mode set to Idle"); LogMessage("Mode set to Idle");

View file

@ -108,7 +108,8 @@ m_dmrSpace1(0U),
m_dmrSpace2(0U), m_dmrSpace2(0U),
m_ysfSpace(0U), m_ysfSpace(0U),
m_tx(false), m_tx(false),
m_lockout(false) m_lockout(false),
m_error(false)
{ {
assert(!port.empty()); assert(!port.empty());
@ -169,6 +170,7 @@ bool CModem::open()
m_statusTimer.start(); m_statusTimer.start();
m_inactivityTimer.start(); m_inactivityTimer.start();
m_error = false;
m_offset = 0U; m_offset = 0U;
return true; return true;
@ -186,6 +188,7 @@ void CModem::clock(unsigned int ms)
m_inactivityTimer.clock(ms); m_inactivityTimer.clock(ms);
if (m_inactivityTimer.hasExpired()) { if (m_inactivityTimer.hasExpired()) {
LogError("No reply from the modem for some time, resetting it"); LogError("No reply from the modem for some time, resetting it");
m_error = true;
close(); close();
#if defined(_WIN32) || defined(_WIN64) #if defined(_WIN32) || defined(_WIN64)
::Sleep(2000UL); // 2s ::Sleep(2000UL); // 2s
@ -643,6 +646,11 @@ bool CModem::hasLockout() const
return m_lockout; return m_lockout;
} }
bool CModem::hasError() const
{
return m_error;
}
bool CModem::writeYSFData(const unsigned char* data, unsigned int length) bool CModem::writeYSFData(const unsigned char* data, unsigned int length)
{ {
assert(data != NULL); assert(data != NULL);

View file

@ -53,6 +53,7 @@ public:
bool hasYSFSpace() const; bool hasYSFSpace() const;
bool hasLockout() const; bool hasLockout() const;
bool hasError() const;
bool writeDStarData(const unsigned char* data, unsigned int length); bool writeDStarData(const unsigned char* data, unsigned int length);
bool writeDMRData1(const unsigned char* data, unsigned int length); bool writeDMRData1(const unsigned char* data, unsigned int length);
@ -105,6 +106,7 @@ private:
unsigned int m_ysfSpace; unsigned int m_ysfSpace;
bool m_tx; bool m_tx;
bool m_lockout; bool m_lockout;
bool m_error;
bool readVersion(); bool readVersion();
bool readStatus(); bool readStatus();

View file

@ -35,6 +35,10 @@ void CNullDisplay::setIdle()
{ {
} }
void CNullDisplay::setError(const char* text)
{
}
void CNullDisplay::setLockout() void CNullDisplay::setLockout()
{ {
} }

View file

@ -33,6 +33,7 @@ public:
virtual void setIdle(); virtual void setIdle();
virtual void setError(const char* text);
virtual void setLockout(); virtual void setLockout();
virtual void setDStar(); virtual void setDStar();

View file

@ -67,10 +67,8 @@ bool CTFTSerial::open()
setBrightness(m_brightness); setBrightness(m_brightness);
// Set background white
setBackground(COLOUR_WHITE); setBackground(COLOUR_WHITE);
// Set foreground black
setForeground(COLOUR_BLACK); setForeground(COLOUR_BLACK);
setIdle(); setIdle();
@ -92,6 +90,29 @@ void CTFTSerial::setIdle()
displayText("IDLE"); displayText("IDLE");
} }
void CTFTSerial::setError(const char* text)
{
assert(text != NULL);
// Clear the screen
clearScreen();
setFontSize(FONT_MEDIUM);
// Draw MMDVM logo
displayBitmap(0U, 0U, "MMDVM_sm.bmp");
setForeground(COLOUR_RED);
gotoPosPixel(18U, 55U);
displayText(text);
gotoPosPixel(18U, 90U);
displayText("ERROR");
setForeground(COLOUR_BLACK);
}
void CTFTSerial::setLockout() void CTFTSerial::setLockout()
{ {
// Clear the screen // Clear the screen

View file

@ -34,6 +34,7 @@ public:
virtual void setIdle(); virtual void setIdle();
virtual void setError(const char* text);
virtual void setLockout(); virtual void setLockout();
virtual void setDStar(); virtual void setDStar();