show time and date in DiplayMode 3 and 5

This commit is contained in:
Jeroen Vermeulen - MageHost 2021-01-01 01:37:08 +01:00
parent 8f63663c1e
commit 08d65c69d5
1 changed files with 18 additions and 5 deletions

View File

@ -28,8 +28,9 @@
#define USE_TINY_FONT #define USE_TINY_FONT
#define SSD1331_BLACK 0x0000 // 0, 0, 0 #define SSD1331_BLACK 0x0000 // 0, 0, 0
#define SSD1331_RED 0xF800 // 255, 0, 0
#define SSD1331_WHITE 0xFFFF // 255, 255, 255 #define SSD1331_WHITE 0xFFFF // 255, 255, 255
#define SSD1331_RED 0xF800 // 255, 0, 0
#define SSD1331_BLUE 0x001F // 0, 0, 255
#include <Adafruit_SSD1331.h> #include <Adafruit_SSD1331.h>
#include <SPI.h> #include <SPI.h>
@ -90,7 +91,7 @@ void SSD1331_InitDriver() {
#ifdef USE_DISPLAY_MODES1TO5 #ifdef USE_DISPLAY_MODES1TO5
void SSD1331PrintLog(void) void SSD1331PrintLog(bool withDateTime)
{ {
disp_refresh--; disp_refresh--;
if (!disp_refresh) { if (!disp_refresh) {
@ -103,6 +104,16 @@ void SSD1331PrintLog(void)
renderer->clearDisplay(); renderer->clearDisplay();
renderer->setCursor(0,0); renderer->setCursor(0,0);
if (withDateTime) {
char line[17];
snprintf_P(line, sizeof(line), PSTR("%02d" D_HOUR_MINUTE_SEPARATOR "%02d %02d" D_MONTH_DAY_SEPARATOR "%02d" D_YEAR_MONTH_SEPARATOR "%04d"), RtcTime.hour, RtcTime.minute, RtcTime.day_of_month, RtcTime.month, RtcTime.year); // [12:34 01-02-2018]
renderer->setTextColor(SSD1331_BLUE);
renderer->println(line);
renderer->setTextColor(fg_color);
last_row--;
}
for (byte i = 0; i < last_row; i++) { for (byte i = 0; i < last_row; i++) {
strlcpy(disp_screen_buffer[i], disp_screen_buffer[i +1], disp_screen_buffer_cols); strlcpy(disp_screen_buffer[i], disp_screen_buffer[i +1], disp_screen_buffer_cols);
renderer->println(disp_screen_buffer[i]); renderer->println(disp_screen_buffer[i]);
@ -139,10 +150,12 @@ void SSD1331Refresh(void) // Every second
SSD1331Time(); SSD1331Time();
break; break;
case 2: // Local case 2: // Local
case 3: // Local
case 4: // Mqtt case 4: // Mqtt
case 5: // Mqtt SSD1331PrintLog(false);
SSD1331PrintLog(); break;
case 3: // Local + Time
case 5: // Mqtt + Time
SSD1331PrintLog(true);
break; break;
} }
} }