I purchased one of these 4 digit 7 segment displays using a TM1637.
I installed the TM1637 display library from the libraries manager and included it:
I am trying to display the time, and I would like, preferably, to display 3 digit times with a colon, but without the leading zero.
I found this great reference online for using the library., and saw the usage for numbers with colons:
showNumberDecEx(number, dots, leading_zeros, length, position)
according to the guide, to have the colon in the center, you would pass
0b01000000 as the
And I figured that if I then want to display, for example, the time
1:36, then my
number parameter would be 136, my
leading_zeros parameter would be
0 (false), my length would be
3 for a 3 digit number, and my position would by
1 to start the number in the zero-indexed second position:
display.showNumberDecEx(136, 0b01000000, false, 3, 1); //displays 5136
But this displayed
5136 with no colon.
I tried a number of other things, including:
display.showNumberDecEx(136, 0b01000000, true, 3, 0); //displays 13:66
display.showNumberDecEx(136, 0b01000000, false, 3, 0); //displays 13:6A
I finally found code from this site, which works to display the time (albeit with a leading zero), but I don't fully understand it:
display.showNumberDecEx(1*100+36, 0x80 >> 1, 1, 4, 0);
I get that 1*100+36 represents number of hours plus minutes, but I don't get the 0x80 >> 1 bit. I'm assuming the rest of it is just saying make it a 4 digit number and add a leading zero.
Can anyone possibly: * help me understand the above working code * tell me an easier way to construct a time so that I can ideally just pass a 3 or 4 digit number and have it automatically render out a clock time with separating colon * tell me why my previous attempts were incorrect