From 245023f9da9294c3bef2dc97557de17a267ea1e2 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Fri, 19 Mar 2021 12:22:53 +0100 Subject: [PATCH] Add DisplayModes to TM163x displays --- tasmota/xdsp_15_tm1637.ino | 39 +++++++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/tasmota/xdsp_15_tm1637.ino b/tasmota/xdsp_15_tm1637.ino index 10a05c42b..9432ea4c3 100644 --- a/tasmota/xdsp_15_tm1637.ino +++ b/tasmota/xdsp_15_tm1637.ino @@ -867,18 +867,12 @@ bool TM1637PrintLog(void) { if (txt != nullptr) { uint8_t last_row = Settings.display_rows -1; - for (uint32_t i = 0; i < last_row; i++) { - strlcpy(disp_screen_buffer[i], disp_screen_buffer[i +1], disp_screen_buffer_cols); - lcd->setCursor(0, i); // Col 0, Row i - lcd->print(disp_screen_buffer[i +1]); - } strlcpy(disp_screen_buffer[last_row], txt, disp_screen_buffer_cols); DisplayFillScreen(last_row); AddLog(LOG_LEVEL_DEBUG, PSTR(D_LOG_DEBUG "[%s]"), disp_screen_buffer[last_row]); - lcd->setCursor(0, last_row); - lcd->print(disp_screen_buffer[last_row]); + TM1637Print(disp_screen_buffer[last_row]); result = true; } @@ -886,8 +880,8 @@ bool TM1637PrintLog(void) { return result; } */ -void TM1637Time(void) -{ + +void TM1637Time(void) { char line[Settings.display_cols[0] +1]; if (Settings.display_cols[0] >= 8) { @@ -902,18 +896,41 @@ void TM1637Time(void) TM1637Center(line); } +void TM1637Date(void) { + char line[Settings.display_cols[0] +1]; + + if (Settings.display_cols[0] >= 8) { + snprintf_P(line, sizeof(line), PSTR("%02d-%02d-%02d"), RtcTime.day_of_month, RtcTime.month, RtcTime.year -2000); + } + else if (Settings.display_cols[0] >= 6) { + snprintf_P(line, sizeof(line), PSTR("%02d%02d%02d"), RtcTime.day_of_month, RtcTime.month, RtcTime.year -2000); + } + else { + snprintf_P(line, sizeof(line), PSTR("%02d%02d"), RtcTime.day_of_month, RtcTime.month); + } + TM1637Center(line); +} + void TM1637Refresh(void) { // Every second if (Settings.display_mode) { // Mode 0 is User text switch (Settings.display_mode) { case 1: // Time TM1637Time(); break; + case 2: // Date + TM1637Date(); + break; + case 3: // Time + if (TasmotaGlobal.uptime % Settings.display_refresh) { + TM1637Time(); + } else { + TM1637Date(); + } + break; /* - case 2: // Local case 4: // Mqtt TM1637PrintLog(); break; - case 3: // Local case 5: { // Mqtt if (!TM1637PrintLog()) { TM1637Time(); } break;