Add seconds to MAX7219 DisplayClock command

As extra digits are available, may as well use them to allow more accuracy. Also changed the colon/dot to remain illuminated since the seconds fulfill the heartbeat function, and colon/dot serves as just a separator.

TM1637 and TM1638 code is unchanged.
This commit is contained in:
pkkrusty 2022-02-03 21:20:43 +00:00 committed by GitHub
parent 19dc1b620f
commit 6172eff331
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 5 deletions

View File

@ -979,6 +979,7 @@ void TM1637ShowTime()
{
uint8_t hr = RtcTime.hour;
uint8_t mn = RtcTime.minute;
uint8_t sc = RtcTime.second;
// uint8_t hr = 1;
// uint8_t mn = 0;
char z = ' ';
@ -998,16 +999,36 @@ void TM1637ShowTime()
if (hr < 10)
{
if (mn < 10)
snprintf(tm, sizeof(tm), PSTR("%c%d0%d"), z, hr, mn);
{
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
snprintf(tm, sizeof(tm), PSTR("%c%d%d"), z, hr, mn);
{
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)
snprintf(tm, sizeof(tm), PSTR("%d0%d"), hr, mn);
{
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
snprintf(tm, sizeof(tm), PSTR("%d%d"), hr, mn);
{
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);
}
}
if (TM1637 == TM1637Data.display_type)
@ -1035,7 +1056,8 @@ void TM1637ShowTime()
{
for (uint32_t i = 0; i < 4; i++)
{
if ((millis() % 1000) > 500 && (i == 1))
//if ((millis() % 1000) > 500 && (i == 3))
if ((i == 1) || (i == 3))
displayMAX7219ASCIIwDot(i, tm[i]);
else
displayMAX7219ASCII(i, tm[i]);