Merge pull request #104 from phl0/germandate

Add American Date Format
This commit is contained in:
Jonathan Naylor 2016-06-22 13:52:06 +01:00 committed by GitHub
commit 1aa7ca537d
4 changed files with 10 additions and 5 deletions

View file

@ -135,12 +135,12 @@ m_hd44780PWMBright(),
m_hd44780PWMDim(), m_hd44780PWMDim(),
m_hd44780DisplayClock(false), m_hd44780DisplayClock(false),
m_hd44780UTC(false), m_hd44780UTC(false),
m_hd44780DateFormat("English"), m_hd44780DateFormat("British"),
m_nextionPort("/dev/ttyAMA0"), 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_nextionDateFormat("British"),
m_oledType(3), m_oledType(3),
m_oledBrightness(0), m_oledBrightness(0),
m_oledInvert(0) m_oledInvert(0)

View file

@ -735,10 +735,12 @@ void CHD44780::clockInt(unsigned int ms)
if (m_cols != 16U && m_rows != 2U) { if (m_cols != 16U && m_rows != 2U) {
::lcdPosition(m_fd, (m_cols - 8) / 2, m_rows == 2 ? 0 : 1); ::lcdPosition(m_fd, (m_cols - 8) / 2, m_rows == 2 ? 0 : 1);
if (strcmp(m_dateformat.c_str(), "English") == 0) { if (strcmp(m_dateformat.c_str(), "British") == 0) {
::lcdPrintf(m_fd, "%02d/%02d/%2d", Day, Month, Year%100); ::lcdPrintf(m_fd, "%02d/%02d/%2d", Day, Month, Year%100);
} else if (strcmp(m_dateformat.c_str(), "German") == 0) { } else if (strcmp(m_dateformat.c_str(), "German") == 0) {
::lcdPrintf(m_fd, "%02d.%02d.%2d", Day, Month, Year%100); ::lcdPrintf(m_fd, "%02d.%02d.%2d", Day, Month, Year%100);
} else if (strcmp(m_dateformat.c_str(), "American") == 0) {
::lcdPrintf(m_fd, "%02d/%02d/%2d", Month, Day, Year%100);
} }
} }
m_clockDisplayTimer.start(); m_clockDisplayTimer.start();

View file

@ -118,13 +118,14 @@ PWMBright=100
PWMDim=16 PWMDim=16
DisplayClock=1 DisplayClock=1
UTC=0 UTC=0
DateFormat=British
[Nextion] [Nextion]
Port=/dev/ttyAMA0 Port=/dev/ttyAMA0
Brightness=50 Brightness=50
DisplayClock=1 DisplayClock=1
UTC=0 UTC=0
DateFormat=English DateFormat=British
[OLED] [OLED]
Type=3 Type=3

View file

@ -242,10 +242,12 @@ void CNextion::clockInt(unsigned int ms)
int Sec = Time->tm_sec; int Sec = Time->tm_sec;
char text[50U]; char text[50U];
if (strcmp(m_dateformat.c_str(), "English") == 0) { if (strcmp(m_dateformat.c_str(), "British") == 0) {
::sprintf(text, "t2.txt=\"%02d:%02d:%02d %02d/%02d/%2d\"", Hour, Min, Sec, Day, Month, Year % 100); ::sprintf(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) { } 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); ::sprintf(text, "t2.txt=\"%02d:%02d:%02d %02d.%02d.%2d\"", Hour, Min, Sec, Day, Month, Year % 100);
} else if (strcmp(m_dateformat.c_str(), "American") == 0) {
::sprintf(text, "t2.txt=\"%02d:%02d:%02d %02d/%02d/%2d\"", Hour, Min, Sec, Month, Day, Year % 100);
} }
sendCommand(text); sendCommand(text);