Add M17 to the HD44780 display.
This commit is contained in:
parent
c469d31227
commit
116e257f90
178
HD44780.cpp
178
HD44780.cpp
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2016,2017,2018,2020 by Jonathan Naylor G4KLX & Tony Corbett G0WFV
|
||||
* Copyright (C) 2016,2017,2018,2020,2021 by Jonathan Naylor G4KLX & Tony Corbett G0WFV
|
||||
*
|
||||
* 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
|
||||
|
@ -41,6 +41,7 @@ const unsigned int DMR_RSSI_COUNT = 4U; // 4 * 360ms = 1440ms
|
|||
const unsigned int YSF_RSSI_COUNT = 13U; // 13 * 100ms = 1300ms
|
||||
const unsigned int P25_RSSI_COUNT = 7U; // 7 * 180ms = 1260ms
|
||||
const unsigned int NXDN_RSSI_COUNT = 28U; // 28 * 40ms = 1120ms
|
||||
const unsigned int M17_RSSI_COUNT = 28U; // 28 * 40ms = 1120ms
|
||||
|
||||
CHD44780::CHD44780(unsigned int rows, unsigned int cols, const std::string& callsign, unsigned int dmrid, const std::vector<unsigned int>& pins, unsigned int i2cAddress, bool pwm, unsigned int pwmPin, unsigned int pwmBright, unsigned int pwmDim, bool displayClock, bool utc, bool duplex) :
|
||||
CDisplay(),
|
||||
|
@ -275,12 +276,12 @@ void CHD44780::pcf8574LCDSetup()
|
|||
::pcf8574Setup(AF_BASE, m_i2cAddress);
|
||||
|
||||
// Turn on backlight
|
||||
::pinMode (AF_BL, OUTPUT);
|
||||
::digitalWrite (AF_BL, 1);
|
||||
::pinMode(AF_BL, OUTPUT);
|
||||
::digitalWrite(AF_BL, 1);
|
||||
|
||||
// Set LCD to write mode.
|
||||
::pinMode (AF_RW, OUTPUT);
|
||||
::digitalWrite (AF_RW, 0);
|
||||
::pinMode(AF_RW, OUTPUT);
|
||||
::digitalWrite(AF_RW, 0);
|
||||
|
||||
m_rb = AF_RS;
|
||||
m_strb = AF_E;
|
||||
|
@ -463,11 +464,10 @@ void CHD44780::writeDStarInt(const char* my1, const char* my2, const char* your,
|
|||
::lcdPrintf(m_fd, " %.8s/%.4s", my1, my2);
|
||||
::lcdPosition(m_fd, m_cols - 1, (m_rows / 2) - 1);
|
||||
|
||||
if (strcmp(type, "R") == 0) {
|
||||
if (strcmp(type, "R") == 0)
|
||||
::lcdPutchar(m_fd, 2);
|
||||
} else {
|
||||
else
|
||||
::lcdPutchar(m_fd, 3);
|
||||
}
|
||||
|
||||
::sprintf(m_buffer1, "%.8s", your);
|
||||
|
||||
|
@ -599,21 +599,20 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro
|
|||
::lcdPosition(m_fd, m_cols - 3U, (m_rows / 2) - 1);
|
||||
::lcdPuts(m_fd, " ");
|
||||
|
||||
if (group) {
|
||||
if (group)
|
||||
::lcdPutchar(m_fd, 5);
|
||||
} else {
|
||||
else
|
||||
::lcdPutchar(m_fd, 4);
|
||||
}
|
||||
|
||||
if (strcmp(type, "R") == 0) {
|
||||
if (strcmp(type, "R") == 0)
|
||||
::lcdPutchar(m_fd, 2);
|
||||
} else {
|
||||
else
|
||||
::lcdPutchar(m_fd, 3);
|
||||
}
|
||||
} else {
|
||||
::lcdPosition(m_fd, 0, (m_rows / 2));
|
||||
::lcdPuts(m_fd, "2 ");
|
||||
if (m_cols > 16 )
|
||||
|
||||
if (m_cols > 16)
|
||||
::sprintf(m_buffer2, "%s > %s%s%s", src.c_str(), group ? "TG" : "", dst.c_str(), DEADSPACE);
|
||||
else
|
||||
::sprintf(m_buffer2, "%s>%s%s", src.c_str(), dst.c_str(), DEADSPACE);
|
||||
|
@ -622,18 +621,16 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro
|
|||
::lcdPosition(m_fd, m_cols - 3U, (m_rows / 2));
|
||||
::lcdPuts(m_fd, " ");
|
||||
|
||||
if (group) {
|
||||
if (group)
|
||||
::lcdPutchar(m_fd, 5);
|
||||
} else {
|
||||
else
|
||||
::lcdPutchar(m_fd, 4);
|
||||
}
|
||||
|
||||
if (strcmp(type, "R") == 0) {
|
||||
if (strcmp(type, "R") == 0)
|
||||
::lcdPutchar(m_fd, 2);
|
||||
} else {
|
||||
else
|
||||
::lcdPutchar(m_fd, 3);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (m_rows > 2U) {
|
||||
::lcdPosition(m_fd, 0, (m_rows / 2) - 2);
|
||||
|
@ -647,11 +644,10 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro
|
|||
::lcdPrintf(m_fd, "%.*s", m_cols - 4U, m_buffer2);
|
||||
::lcdPosition(m_fd, m_cols - 1U, (m_rows / 2) - 1);
|
||||
|
||||
if (strcmp(type, "R") == 0) {
|
||||
if (strcmp(type, "R") == 0)
|
||||
::lcdPutchar(m_fd, 2);
|
||||
} else {
|
||||
else
|
||||
::lcdPutchar(m_fd, 3);
|
||||
}
|
||||
|
||||
::lcdPosition(m_fd, 0, (m_rows / 2));
|
||||
::lcdPutchar(m_fd, 1);
|
||||
|
@ -659,12 +655,12 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro
|
|||
::lcdPrintf(m_fd, "%.*s", m_cols - 4U, m_buffer2);
|
||||
::lcdPosition(m_fd, m_cols - 1U, (m_rows / 2));
|
||||
|
||||
if (group) {
|
||||
if (group)
|
||||
::lcdPutchar(m_fd, 5);
|
||||
} else {
|
||||
else
|
||||
::lcdPutchar(m_fd, 4);
|
||||
}
|
||||
}
|
||||
|
||||
m_dmr = true;
|
||||
m_rssiCount1 = 0U;
|
||||
m_rssiCount2 = 0U;
|
||||
|
@ -722,7 +718,6 @@ void CHD44780::clearDMRInt(unsigned int slotNo)
|
|||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
if (m_rows > 2U) {
|
||||
::lcdPosition(m_fd, 0, (m_rows / 2) - 2);
|
||||
::sprintf(m_buffer1, "%s", DEADSPACE);
|
||||
|
@ -762,12 +757,10 @@ void CHD44780::writeFusionInt(const char* source, const char* dest, unsigned cha
|
|||
::lcdPuts(m_fd, "System Fusion");
|
||||
|
||||
if (m_rows == 2U && m_cols == 16U) {
|
||||
char m_buffer1[16U];
|
||||
::sprintf(m_buffer1, "%.10s >", source);
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
} else if (m_rows == 4U && m_cols == 16U) {
|
||||
char m_buffer1[16U];
|
||||
::sprintf(m_buffer1, "%.10s >", source);
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
|
@ -776,7 +769,6 @@ void CHD44780::writeFusionInt(const char* source, const char* dest, unsigned cha
|
|||
::lcdPosition(m_fd, 0, 2);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
} else if (m_rows == 4U && m_cols == 20U) {
|
||||
char m_buffer1[20U];
|
||||
::sprintf(m_buffer1, "%.10s >", source);
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
|
@ -785,7 +777,6 @@ void CHD44780::writeFusionInt(const char* source, const char* dest, unsigned cha
|
|||
::lcdPosition(m_fd, 0, 2);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
} else if (m_rows == 2 && m_cols == 40U) {
|
||||
char m_buffer1[40U];
|
||||
::sprintf(m_buffer1, "%.10s > DG-ID %u", source, dgid);
|
||||
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
|
@ -865,12 +856,10 @@ void CHD44780::writeP25Int(const char* source, bool group, unsigned int dest, co
|
|||
::lcdPuts(m_fd, "P25");
|
||||
|
||||
if (m_rows == 2U && m_cols == 16U) {
|
||||
char m_buffer1[16U];
|
||||
::sprintf(m_buffer1, "%.10s >", source);
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
} else if (m_rows == 4U && m_cols == 16U) {
|
||||
char m_buffer1[16U];
|
||||
::sprintf(m_buffer1, "%.10s >", source);
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
|
@ -879,7 +868,6 @@ void CHD44780::writeP25Int(const char* source, bool group, unsigned int dest, co
|
|||
::lcdPosition(m_fd, 0, 2);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
} else if (m_rows == 4U && m_cols == 20U) {
|
||||
char m_buffer1[20U];
|
||||
::sprintf(m_buffer1, "%.10s >", source);
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
|
@ -888,7 +876,6 @@ void CHD44780::writeP25Int(const char* source, bool group, unsigned int dest, co
|
|||
::lcdPosition(m_fd, 0, 2);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
} else if (m_rows == 2 && m_cols == 40U) {
|
||||
char m_buffer1[40U];
|
||||
::sprintf(m_buffer1, "%.10s > %s%u", source, group ? "TG" : "", dest);
|
||||
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
|
@ -969,12 +956,10 @@ void CHD44780::writeNXDNInt(const char* source, bool group, unsigned int dest, c
|
|||
::lcdPuts(m_fd, "NXDN");
|
||||
|
||||
if (m_rows == 2U && m_cols == 16U) {
|
||||
char m_buffer1[16U];
|
||||
::sprintf(m_buffer1, "%.10s >", source);
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
} else if (m_rows == 4U && m_cols == 16U) {
|
||||
char m_buffer1[16U];
|
||||
::sprintf(m_buffer1, "%.10s >", source);
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
|
@ -983,7 +968,6 @@ void CHD44780::writeNXDNInt(const char* source, bool group, unsigned int dest, c
|
|||
::lcdPosition(m_fd, 0, 2);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
} else if (m_rows == 4U && m_cols == 20U) {
|
||||
char m_buffer1[20U];
|
||||
::sprintf(m_buffer1, "%.10s >", source);
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
|
@ -992,9 +976,7 @@ void CHD44780::writeNXDNInt(const char* source, bool group, unsigned int dest, c
|
|||
::lcdPosition(m_fd, 0, 2);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
} else if (m_rows == 2 && m_cols == 40U) {
|
||||
char m_buffer1[40U];
|
||||
::sprintf(m_buffer1, "%.10s > %s%u", source, group ? "TG" : "", dest);
|
||||
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
}
|
||||
|
@ -1050,6 +1032,105 @@ void CHD44780::clearNXDNInt()
|
|||
}
|
||||
}
|
||||
|
||||
void CHD44780::writeM17Int(const char* source, const char* dest, const char* type)
|
||||
{
|
||||
assert(source != NULL);
|
||||
assert(dest != NULL);
|
||||
assert(type != NULL);
|
||||
|
||||
#ifdef ADAFRUIT_DISPLAY
|
||||
adafruitLCDColour(AC_RED);
|
||||
#endif
|
||||
|
||||
m_clockDisplayTimer.stop(); // Stop the clock display
|
||||
::lcdClear(m_fd);
|
||||
|
||||
if (m_pwm) {
|
||||
if (m_pwmPin != 1U)
|
||||
::softPwmWrite(m_pwmPin, m_pwmBright);
|
||||
else
|
||||
::pwmWrite(m_pwmPin, (m_pwmBright / 100) * 1024);
|
||||
}
|
||||
|
||||
::lcdPosition(m_fd, 0, 0);
|
||||
::lcdPuts(m_fd, "M17");
|
||||
|
||||
::sprintf(m_buffer1, "%.9s", source);
|
||||
::sprintf(m_buffer2, "%.9s", dest);
|
||||
|
||||
if (m_rows == 2U && m_cols == 16U) {
|
||||
::lcdPosition(m_fd, 5, 0);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols - 5, m_buffer1);
|
||||
::lcdPosition(m_fd, 5, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols - 5, m_buffer2);
|
||||
} else if (m_rows == 4U && m_cols == 16U) {
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
::lcdPosition(m_fd, 0, 2);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer2);
|
||||
} else if (m_rows == 4U && m_cols == 20U) {
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
::lcdPosition(m_fd, 0, 2);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
} else if (m_rows == 2 && m_cols == 40U) {
|
||||
::sprintf(m_buffer1, "%.9s > %.9s", source, dest);
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
}
|
||||
|
||||
m_dmr = false;
|
||||
m_rssiCount1 = 0U;
|
||||
}
|
||||
|
||||
void CHD44780::writeFusionM17Int(unsigned char rssi)
|
||||
{
|
||||
if (m_rssiCount1 == 0U && m_rows > 2) {
|
||||
::lcdPosition(m_fd, 0, 3);
|
||||
::lcdPrintf(m_fd, "-%3udBm", rssi);
|
||||
}
|
||||
|
||||
m_rssiCount1++;
|
||||
if (m_rssiCount1 >= M17_RSSI_COUNT)
|
||||
m_rssiCount1 = 0U;
|
||||
}
|
||||
|
||||
void CHD44780::clearM17Int()
|
||||
{
|
||||
#ifdef ADAFRUIT_DISPLAY
|
||||
adafruitLCDColour(AC_PURPLE);
|
||||
#endif
|
||||
m_clockDisplayTimer.stop(); // Stop the clock display
|
||||
|
||||
if (m_rows == 2U && m_cols == 16U) {
|
||||
::lcdPosition(m_fd, 5, 0);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols - 5, LISTENING);
|
||||
::lcdPosition(m_fd, 5, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols - 5, " ");
|
||||
} else if (m_rows == 4U && m_cols == 16U) {
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
|
||||
|
||||
::lcdPosition(m_fd, 0, 2);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, " ");
|
||||
|
||||
::lcdPosition(m_fd, 0, 3);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, " ");
|
||||
} else if (m_rows == 4U && m_cols == 20U) {
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
|
||||
|
||||
::lcdPosition(m_fd, 0, 2);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, " ");
|
||||
|
||||
::lcdPosition(m_fd, 0, 3);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, " ");
|
||||
} else if (m_rows == 2 && m_cols == 40U) {
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
|
||||
}
|
||||
}
|
||||
|
||||
void CHD44780::writePOCSAGInt(uint32_t ric, const std::string& message)
|
||||
{
|
||||
::lcdPosition(m_fd, m_cols - 5, m_rows - 1);
|
||||
|
@ -1082,17 +1163,16 @@ void CHD44780::clockInt(unsigned int ms)
|
|||
if (m_displayClock && m_clockDisplayTimer.isRunning() && m_clockDisplayTimer.hasExpired()) {
|
||||
time_t currentTime;
|
||||
struct tm *Time;
|
||||
time(¤tTime);
|
||||
::time(¤tTime);
|
||||
|
||||
if (m_utc) {
|
||||
Time = gmtime(¤tTime);
|
||||
} else {
|
||||
Time = localtime(¤tTime);
|
||||
}
|
||||
if (m_utc)
|
||||
Time = ::gmtime(¤tTime);
|
||||
else
|
||||
Time = ::localtime(¤tTime);
|
||||
|
||||
setlocale(LC_TIME,"");
|
||||
strftime(m_buffer1, 128, "%X", Time); // Time
|
||||
strftime(m_buffer2, 128, "%x", Time); // Date
|
||||
::strftime(m_buffer1, 128, "%X", Time); // Time
|
||||
::strftime(m_buffer2, 128, "%x", Time); // Date
|
||||
|
||||
if (m_cols == 16U && m_rows == 2U) {
|
||||
::lcdPosition(m_fd, m_cols - 10, 1);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2016,2017,2018,2020 by Jonathan Naylor G4KLX & Tony Corbett G0WFV
|
||||
* Copyright (C) 2016,2017,2018,2020,2021 by Jonathan Naylor G4KLX & Tony Corbett G0WFV
|
||||
*
|
||||
* 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
|
||||
|
@ -123,6 +123,10 @@ protected:
|
|||
virtual void writeNXDNRSSIInt(unsigned char rssi);
|
||||
virtual void clearNXDNInt();
|
||||
|
||||
virtual void writeM17Int(const char* source, const char* dest, const char* type);
|
||||
virtual void writeM17RSSIInt(unsigned char rssi);
|
||||
virtual void clearM17Int();
|
||||
|
||||
virtual void writePOCSAGInt(uint32_t ric, const std::string& message);
|
||||
virtual void clearPOCSAGInt();
|
||||
|
||||
|
|
Loading…
Reference in New Issue