From 2bd75c1cffdcbfe7f4ff0b2713784db4efdc925d Mon Sep 17 00:00:00 2001 From: phl0 Date: Wed, 22 Jun 2016 11:51:41 +0200 Subject: [PATCH] Add dot as date separator --- Conf.cpp | 8 ++++++++ Conf.h | 2 ++ MMDVM.ini | 1 + MMDVMHost.cpp | 3 ++- Nextion.cpp | 11 +++++++++-- Nextion.h | 3 ++- 6 files changed, 24 insertions(+), 4 deletions(-) diff --git a/Conf.cpp b/Conf.cpp index 0dbea94..b9c922c 100644 --- a/Conf.cpp +++ b/Conf.cpp @@ -139,6 +139,7 @@ m_nextionPort("/dev/ttyAMA0"), m_nextionBrightness(50U), m_nextionDisplayClock(false), m_nextionUTC(false), +m_nextionDateFormat("English"), m_oledType(3), m_oledBrightness(0), m_oledInvert(0) @@ -461,6 +462,8 @@ bool CConf::read() m_nextionDisplayClock = ::atoi(value) == 1; else if (::strcmp(key, "UTC") == 0) m_nextionUTC = ::atoi(value) == 1; + else if (::strcmp(key, "DateFormat") == 0) + m_nextionDateFormat = value; } else if (section == SECTION_OLED) { if (::strcmp(key, "Type") == 0) m_oledType = (unsigned char)::atoi(value); @@ -926,6 +929,11 @@ bool CConf::getNextionUTC() const return m_nextionUTC; } +std::string CConf::getNextionDateFormat() const +{ + return m_nextionDateFormat; +} + unsigned char CConf::getOLEDType() const { return m_oledType; diff --git a/Conf.h b/Conf.h index 4a4a973..bb233e9 100644 --- a/Conf.h +++ b/Conf.h @@ -148,6 +148,7 @@ public: unsigned int getNextionBrightness() const; bool getNextionDisplayClock() const; bool getNextionUTC() const; + std::string getNextionDateFormat() const; // The OLED section unsigned char getOLEDType() const; @@ -260,6 +261,7 @@ private: unsigned int m_nextionBrightness; bool m_nextionDisplayClock; bool m_nextionUTC; + std::string m_nextionDateFormat; unsigned char m_oledType; unsigned char m_oledBrightness; diff --git a/MMDVM.ini b/MMDVM.ini index 7762c52..1f74d33 100644 --- a/MMDVM.ini +++ b/MMDVM.ini @@ -124,6 +124,7 @@ Port=/dev/ttyAMA0 Brightness=50 DisplayClock=1 UTC=0 +DateFormat=English [OLED] Type=3 diff --git a/MMDVMHost.cpp b/MMDVMHost.cpp index 2b7d537..930b1bf 100644 --- a/MMDVMHost.cpp +++ b/MMDVMHost.cpp @@ -833,6 +833,7 @@ void CMMDVMHost::createDisplay() unsigned int brightness = m_conf.getNextionBrightness(); bool displayClock = m_conf.getNextionDisplayClock(); bool utc = m_conf.getNextionUTC(); + std::string dateformat = m_conf.getNextionDateFormat(); LogInfo(" Port: %s", port.c_str()); LogInfo(" Brightness: %u", brightness); @@ -840,7 +841,7 @@ void CMMDVMHost::createDisplay() if (displayClock) LogInfo(" Display UTC: %s", utc ? "yes" : "no"); - m_display = new CNextion(m_callsign, dmrid, port, brightness, displayClock, utc); + m_display = new CNextion(m_callsign, dmrid, port, brightness, displayClock, utc, dateformat); #if defined(HD44780) } else if (type == "HD44780") { unsigned int rows = m_conf.getHD44780Rows(); diff --git a/Nextion.cpp b/Nextion.cpp index 4cc22f8..befe667 100644 --- a/Nextion.cpp +++ b/Nextion.cpp @@ -24,7 +24,7 @@ #include #include -CNextion::CNextion(const std::string& callsign, unsigned int dmrid, const std::string& port, unsigned int brightness, bool displayClock, bool utc) : +CNextion::CNextion(const std::string& callsign, unsigned int dmrid, const std::string& port, unsigned int brightness, bool displayClock, bool utc, const std::string& dateformat) : CDisplay(), m_callsign(callsign), m_dmrid(dmrid), @@ -33,6 +33,7 @@ m_brightness(brightness), m_mode(MODE_IDLE), m_displayClock(displayClock), m_utc(utc), +m_dateformat(dateformat), m_clockDisplayTimer(1000U, 0U, 400U) { assert(brightness >= 0U && brightness <= 100U); @@ -241,7 +242,13 @@ void CNextion::clockInt(unsigned int ms) int Sec = Time->tm_sec; char text[50U]; - ::sprintf(text, "t2.txt=\"%02d:%02d:%02d %02d/%02d/%2d\"", Hour, Min, Sec, Day, Month, Year % 100); + if (strcmp(m_dateformat.c_str(), "English") == 0) { + ::sprintf(text, "t2.txt=\"%02d:%02d:%02d %02d/%02d/%2d\"", Hour, Min, Sec, Day, Month, Year % 100); + printf(text, "t2.txt=\"%02d:%02d:%02d %02d/%02d/%2d\"", Hour, Min, Sec, Day, Month, Year % 100); + } else if (strcmp(m_dateformat.c_str(), "German") == 0) { + ::sprintf(text, "t2.txt=\"%02d:%02d:%02d %02d.%02d.%2d\"", Hour, Min, Sec, Day, Month, Year % 100); + printf(text, "t2.txt=\"%02d:%02d:%02d %02d.%02d.%2d\"", Hour, Min, Sec, Day, Month, Year % 100); + } sendCommand(text); m_clockDisplayTimer.start(); // restart the clock display timer diff --git a/Nextion.h b/Nextion.h index 319b23d..0849050 100644 --- a/Nextion.h +++ b/Nextion.h @@ -29,7 +29,7 @@ class CNextion : public CDisplay { public: - CNextion(const std::string& callsign, unsigned int dmrid, const std::string& port, unsigned int brightness, bool displayClock, bool utc); + CNextion(const std::string& callsign, unsigned int dmrid, const std::string& port, unsigned int brightness, bool displayClock, bool utc, const std::string& dateformat); virtual ~CNextion(); virtual bool open(); @@ -60,6 +60,7 @@ private: unsigned char m_mode; bool m_displayClock; bool m_utc; + std::string m_dateformat; CTimer m_clockDisplayTimer; void sendCommand(const char* command);