mattncsu / Neo7SegmentClock

Clock using WS2812 leds arranged in 7-segment display
16 stars 5 forks source link

12h format #2

Open Mo-albabtain opened 3 years ago

Mo-albabtain commented 3 years ago

Hi there,

thank you for the amazing work. Is it possible to change the time format to display 12h instead of 24h

I tried editing
Serial.println(&timeinfo, "%A, %B %d %Y %H:%M:%S"); to Serial.println(&timeinfo, "%A, %B %d %Y %I:%M:%S"); but no luck. Do you know any other way?

Thanks a lot

mattncsu commented 3 years ago

Hi! That just changes how the time is printed to the terminal, to change what is displayed on the clock, edit the next line:

count=(timeinfo.tm_hour*100+timeinfo.tm_min);

I'd set up an if statement along the lines of if timeinfo.tm_tm_hour>12 then subtract 12 before multiplying by 100. I'd type it all out but I'm on mobile. Hopefully that helps!

Mo-albabtain commented 3 years ago

Thanks for the response. That's what I did and it works fine if (timeinfo.tm_hour>12) { a = timeinfo.tm_hour-12; } count=(a*100+timeinfo.tm_min);

Do you have any idea how to not display zeros in hours like 6:14 instead of 06:14

Thanks again for your help

mattncsu commented 3 years ago

Hey, sorry for the delay... Edit line 224 that controls what is shown when 0 is the first digit on the display: if (c1000 == 0) { seg1G = segCOLOR; }

What that does currently is black out the middle segment to turn an "8" (all segments on) to a "0" (middle segment off). Edit the code to turn off all the segments when 0 is displayed in the first position.