From 736053e24e4933148bd28b6fb2d3720005de9c1e Mon Sep 17 00:00:00 2001 From: akshay rajput <47478320+axayrajput27@users.noreply.github.com> Date: Sun, 26 Dec 2021 06:59:56 +0530 Subject: [PATCH] Patch to remove preceding zero of hour digit for 7segment usermod (#2445) * Update usermod_seven_segment_reloaded.h * Update usermod_seven_segment_reloaded.h --- .../usermod_seven_segment_reloaded.h | 41 ++++++++++++------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/usermods/seven_segment_display_reloaded/usermod_seven_segment_reloaded.h b/usermods/seven_segment_display_reloaded/usermod_seven_segment_reloaded.h index c4a64886..7b89c8d7 100644 --- a/usermods/seven_segment_display_reloaded/usermod_seven_segment_reloaded.h +++ b/usermods/seven_segment_display_reloaded/usermod_seven_segment_reloaded.h @@ -65,7 +65,8 @@ private: { 1, 0, 1, 1, 1, 1, 1 }, // 6 { 1, 1, 1, 0, 0, 0, 0 }, // 7 { 1, 1, 1, 1, 1, 1, 1 }, // 8 - { 1, 1, 1, 1, 0, 1, 1 } // 9 + { 1, 1, 1, 1, 0, 1, 1 }, // 9 + { 0, 0, 0, 0, 0, 0, 0 } // blank }; //String to reduce flash memory usage @@ -100,39 +101,39 @@ private: switch (umSSDRDisplayMask[index]) { case 'h': timeVar = hourFormat12(localTime); - _showElements(&umSSDRHours, timeVar, 0); + _showElements(&umSSDRHours, timeVar, 0, 1); break; case 'H': timeVar = hour(localTime); - _showElements(&umSSDRHours, timeVar, 0); + _showElements(&umSSDRHours, timeVar, 0, 1); break; case 'k': timeVar = hour(localTime) + 1; - _showElements(&umSSDRHours, timeVar, 0); + _showElements(&umSSDRHours, timeVar, 0, 0); break; case 'm': timeVar = minute(localTime); - _showElements(&umSSDRMinutes, timeVar, 0); + _showElements(&umSSDRMinutes, timeVar, 0, 0); break; case 's': timeVar = second(localTime); - _showElements(&umSSDRSeconds, timeVar, 0); + _showElements(&umSSDRSeconds, timeVar, 0, 0); break; case 'd': timeVar = day(localTime); - _showElements(&umSSDRDays, timeVar, 0); + _showElements(&umSSDRDays, timeVar, 0, 0); break; case 'M': timeVar = month(localTime); - _showElements(&umSSDRMonths, timeVar, 0); + _showElements(&umSSDRMonths, timeVar, 0, 0); break; case 'y': timeVar = second(localTime); - _showElements(&umSSDRYears, timeVar, 0); + _showElements(&umSSDRYears, timeVar, 0, 0); break; case 'Y': timeVar = year(localTime); - _showElements(&umSSDRYears, timeVar, 0); + _showElements(&umSSDRYears, timeVar, 0, 0); break; case ':': if (!colonsDone) { // only call _setColons once as all colons are printed when the first colon is found @@ -148,14 +149,16 @@ private: void _setColons() { if ( umSSDRColonblink ) { if ( second(localTime) % 2 == 0 ) { - _showElements(&umSSDRColons, 0, 1); + _showElements(&umSSDRColons, 0, 1, 0); } } else { - _showElements(&umSSDRColons, 0, 1); + _showElements(&umSSDRColons, 0, 1, 0); } } - void _showElements(String *map, int timevar, bool isColon) { + void _showElements(String *map, int timevar, bool isColon, bool removeZero + +) { if (!(*map).equals("") && !(*map) == NULL) { int length = String(timevar).length(); bool addZero = false; @@ -165,8 +168,16 @@ private: } int timeArr[length]; if(addZero) { - timeArr[1] = 0; - timeArr[0] = timevar; + if(removeZero) + { + timeArr[1] = 10; + timeArr[0] = timevar; + } + else + { + timeArr[1] = 0; + timeArr[0] = timevar; + } } else { int count = 0; while (timevar) {