Merge pull request #78 from g0wfv/develop
Add a clock to the HD44780 Idle screen and redesigned Idle layouts ...
This commit is contained in:
commit
5e3f186895
7 changed files with 204 additions and 72 deletions
16
Conf.cpp
16
Conf.cpp
|
@ -119,6 +119,8 @@ m_hd44780PWM(false),
|
|||
m_hd44780PWMPin(),
|
||||
m_hd44780PWMBright(),
|
||||
m_hd44780PWMDim(),
|
||||
m_hd44780DisplayClock(false),
|
||||
m_hd44780UTC(false),
|
||||
m_nextionPort("/dev/ttyAMA0"),
|
||||
m_nextionBrightness(50U),
|
||||
m_oledType(3),
|
||||
|
@ -370,6 +372,10 @@ bool CConf::read()
|
|||
m_hd44780PWMBright = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "PWMDim") == 0)
|
||||
m_hd44780PWMDim = (unsigned int)::atoi(value);
|
||||
else if (::strcmp(key, "DisplayClock") == 0)
|
||||
m_hd44780DisplayClock = ::atoi(value) == 1;
|
||||
else if (::strcmp(key, "UTC") == 0)
|
||||
m_hd44780UTC = ::atoi(value) == 1;
|
||||
else if (::strcmp(key, "Pins") == 0) {
|
||||
char* p = ::strtok(value, ",\r\n");
|
||||
while (p != NULL) {
|
||||
|
@ -754,6 +760,16 @@ unsigned int CConf::getHD44780PWMDim() const
|
|||
return m_hd44780PWMDim;
|
||||
}
|
||||
|
||||
bool CConf::getHD44780DisplayClock() const
|
||||
{
|
||||
return m_hd44780DisplayClock;
|
||||
}
|
||||
|
||||
bool CConf::getHD44780UTC() const
|
||||
{
|
||||
return m_hd44780UTC;
|
||||
}
|
||||
|
||||
std::string CConf::getNextionPort() const
|
||||
{
|
||||
return m_nextionPort;
|
||||
|
|
4
Conf.h
4
Conf.h
|
@ -126,6 +126,8 @@ public:
|
|||
unsigned int getHD44780PWMPin() const;
|
||||
unsigned int getHD44780PWMBright() const;
|
||||
unsigned int getHD44780PWMDim() const;
|
||||
bool getHD44780DisplayClock() const;
|
||||
bool getHD44780UTC() const;
|
||||
|
||||
// The Nextion section
|
||||
std::string getNextionPort() const;
|
||||
|
@ -221,6 +223,8 @@ private:
|
|||
unsigned int m_hd44780PWMPin;
|
||||
unsigned int m_hd44780PWMBright;
|
||||
unsigned int m_hd44780PWMDim;
|
||||
bool m_hd44780DisplayClock;
|
||||
bool m_hd44780UTC;
|
||||
|
||||
std::string m_nextionPort;
|
||||
unsigned int m_nextionBrightness;
|
||||
|
|
174
HD44780.cpp
174
HD44780.cpp
|
@ -31,7 +31,10 @@
|
|||
const char* LISTENING = "Listening ";
|
||||
const char* DEADSPACE = " ";
|
||||
|
||||
CHD44780::CHD44780(unsigned int rows, unsigned int cols, const std::string& callsign, unsigned int dmrid, const std::vector<unsigned int>& pins, bool pwm, unsigned int pwmPin, unsigned int pwmBright, unsigned int pwmDim, bool duplex) :
|
||||
char m_buffer1[128U];
|
||||
char m_buffer2[128U];
|
||||
|
||||
CHD44780::CHD44780(unsigned int rows, unsigned int cols, const std::string& callsign, unsigned int dmrid, const std::vector<unsigned int>& pins, bool pwm, unsigned int pwmPin, unsigned int pwmBright, unsigned int pwmDim, bool displayClock, bool utc, bool duplex) :
|
||||
CDisplay(),
|
||||
m_rows(rows),
|
||||
m_cols(cols),
|
||||
|
@ -47,11 +50,13 @@ m_pwm(pwm),
|
|||
m_pwmPin(pwmPin),
|
||||
m_pwmBright(pwmBright),
|
||||
m_pwmDim(pwmDim),
|
||||
m_displayClock(displayClock),
|
||||
m_utc(utc),
|
||||
m_duplex(duplex),
|
||||
//m_duplex(true), // uncomment to force duplex display for testing!
|
||||
m_fd(-1),
|
||||
m_dmr(false),
|
||||
m_timer(1000U, 0U, 250U) // 250ms
|
||||
m_clockDisplayTimer(1000U, 0U, 75U) // Update the clock display every 75ms
|
||||
{
|
||||
assert(rows > 1U);
|
||||
assert(cols > 15U);
|
||||
|
@ -288,6 +293,7 @@ void CHD44780::adafruitLCDColour(ADAFRUIT_COLOUR colour)
|
|||
|
||||
void CHD44780::setIdleInt()
|
||||
{
|
||||
m_clockDisplayTimer.start(); // Start the clock display in IDLE only
|
||||
::lcdClear(m_fd);
|
||||
|
||||
#ifdef ADAFRUIT_DISPLAY
|
||||
|
@ -301,16 +307,21 @@ void CHD44780::setIdleInt()
|
|||
::pwmWrite(m_pwmPin, (m_pwmDim / 100) * 1024);
|
||||
}
|
||||
|
||||
// Print callsign and ID at on top row for all screen sizes
|
||||
::lcdPosition(m_fd, 0, 0);
|
||||
::lcdPrintf(m_fd, "%-6s / %u", m_callsign.c_str(), m_dmrid);
|
||||
::lcdPrintf(m_fd, "%-6s", m_callsign.c_str());
|
||||
::lcdPosition(m_fd, m_cols - 7, 0);
|
||||
::lcdPrintf(m_fd, "%7u", m_dmrid);
|
||||
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
// Print MMDVM and Idle on bottom row for all screen sizes
|
||||
::lcdPosition(m_fd, 0, m_rows - 1);
|
||||
::lcdPutchar(m_fd, 2);
|
||||
::lcdPutchar(m_fd, 2);
|
||||
::lcdPutchar(m_fd, 3);
|
||||
::lcdPutchar(m_fd, 4);
|
||||
::lcdPutchar(m_fd, 2);
|
||||
::lcdPuts(m_fd, " Idle");
|
||||
::lcdPosition(m_fd, m_cols - 4, m_rows - 1);
|
||||
::lcdPuts(m_fd, "Idle"); // Gets overwritten by clock on 2 line screen
|
||||
|
||||
m_dmr = false;
|
||||
}
|
||||
|
@ -323,6 +334,7 @@ void CHD44780::setErrorInt(const char* text)
|
|||
adafruitLCDColour(AC_RED);
|
||||
#endif
|
||||
|
||||
m_clockDisplayTimer.stop(); // Stop the clock display
|
||||
::lcdClear(m_fd);
|
||||
|
||||
if (m_pwm) {
|
||||
|
@ -351,6 +363,7 @@ void CHD44780::setLockoutInt()
|
|||
adafruitLCDColour(AC_RED);
|
||||
#endif
|
||||
|
||||
m_clockDisplayTimer.stop(); // Stop the clock display
|
||||
::lcdClear(m_fd);
|
||||
|
||||
if (m_pwm) {
|
||||
|
@ -385,6 +398,7 @@ void CHD44780::writeDStarInt(const char* my1, const char* my2, const char* your,
|
|||
adafruitLCDColour(AC_RED);
|
||||
#endif
|
||||
|
||||
m_clockDisplayTimer.stop(); // Stop the clock display
|
||||
::lcdClear(m_fd);
|
||||
|
||||
if (m_pwm) {
|
||||
|
@ -398,45 +412,45 @@ void CHD44780::writeDStarInt(const char* my1, const char* my2, const char* your,
|
|||
::lcdPuts(m_fd, "D-Star");
|
||||
|
||||
if (m_rows == 2U && m_cols == 16U) {
|
||||
char buffer[16U];
|
||||
::sprintf(buffer, "%s %.8s/%.4s", type, my1, my2);
|
||||
// char buffer[16U];
|
||||
::sprintf(m_buffer1, "%s %.8s/%.4s", type, my1, my2);
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
} else if (m_rows == 4U && m_cols == 16U) {
|
||||
char buffer[16U];
|
||||
::sprintf(buffer, "%s %.8s/%.4s", type, my1, my2);
|
||||
// char buffer[16U];
|
||||
::sprintf(m_buffer1, "%s %.8s/%.4s", type, my1, my2);
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
|
||||
if (strcmp(reflector, " ") == 0)
|
||||
::sprintf(buffer, "%.8s", your);
|
||||
::sprintf(m_buffer1, "%.8s", your);
|
||||
else
|
||||
::sprintf(buffer, "%.8s<%.8s", your, reflector);
|
||||
::sprintf(m_buffer1, "%.8s<%.8s", your, reflector);
|
||||
|
||||
::lcdPosition(m_fd, 0, 2);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
} else if (m_rows == 4U && m_cols == 20U) {
|
||||
char buffer[20U];
|
||||
::sprintf(buffer, "%s %.8s/%.4s >", type, my1, my2);
|
||||
char m_buffer1[20U];
|
||||
::sprintf(m_buffer1, "%s %.8s/%.4s >", type, my1, my2);
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
|
||||
if (strcmp(reflector, " ") == 0)
|
||||
::sprintf(buffer, "%.8s", your);
|
||||
::sprintf(m_buffer1, "%.8s", your);
|
||||
else
|
||||
::sprintf(buffer, "%.8s <- %.8s", your, reflector);
|
||||
::sprintf(m_buffer1, "%.8s <- %.8s", your, reflector);
|
||||
|
||||
::lcdPosition(m_fd, 0, 2);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
} else if (m_rows == 2 && m_cols == 40U) {
|
||||
char buffer[40U];
|
||||
char m_buffer1[40U];
|
||||
if (strcmp(reflector, " ") == 0)
|
||||
::sprintf(buffer, "%s %.8s/%.4s > %.8s", type, my1, my2, your);
|
||||
::sprintf(m_buffer1, "%s %.8s/%.4s > %.8s", type, my1, my2, your);
|
||||
else
|
||||
::sprintf(buffer, "%s %.8s/%.4s > %.8s via %.8s", type, my1, my2, your, reflector);
|
||||
::sprintf(m_buffer1, "%s %.8s/%.4s > %.8s via %.8s", type, my1, my2, your, reflector);
|
||||
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
}
|
||||
|
||||
m_dmr = false;
|
||||
|
@ -448,6 +462,8 @@ void CHD44780::clearDStarInt()
|
|||
adafruitLCDColour(AC_PURPLE);
|
||||
#endif
|
||||
|
||||
m_clockDisplayTimer.stop(); // Stop the clock display
|
||||
|
||||
if (m_rows == 2U && m_cols == 16U) {
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
|
||||
|
@ -471,10 +487,11 @@ void CHD44780::clearDStarInt()
|
|||
|
||||
void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type)
|
||||
{
|
||||
char buffer[128]; // force 128 char buffer - we're never getting that far but stops us overflowing it!
|
||||
// char buffer[128]; // force 128 char buffer - we're never getting that far but stops us overflowing it!
|
||||
assert(type != NULL);
|
||||
|
||||
if (!m_dmr) {
|
||||
m_clockDisplayTimer.stop(); // Stop the clock display
|
||||
::lcdClear(m_fd);
|
||||
|
||||
#ifdef ADAFRUIT_DISPLAY
|
||||
|
@ -491,8 +508,8 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro
|
|||
if (m_duplex) {
|
||||
if (m_rows > 2U) {
|
||||
::lcdPosition(m_fd, 0, (m_rows / 2) - 2);
|
||||
::sprintf(buffer, "%s%s", "DMR", DEADSPACE);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
||||
::sprintf(m_buffer1, "%s%s", "DMR", DEADSPACE);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
}
|
||||
|
||||
if (slotNo == 1U) {
|
||||
|
@ -504,8 +521,8 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro
|
|||
}
|
||||
} else {
|
||||
::lcdPosition(m_fd, 0, (m_rows / 2) - 1);
|
||||
::sprintf(buffer, "%s%s", "DMR", DEADSPACE);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
||||
::sprintf(m_buffer1, "%s%s", "DMR", DEADSPACE);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
::lcdPosition(m_fd, 0, (m_rows / 2));
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
|
||||
}
|
||||
|
@ -519,10 +536,8 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro
|
|||
if (slotNo == 1U) {
|
||||
::lcdPosition(m_fd, 0, (m_rows / 2) - 1);
|
||||
::lcdPuts(m_fd, "1 ");
|
||||
::sprintf(buffer, "%s > %s%s", src.c_str(), dst.c_str(), DEADSPACE);
|
||||
|
||||
// Thread this out?
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols - 2U, buffer);
|
||||
::sprintf(m_buffer1, "%s > %s%s", src.c_str(), dst.c_str(), DEADSPACE);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols - 2U, m_buffer1);
|
||||
|
||||
if (m_cols > 16) {
|
||||
::lcdCharDef(m_fd, 6, group ? tgChar : privChar);
|
||||
|
@ -535,10 +550,8 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro
|
|||
} else {
|
||||
::lcdPosition(m_fd, 0, (m_rows / 2));
|
||||
::lcdPuts(m_fd, "2 ");
|
||||
::sprintf(buffer, "%s > %s%s", src.c_str(), dst.c_str(), DEADSPACE);
|
||||
|
||||
// Thread this out?
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols - 2U, buffer);
|
||||
::sprintf(m_buffer2, "%s > %s%s", src.c_str(), dst.c_str(), DEADSPACE);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols - 2U, m_buffer2);
|
||||
|
||||
if (m_cols > 16) {
|
||||
::lcdCharDef(m_fd, 6, group ? tgChar : privChar);
|
||||
|
@ -552,16 +565,16 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro
|
|||
} else {
|
||||
::lcdPosition(m_fd, 0, (m_rows / 2) - 1);
|
||||
::lcdPutchar(m_fd, 0);
|
||||
::sprintf(buffer, " %s%s", src.c_str(), DEADSPACE);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols - 4U, buffer);
|
||||
::sprintf(m_buffer2, " %s%s", src.c_str(), DEADSPACE);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols - 4U, m_buffer2);
|
||||
::lcdCharDef(m_fd, 5, strcmp(type, "R") == 0 ? rfChar : ipChar);
|
||||
::lcdPosition(m_fd, m_cols - 1U, (m_rows / 2) - 1);
|
||||
::lcdPutchar(m_fd, 5);
|
||||
|
||||
::lcdPosition(m_fd, 0, (m_rows / 2));
|
||||
::lcdPutchar(m_fd, 1);
|
||||
::sprintf(buffer, " %s%s", dst.c_str(), DEADSPACE);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols - 4U, buffer);
|
||||
::sprintf(m_buffer2, " %s%s", dst.c_str(), DEADSPACE);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols - 4U, m_buffer2);
|
||||
::lcdCharDef(m_fd, 6, group ? tgChar : privChar);
|
||||
::lcdPosition(m_fd, m_cols - 1U, (m_rows / 2));
|
||||
::lcdPutchar(m_fd, 6);
|
||||
|
@ -571,12 +584,13 @@ void CHD44780::writeDMRInt(unsigned int slotNo, const std::string& src, bool gro
|
|||
|
||||
void CHD44780::clearDMRInt(unsigned int slotNo)
|
||||
{
|
||||
char buffer[128]; // force 128 char buffer - we're never getting that far but stops us overflowing it!
|
||||
// char buffer[128]; // force 128 char buffer - we're never getting that far but stops us overflowing it!
|
||||
|
||||
#ifdef ADAFRUIT_DISPLAY
|
||||
adafruitLCDColour(AC_PURPLE);
|
||||
#endif
|
||||
|
||||
m_clockDisplayTimer.stop(); // Stop the clock display
|
||||
if (m_duplex) {
|
||||
if (slotNo == 1U) {
|
||||
::lcdPosition(m_fd, 0, 0);
|
||||
|
@ -587,8 +601,8 @@ void CHD44780::clearDMRInt(unsigned int slotNo)
|
|||
}
|
||||
} else {
|
||||
::lcdPosition(m_fd, 0, (m_rows / 2) - 1);
|
||||
::sprintf(buffer, "%s%s", "DMR", DEADSPACE);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
||||
::sprintf(m_buffer2, "%s%s", "DMR", DEADSPACE);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer2);
|
||||
::lcdPosition(m_fd, 0, (m_rows / 2));
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
|
||||
}
|
||||
|
@ -605,6 +619,7 @@ void CHD44780::writeFusionInt(const char* source, const char* dest, const char*
|
|||
adafruitLCDColour(AC_RED);
|
||||
#endif
|
||||
|
||||
m_clockDisplayTimer.stop(); // Stop the clock display
|
||||
::lcdClear(m_fd);
|
||||
|
||||
if (m_pwm) {
|
||||
|
@ -618,34 +633,34 @@ void CHD44780::writeFusionInt(const char* source, const char* dest, const char*
|
|||
::lcdPuts(m_fd, "System Fusion");
|
||||
|
||||
if (m_rows == 2U && m_cols == 16U) {
|
||||
char buffer[16U];
|
||||
::sprintf(buffer, "%.10s >", source);
|
||||
char m_buffer1[16U];
|
||||
::sprintf(m_buffer1, "%.10s >", source);
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
} else if (m_rows == 4U && m_cols == 16U) {
|
||||
char buffer[16U];
|
||||
::sprintf(buffer, "%.10s >", source);
|
||||
char m_buffer1[16U];
|
||||
::sprintf(m_buffer1, "%.10s >", source);
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
|
||||
::sprintf(buffer, "%.10s", dest);
|
||||
::sprintf(m_buffer1, "%.10s", dest);
|
||||
::lcdPosition(m_fd, 0, 2);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
} else if (m_rows == 4U && m_cols == 20U) {
|
||||
char buffer[20U];
|
||||
::sprintf(buffer, "%.10s >", source);
|
||||
char m_buffer1[20U];
|
||||
::sprintf(m_buffer1, "%.10s >", source);
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
|
||||
::sprintf(buffer, "%.10s", dest);
|
||||
::sprintf(m_buffer1, "%.10s", dest);
|
||||
::lcdPosition(m_fd, 0, 2);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
} else if (m_rows == 2 && m_cols == 40U) {
|
||||
char buffer[40U];
|
||||
::sprintf(buffer, "%.10s > %.10s", source, dest);
|
||||
char m_buffer1[40U];
|
||||
::sprintf(m_buffer1, "%.10s > %.10s", source, dest);
|
||||
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, buffer);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, m_buffer1);
|
||||
}
|
||||
|
||||
m_dmr = false;
|
||||
|
@ -657,6 +672,8 @@ void CHD44780::clearFusionInt()
|
|||
adafruitLCDColour(AC_PURPLE);
|
||||
#endif
|
||||
|
||||
m_clockDisplayTimer.stop(); // Stop the clock display
|
||||
|
||||
if (m_rows == 2U && m_cols == 16U) {
|
||||
::lcdPosition(m_fd, 0, 1);
|
||||
::lcdPrintf(m_fd, "%.*s", m_cols, LISTENING);
|
||||
|
@ -680,13 +697,38 @@ void CHD44780::clearFusionInt()
|
|||
|
||||
void CHD44780::clockInt(unsigned int ms)
|
||||
{
|
||||
m_timer.clock(ms);
|
||||
if (m_timer.isRunning() && m_timer.hasExpired()) {
|
||||
// Do work every 250ms here
|
||||
// Update the clock display in IDLE mode every 75ms
|
||||
m_clockDisplayTimer.clock(ms);
|
||||
if (m_displayClock && m_clockDisplayTimer.isRunning() && m_clockDisplayTimer.hasExpired()) {
|
||||
time_t currentTime;
|
||||
struct tm *Time;
|
||||
time(¤tTime); // Get the current time
|
||||
|
||||
// Start the timer with m_timer.start();
|
||||
// and stop it with m_timer.stop();
|
||||
m_timer.start();
|
||||
if (m_utc){
|
||||
Time = gmtime(¤tTime);
|
||||
} else {
|
||||
Time = localtime(¤tTime);
|
||||
}
|
||||
|
||||
int Day = Time->tm_mday;
|
||||
int Month = Time->tm_mon + 1;
|
||||
int Year = Time->tm_year + 1900;
|
||||
int Hour = Time->tm_hour;
|
||||
int Min = Time->tm_min;
|
||||
int Sec = Time->tm_sec;
|
||||
|
||||
if (m_cols == 16U && m_rows == 2U) {
|
||||
::lcdPosition(m_fd, m_cols - 8, 1);
|
||||
} else {
|
||||
::lcdPosition(m_fd, (m_cols - 8) / 2, m_rows == 2 ? 1 : 2);
|
||||
}
|
||||
::lcdPrintf(m_fd, "%02d:%02d:%02d", Hour, Min, Sec);
|
||||
|
||||
if (m_cols != 16U && m_rows != 2U) {
|
||||
::lcdPosition(m_fd, (m_cols - 8) / 2, m_rows == 2 ? 0 : 1);
|
||||
::lcdPrintf(m_fd, "%02d/%02d/%2d", Day, Month, Year%100);
|
||||
}
|
||||
m_clockDisplayTimer.start(); // restart the clock display timer
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ enum ADAFRUIT_COLOUR {
|
|||
class CHD44780 : public CDisplay
|
||||
{
|
||||
public:
|
||||
CHD44780(unsigned int rows, unsigned int cols, const std::string& callsign, unsigned int dmrid, const std::vector<unsigned int>& pins, bool pwm, unsigned int pwmPin, unsigned int pwmBright, unsigned int pwmDim, bool duplex);
|
||||
CHD44780(unsigned int rows, unsigned int cols, const std::string& callsign, unsigned int dmrid, const std::vector<unsigned int>& pins, bool pwm, unsigned int pwmPin, unsigned int pwmBright, unsigned int pwmDim, bool displayClock, bool utc, bool duplex);
|
||||
virtual ~CHD44780();
|
||||
|
||||
virtual bool open();
|
||||
|
@ -91,10 +91,12 @@ private:
|
|||
unsigned int m_pwmPin;
|
||||
unsigned int m_pwmBright;
|
||||
unsigned int m_pwmDim;
|
||||
bool m_displayClock;
|
||||
bool m_utc;
|
||||
bool m_duplex;
|
||||
int m_fd;
|
||||
bool m_dmr;
|
||||
CTimer m_timer;
|
||||
CTimer m_clockDisplayTimer;
|
||||
|
||||
#ifdef ADAFRUIT_DISPLAY
|
||||
void adafruitLCDSetup();
|
||||
|
|
58
HD44780.layouts
Normal file
58
HD44780.layouts
Normal file
|
@ -0,0 +1,58 @@
|
|||
IDLE SCREEN LAYOUTS
|
||||
-------------------
|
||||
|
||||
16 x 2
|
||||
------
|
||||
|
||||
With clock Without clock
|
||||
---------- -------------
|
||||
|
||||
0 1 0 1
|
||||
0123456789012345 0123456789012345
|
||||
+----------------+ +----------------+
|
||||
0|AAAAAA NNNNNNN| 0|AAAAAA NNNNNNN|
|
||||
1|MMDVM HH:MM:SS| 1|MMDVM Idle|
|
||||
+----------------+ +----------------+
|
||||
|
||||
40 x 2
|
||||
------
|
||||
|
||||
With clock Without clock
|
||||
---------- -------------
|
||||
|
||||
0 1 2 3 0 1 2 3
|
||||
0123456789012345678901234567890123456789 0123456789012345678901234567890123456789
|
||||
+----------------------------------------+ +----------------------------------------+
|
||||
0|AAAAAA DD/MM/YY NNNNNNN| 0|AAAAAA NNNNNNN|
|
||||
1|MMDVM HH:MM:SS Idle| 1|MMDVM Idle|
|
||||
+----------------------------------------+ +----------------------------------------+
|
||||
|
||||
16 x 4
|
||||
------
|
||||
|
||||
With clock Without clock
|
||||
---------- -------------
|
||||
|
||||
0 1 0 1
|
||||
0123456789012345 0123456789012345
|
||||
+----------------+ +----------------+
|
||||
0|AAAAAA NNNNNNN| 0|AAAAAA NNNNNNN|
|
||||
1| DD/MM/YY | 1| |
|
||||
2| HH:MM:SS | 2| |
|
||||
3|MMDVM Idle| 3|MMDVM Idle|
|
||||
+----------------+ +----------------+
|
||||
|
||||
20 x 4
|
||||
------
|
||||
|
||||
With clock Without clock
|
||||
---------- -------------
|
||||
|
||||
0 1 0 1
|
||||
01234567890123456479 01234567890123456789
|
||||
+--------------------+ +--------------------+
|
||||
0|AAAAAA NNNNNNN| 0|AAAAAA NNNNNNN|
|
||||
1| DD/MM/YY | 1| |
|
||||
2| HH:MM:SS | 2| |
|
||||
3|MMDVM Idle| 3|MMDVM Idle|
|
||||
+--------------------+ +--------------------+
|
|
@ -95,12 +95,16 @@ Pins=11,10,0,1,2,3
|
|||
# For Adafruit i2c HD44780
|
||||
# Pins=115,113,112,111,110,109
|
||||
|
||||
# PWM brightness control
|
||||
PWM=1
|
||||
# PWM backlight
|
||||
PWM=0
|
||||
PWMPin=21
|
||||
PWMBright=100
|
||||
PWMDim=16
|
||||
|
||||
# Display a clock when in IDLE? (HD44780 ONLY!)
|
||||
DisplayClock=1
|
||||
UTC=0
|
||||
|
||||
[Nextion]
|
||||
Port=/dev/ttyAMA0
|
||||
Brightness=50
|
||||
|
|
|
@ -801,20 +801,26 @@ void CMMDVMHost::createDisplay()
|
|||
unsigned int pwmPin = m_conf.getHD44780PWMPin();
|
||||
unsigned int pwmBright = m_conf.getHD44780PWMBright();
|
||||
unsigned int pwmDim = m_conf.getHD44780PWMDim();
|
||||
bool displayClock = m_conf.getHD44780DisplayClock();
|
||||
bool utc = m_conf.getHD44780UTC();
|
||||
|
||||
if (pins.size() == 6U) {
|
||||
LogInfo(" Rows: %u", rows);
|
||||
LogInfo(" Columns: %u", columns);
|
||||
LogInfo(" Pins: %u,%u,%u,%u,%u,%u", pins.at(0U), pins.at(1U), pins.at(2U), pins.at(3U), pins.at(4U), pins.at(5U));
|
||||
|
||||
LogInfo(" PWM Backlight: %s", pwm ? "yes" : "no");
|
||||
if (pwm) {
|
||||
LogInfo("PWM Brightness Control Enabled");
|
||||
LogInfo(" PWM Pin: %u", pwmPin);
|
||||
LogInfo(" PWM Bright: %u", pwmBright);
|
||||
LogInfo(" PWM Dim: %u", pwmDim);
|
||||
}
|
||||
|
||||
m_display = new CHD44780(rows, columns, m_callsign, dmrid, pins, pwm, pwmPin, pwmBright, pwmDim, m_duplex);
|
||||
LogInfo(" Clock Display: %s", displayClock ? "yes" : "no");
|
||||
if (displayClock)
|
||||
LogInfo(" Display UTC: %s", utc ? "yes" : "no");
|
||||
|
||||
m_display = new CHD44780(rows, columns, m_callsign, dmrid, pins, pwm, pwmPin, pwmBright, pwmDim, displayClock, utc, m_duplex);
|
||||
}
|
||||
#endif
|
||||
#if defined(OLED)
|
||||
|
|
Loading…
Reference in a new issue