Add dot as date separator

This commit is contained in:
phl0
2016-06-22 11:51:41 +02:00
parent 768e3efcad
commit 2bd75c1cff
6 changed files with 24 additions and 4 deletions

View File

@@ -139,6 +139,7 @@ m_nextionPort("/dev/ttyAMA0"),
m_nextionBrightness(50U), m_nextionBrightness(50U),
m_nextionDisplayClock(false), m_nextionDisplayClock(false),
m_nextionUTC(false), m_nextionUTC(false),
m_nextionDateFormat("English"),
m_oledType(3), m_oledType(3),
m_oledBrightness(0), m_oledBrightness(0),
m_oledInvert(0) m_oledInvert(0)
@@ -461,6 +462,8 @@ bool CConf::read()
m_nextionDisplayClock = ::atoi(value) == 1; m_nextionDisplayClock = ::atoi(value) == 1;
else if (::strcmp(key, "UTC") == 0) else if (::strcmp(key, "UTC") == 0)
m_nextionUTC = ::atoi(value) == 1; m_nextionUTC = ::atoi(value) == 1;
else if (::strcmp(key, "DateFormat") == 0)
m_nextionDateFormat = value;
} else if (section == SECTION_OLED) { } else if (section == SECTION_OLED) {
if (::strcmp(key, "Type") == 0) if (::strcmp(key, "Type") == 0)
m_oledType = (unsigned char)::atoi(value); m_oledType = (unsigned char)::atoi(value);
@@ -926,6 +929,11 @@ bool CConf::getNextionUTC() const
return m_nextionUTC; return m_nextionUTC;
} }
std::string CConf::getNextionDateFormat() const
{
return m_nextionDateFormat;
}
unsigned char CConf::getOLEDType() const unsigned char CConf::getOLEDType() const
{ {
return m_oledType; return m_oledType;

2
Conf.h
View File

@@ -148,6 +148,7 @@ public:
unsigned int getNextionBrightness() const; unsigned int getNextionBrightness() const;
bool getNextionDisplayClock() const; bool getNextionDisplayClock() const;
bool getNextionUTC() const; bool getNextionUTC() const;
std::string getNextionDateFormat() const;
// The OLED section // The OLED section
unsigned char getOLEDType() const; unsigned char getOLEDType() const;
@@ -260,6 +261,7 @@ private:
unsigned int m_nextionBrightness; unsigned int m_nextionBrightness;
bool m_nextionDisplayClock; bool m_nextionDisplayClock;
bool m_nextionUTC; bool m_nextionUTC;
std::string m_nextionDateFormat;
unsigned char m_oledType; unsigned char m_oledType;
unsigned char m_oledBrightness; unsigned char m_oledBrightness;

View File

@@ -124,6 +124,7 @@ Port=/dev/ttyAMA0
Brightness=50 Brightness=50
DisplayClock=1 DisplayClock=1
UTC=0 UTC=0
DateFormat=English
[OLED] [OLED]
Type=3 Type=3

View File

@@ -833,6 +833,7 @@ void CMMDVMHost::createDisplay()
unsigned int brightness = m_conf.getNextionBrightness(); unsigned int brightness = m_conf.getNextionBrightness();
bool displayClock = m_conf.getNextionDisplayClock(); bool displayClock = m_conf.getNextionDisplayClock();
bool utc = m_conf.getNextionUTC(); bool utc = m_conf.getNextionUTC();
std::string dateformat = m_conf.getNextionDateFormat();
LogInfo(" Port: %s", port.c_str()); LogInfo(" Port: %s", port.c_str());
LogInfo(" Brightness: %u", brightness); LogInfo(" Brightness: %u", brightness);
@@ -840,7 +841,7 @@ void CMMDVMHost::createDisplay()
if (displayClock) if (displayClock)
LogInfo(" Display UTC: %s", utc ? "yes" : "no"); 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) #if defined(HD44780)
} else if (type == "HD44780") { } else if (type == "HD44780") {
unsigned int rows = m_conf.getHD44780Rows(); unsigned int rows = m_conf.getHD44780Rows();

View File

@@ -24,7 +24,7 @@
#include <cstring> #include <cstring>
#include <ctime> #include <ctime>
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(), CDisplay(),
m_callsign(callsign), m_callsign(callsign),
m_dmrid(dmrid), m_dmrid(dmrid),
@@ -33,6 +33,7 @@ m_brightness(brightness),
m_mode(MODE_IDLE), m_mode(MODE_IDLE),
m_displayClock(displayClock), m_displayClock(displayClock),
m_utc(utc), m_utc(utc),
m_dateformat(dateformat),
m_clockDisplayTimer(1000U, 0U, 400U) m_clockDisplayTimer(1000U, 0U, 400U)
{ {
assert(brightness >= 0U && brightness <= 100U); assert(brightness >= 0U && brightness <= 100U);
@@ -241,7 +242,13 @@ void CNextion::clockInt(unsigned int ms)
int Sec = Time->tm_sec; int Sec = Time->tm_sec;
char text[50U]; 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); sendCommand(text);
m_clockDisplayTimer.start(); // restart the clock display timer m_clockDisplayTimer.start(); // restart the clock display timer

View File

@@ -29,7 +29,7 @@
class CNextion : public CDisplay class CNextion : public CDisplay
{ {
public: 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 ~CNextion();
virtual bool open(); virtual bool open();
@@ -60,6 +60,7 @@ private:
unsigned char m_mode; unsigned char m_mode;
bool m_displayClock; bool m_displayClock;
bool m_utc; bool m_utc;
std::string m_dateformat;
CTimer m_clockDisplayTimer; CTimer m_clockDisplayTimer;
void sendCommand(const char* command); void sendCommand(const char* command);