Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to show colon? #9

Open
smartroad opened this issue Apr 7, 2021 · 2 comments
Open

How to show colon? #9

smartroad opened this issue Apr 7, 2021 · 2 comments

Comments

@smartroad
Copy link

smartroad commented Apr 7, 2021

Hi! I have a display from eBay which has the 4 digits and the colon in the middle. I've been reading through but can't figure out how to get the colon to flash. I'm obviously missing something but I don't know what? Any suggestions?

I am trying to make a clock and using the Time library i have done:

display.showNumber(hour(), true, 2,0);
display.showNumber(minute(), true, 2,2);

and would like to have the colon flash between the hour and minute

@jasonacox
Copy link
Owner

You can send the colon as a decimal value 0b01000000 using the showNumberDec() function.

Here is an example minute:second counter. Would love to see your code.

#include <TM1637TinyDisplay.h>

// Useful Time Macros
#define numberOfSeconds(_time_) (_time_ % 60UL)
#define numberOfMinutes(_time_) ((_time_ / 60UL) % 60UL)
#define numberOfHours(_time_) (( _time_% (3600UL * 24L)) / 3600UL)
#define elapsedDays(_time_) ( _time_ / (3600UL * 24L))

#define OFFSET (10UL * 60UL + 55UL) // start at 10m:55s

// Define Digital Pins
#define CLK 3
#define DIO 4

TM1637TinyDisplay display(CLK, DIO);

void setup() {
  display.setBrightness(0x0f);
}

void loop() {
  unsigned long timenow = (millis() / 1000) + OFFSET;
  int days = elapsedDays(timenow);
  int hours = numberOfHours(timenow);
  int minutes = numberOfMinutes(timenow);
  int seconds = numberOfSeconds(timenow);

  if ((seconds % 2) == 0) {  // flash colon every other second
    display.showNumberDec(((minutes * 100) + seconds), 0b01000000, true); // turn on colon
  }
  else {
    display.showNumberDec(((minutes * 100) + seconds), 0b00000000, true); // turn off colon
  }
}

@smartroad
Copy link
Author

smartroad commented Apr 8, 2021

Great, thanks :)

Here is my code:

    if (hour24) display.showNumberDec(hour(), second() % 2 * 0b01000000, true, 2, 0);
    else display.showNumberDec(hourFormat12(), second() % 2 * 0b01000000, false, 2, 0);
    display.showNumber(minute(), true, 2, 2);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants