Patch to remove preceding zero of hour digit for 7segment usermod (#2445)

* Update usermod_seven_segment_reloaded.h

* Update usermod_seven_segment_reloaded.h
This commit is contained in:
akshay rajput 2021-12-26 06:59:56 +05:30 committed by GitHub
parent 2c14181051
commit 736053e24e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -65,7 +65,8 @@ private:
{ 1, 0, 1, 1, 1, 1, 1 }, // 6 { 1, 0, 1, 1, 1, 1, 1 }, // 6
{ 1, 1, 1, 0, 0, 0, 0 }, // 7 { 1, 1, 1, 0, 0, 0, 0 }, // 7
{ 1, 1, 1, 1, 1, 1, 1 }, // 8 { 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 //String to reduce flash memory usage
@ -100,39 +101,39 @@ private:
switch (umSSDRDisplayMask[index]) { switch (umSSDRDisplayMask[index]) {
case 'h': case 'h':
timeVar = hourFormat12(localTime); timeVar = hourFormat12(localTime);
_showElements(&umSSDRHours, timeVar, 0); _showElements(&umSSDRHours, timeVar, 0, 1);
break; break;
case 'H': case 'H':
timeVar = hour(localTime); timeVar = hour(localTime);
_showElements(&umSSDRHours, timeVar, 0); _showElements(&umSSDRHours, timeVar, 0, 1);
break; break;
case 'k': case 'k':
timeVar = hour(localTime) + 1; timeVar = hour(localTime) + 1;
_showElements(&umSSDRHours, timeVar, 0); _showElements(&umSSDRHours, timeVar, 0, 0);
break; break;
case 'm': case 'm':
timeVar = minute(localTime); timeVar = minute(localTime);
_showElements(&umSSDRMinutes, timeVar, 0); _showElements(&umSSDRMinutes, timeVar, 0, 0);
break; break;
case 's': case 's':
timeVar = second(localTime); timeVar = second(localTime);
_showElements(&umSSDRSeconds, timeVar, 0); _showElements(&umSSDRSeconds, timeVar, 0, 0);
break; break;
case 'd': case 'd':
timeVar = day(localTime); timeVar = day(localTime);
_showElements(&umSSDRDays, timeVar, 0); _showElements(&umSSDRDays, timeVar, 0, 0);
break; break;
case 'M': case 'M':
timeVar = month(localTime); timeVar = month(localTime);
_showElements(&umSSDRMonths, timeVar, 0); _showElements(&umSSDRMonths, timeVar, 0, 0);
break; break;
case 'y': case 'y':
timeVar = second(localTime); timeVar = second(localTime);
_showElements(&umSSDRYears, timeVar, 0); _showElements(&umSSDRYears, timeVar, 0, 0);
break; break;
case 'Y': case 'Y':
timeVar = year(localTime); timeVar = year(localTime);
_showElements(&umSSDRYears, timeVar, 0); _showElements(&umSSDRYears, timeVar, 0, 0);
break; break;
case ':': case ':':
if (!colonsDone) { // only call _setColons once as all colons are printed when the first colon is found if (!colonsDone) { // only call _setColons once as all colons are printed when the first colon is found
@ -148,14 +149,16 @@ private:
void _setColons() { void _setColons() {
if ( umSSDRColonblink ) { if ( umSSDRColonblink ) {
if ( second(localTime) % 2 == 0 ) { if ( second(localTime) % 2 == 0 ) {
_showElements(&umSSDRColons, 0, 1); _showElements(&umSSDRColons, 0, 1, 0);
} }
} else { } 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) { if (!(*map).equals("") && !(*map) == NULL) {
int length = String(timevar).length(); int length = String(timevar).length();
bool addZero = false; bool addZero = false;
@ -165,8 +168,16 @@ private:
} }
int timeArr[length]; int timeArr[length];
if(addZero) { if(addZero) {
timeArr[1] = 0; if(removeZero)
timeArr[0] = timevar; {
timeArr[1] = 10;
timeArr[0] = timevar;
}
else
{
timeArr[1] = 0;
timeArr[0] = timevar;
}
} else { } else {
int count = 0; int count = 0;
while (timevar) { while (timevar) {