avishorp / TM1637

Arduino library for TM1637 (LED Driver)
GNU Lesser General Public License v3.0
427 stars 218 forks source link

Showing a colon #47

Open XGamerYU opened 5 years ago

XGamerYU commented 5 years ago

Hello folks,

so I'm building a digital clock using the ds1307 RTC module, and everything works fine, except the issue that there's no colon or a dot showing in between hours and minutes. Is there a way that I can solve this. Thanks in advance!

ybaransky commented 5 years ago

If just the Colin, doable. It's in this thread somewhere. But no one succeeded with colon and decimal. In theory yes, but looks like the hardware does not allow it

On Wed, Jan 9, 2019, 11:00 AM XGamerYU <notifications@github.com wrote:

Hello folks,

so I'm building a digital clock using the ds1307 RTC module, and everything works fine, except the issue that there's no colon or a dot showing in between hours and minutes. Is there a way that I can solve this. Thanks in advance!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/avishorp/TM1637/issues/47, or mute the thread https://github.com/notifications/unsubscribe-auth/AKgoWykeGyyQXo6qU2sFP3HvJRTnvOjPks5vBhINgaJpZM4Z3x1M .

XGamerYU commented 5 years ago

How come that I saw numerous pictures around the internet with the same hardware, but having a dot or a colon...

ybaransky commented 5 years ago

Do you believe everything you read on the internet? I msged the manufacturer for the circuit design. Some double talk and apology. So who knows. But it does seem not possible with that driver chip. Look at adafruit, they use a different (more expensive and functional) chip. 7segment definitely supports it, just need a different chip.

On Wed, Jan 9, 2019, 4:25 PM XGamerYU <notifications@github.com wrote:

How come that I saw numerous pictures around the internet with the same hardware, but having a dot or a colon...

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/avishorp/TM1637/issues/47#issuecomment-452824285, or mute the thread https://github.com/notifications/unsubscribe-auth/AKgoW3xTORkT0CZVNU4SyKgUkQrpz5Ztks5vBlD2gaJpZM4Z3x1M .

paullbart commented 5 years ago

what display are you using? I found an issue with the colon not displaying if the preceding zeros were not shown. I managed to fix it by adding one line to the library. See Issue No5 in the list.

jsdevel commented 5 years ago

look at the comments here: https://github.com/avishorp/TM1637/blob/master/TM1637Display.h#L107

for a clock i do something like this:

display_clock.showNumberDecEx(102, 0b01000000, true, 4, 0);

this would display 01:02

scottchiefbaker commented 4 years ago

Did this ever get solved? I'd really like to have full control over each digit and the colon. Ideally I'd like to be able to do this pseudo-code:

setDigit(1, 1);
setDigit(2, 0);
setDigit(COLON, 1);
setDigit(3, 5);
setDigit(4, 8);

To have my display show "10:58"... I've used:

display_clock.showNumberDecEx(1058, 0b11100000, true, 4, 0);

Which works, but the next iteration if I only use three digits:

display_clock.showNumberDecEx(937, 0b11100000, true, 3, 1);

This leaves the "1" in the first position from 10:58 as this call only updates three digits. This is relevant to my real world scenario where I'm writing a countdown timer, or when 12:59 rolls to 1:00 (counting up).

scottchiefbaker commented 4 years ago

I spent a chunk of time today hacking on this issue and came up with this solution:

void show_clock(uint8_t hours, uint8_t minutes) {
    uint8_t d1 = hours   / 10; // Tens digit of hours
    uint8_t d2 = hours   % 10; // Ones digit of hours
    uint8_t d3 = minutes / 10; // Tens digit of minutes
    uint8_t d4 = minutes % 10; // Ones digit of minutes

    /*
    char msg[100] = "";
    snprintf(msg, 100, "Displaying: %d hours %d minutes (%d%d:%d%d)\n", hours, minutes, d1, d2, d3, d4);
    Serial.print(msg);
    */

    uint8_t digits[4];
    digits[0] = display.encodeDigit(d1);
    digits[1] = display.encodeDigit(d2); 
    digits[2] = display.encodeDigit(d3);
    digits[3] = display.encodeDigit(d4);

    // Turn on the colon
    digits[1] |= 128;

    // No leading zero on times like 1:34
    if (!d1) {
        digits[0] = 0; // Off
    }

    display.setSegments(digits, 4, 0);
}

On my board the colon is enabled by or'ing the second digit with 128;

MHz000 commented 1 year ago

@scottchiefbaker capeau! after spending houres searching the net your code solved the problem! Thank you

Peanuts2000 commented 7 months ago

Hi,

On my board the colon is enabled by or'ing the second digit with 128;

Excactly: I have a suggestion to expand the Segment bits by one: in file "TM1637Display.h" add a line 29: "#define SEG_P 0b10000000 // added by Kurt for access point/colon-LEDs"

This is how I access any 8th Bit for Dots or colons on 7-segment LED modules. Regards, Kurt