bremme / arduino-tm1637

Arduino library for using a 4 digit seven segment display with TM1636 or TM1637 driver IC
GNU General Public License v2.0
164 stars 62 forks source link

Blinking on seconds #11

Closed Its-Matra closed 6 years ago

Its-Matra commented 7 years ago

Am I just being really dumb or can you not get the colon to blink on seconds? It blinks every minute but not seconds (using the clock example and examined SevenSegmentTM1637.h and SevenSegmentExtended.h but can't find how to get the damn thing to blink every second).

I also noticed an error in the clock example too, when hitting 23:59 the whole thing will just freeze, you need to add an hour reset too.

  for ( ; hours < 24; hours++) {                // count hours   up to 24
    for ( ; minutes < 60; minutes++) {          // count minutes up to 59
      display.printTime(hours, minutes, true);  // display time
      delay(60000 / clockSpeed);                // clock delay ms
    }
    minutes = 0;                                // reset minutes
  }
  **hours = 0;**
}
AJMartel commented 6 years ago

Thanks Its-Matra for the "hours" fix. I got it to work only after moving:

 byte hours    = 23;            // initialize hours
 byte minutes  = 59;          // initialize minutes

into global variables under:

 const unsigned int clockSpeed = 1;    // speed up clock for demo

I am also looking to get the colon to blink every second

bremme commented 6 years ago

@Its-Matra Damn, this is a late reply. Finally found some time to reply to some issues. Just tested my clock example again ExtClock.ino and I think it works as expected: run the clock at high speed from 14:39 to 23:59 and reset. I you remove the hour and minute initialization lines from the demo, you have to reset the hours yourself like you found out. You probably already fixed this, but here is an example to show HH:MM and blink every second:

void loop() {

  byte hours    = 14;                           // initialize hours
  byte minutes  = 39;                           // initialize minutes
  byte seconds  = 0;                            // initialize seconds

  for ( ; hours < 24; hours++) {                // count hours   up to 24
    for ( ; minutes < 60; minutes++) {          // count minutes up to 59
      for ( ; seconds < 60; seconds++) {
        display.printTime(hours, minutes, true);  // display time
        delay(1000);
      }
      seconds = 0;
    };
    minutes = 0;                                // reset minutes
  };
};

Hope this helps!