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
|
bool updateWithDelays = false; // Default. Recommended
|
||||||
/* without it there is visual bug at 0 o'clock, and in current version of
|
/* without it there is visual bug at 0 o'clock, and in current version of
|
||||||
* SevSeg' setChars() does not dots at all */
|
* SevSeg' setChars() does not dots at all */
|
||||||
bool leadingZeros = true;
|
bool leadingZeros = false;
|
||||||
|
|
||||||
Display.begin(hardwareConfig, numDigits, digitPins, segmentPins,
|
Display.begin(hardwareConfig, numDigits, digitPins, segmentPins,
|
||||||
resistorsOnSegments, updateWithDelays, leadingZeros);
|
resistorsOnSegments, updateWithDelays, leadingZeros);
|
||||||
@@ -89,7 +89,9 @@ void setup()
|
|||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
unsigned long currentMillis = millis();
|
unsigned long currentMillis = millis();
|
||||||
|
char str[4];
|
||||||
|
float d;
|
||||||
|
|
||||||
if (currentMillis - previousMillis >= interval)
|
if (currentMillis - previousMillis >= interval)
|
||||||
{
|
{
|
||||||
previousMillis = currentMillis;
|
previousMillis = currentMillis;
|
||||||
@@ -125,10 +127,31 @@ void loop()
|
|||||||
clock.getTime();
|
clock.getTime();
|
||||||
|
|
||||||
// make blinking dot
|
// make blinking dot
|
||||||
if (dot == true) {
|
if (clock.hour > 0)
|
||||||
Display.setNumber((clock.hour * 100 + clock.minute), 2);
|
{
|
||||||
} else {
|
if (dot == true)
|
||||||
Display.setNumber((clock.hour * 100 + clock.minute));
|
{
|
||||||
|
Display.setNumber((clock.hour * 100 + clock.minute), 2);
|
||||||
|
}
|
||||||
|
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();
|
Display.refreshDisplay();
|
||||||
|
|||||||
Reference in New Issue
Block a user