Make it possible to display time without explicit leading zeroes
This commit is contained in:
@@ -60,7 +60,7 @@ void setup()
|
||||
bool updateWithDelays = false; // Default. Recommended
|
||||
/* without it there is visual bug at 0 o'clock, and in current version of
|
||||
* SevSeg' setChars() does not dots at all */
|
||||
bool leadingZeros = true;
|
||||
bool leadingZeros = false;
|
||||
|
||||
Display.begin(hardwareConfig, numDigits, digitPins, segmentPins,
|
||||
resistorsOnSegments, updateWithDelays, leadingZeros);
|
||||
@@ -89,6 +89,8 @@ void setup()
|
||||
void loop()
|
||||
{
|
||||
unsigned long currentMillis = millis();
|
||||
char str[4];
|
||||
float d;
|
||||
|
||||
if (currentMillis - previousMillis >= interval)
|
||||
{
|
||||
@@ -125,11 +127,32 @@ void loop()
|
||||
clock.getTime();
|
||||
|
||||
// make blinking dot
|
||||
if (dot == true) {
|
||||
if (clock.hour > 0)
|
||||
{
|
||||
if (dot == true)
|
||||
{
|
||||
Display.setNumber((clock.hour * 100 + clock.minute), 2);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
Display.setNumber((clock.hour * 100 + clock.minute));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* 0 o'clock is an exception, we dont want to see "00.00", we want see
|
||||
* "0.00" or "0 00", so we have to use this "hack" */
|
||||
if (dot == true)
|
||||
{
|
||||
d = float(clock.minute) / 100;
|
||||
Display.setNumber(d, 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(str, "%2d%02d", clock.hour, clock.minute);
|
||||
Display.setChars(str);
|
||||
}
|
||||
}
|
||||
|
||||
Display.refreshDisplay();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user