From 5e207569228a45668a9ef25703b504c6b748e765 Mon Sep 17 00:00:00 2001 From: pkkrusty <79770016+pkkrusty@users.noreply.github.com> Date: Fri, 4 Feb 2022 19:22:29 +0000 Subject: [PATCH] Replace noob code with pro code for assembling string %02d pads an integer with leading zeros up to 2 digits. Amazing! --- tasmota/xdsp_15_tm1637.ino | 37 ++----------------------------------- 1 file changed, 2 insertions(+), 35 deletions(-) diff --git a/tasmota/xdsp_15_tm1637.ino b/tasmota/xdsp_15_tm1637.ino index 744cf043d..f0497f901 100644 --- a/tasmota/xdsp_15_tm1637.ino +++ b/tasmota/xdsp_15_tm1637.ino @@ -996,41 +996,8 @@ void TM1637ShowTime() } char tm[9]; - if (hr < 10) - { - if (mn < 10) - { - if (sc < 10) - snprintf(tm, sizeof(tm), PSTR("%c%d0%d0%d"), z, hr, mn, sc); - else - snprintf(tm, sizeof(tm), PSTR("%c%d0%d%d"), z, hr, mn, sc); - } - else - { - if (sc < 10) - snprintf(tm, sizeof(tm), PSTR("%c%d%d0%d"), z, hr, mn, sc); - else - snprintf(tm, sizeof(tm), PSTR("%c%d%d%d"), z, hr, mn, sc); - } - } - else - { - if (mn < 10) - { - if (sc < 10) - snprintf(tm, sizeof(tm), PSTR("%d0%d0%d"), hr, mn, sc); - else - snprintf(tm, sizeof(tm), PSTR("%d0%d%d"), hr, mn, sc); - } - else - { - if (sc < 10) - snprintf(tm, sizeof(tm), PSTR("%d%d0%d"), hr, mn, sc); - else - snprintf(tm, sizeof(tm), PSTR("%d%d%d"), hr, mn, sc); - } - } - + snprintf_P(tm, sizeof(tm), PSTR("%c%d%02d%02d"), z, hr, mn, sc); + if (TM1637 == TM1637Data.display_type) { uint8_t rawBytes[1];