|
@@ -47,7 +47,7 @@ main(int argc, char** argv)
|
47
|
47
|
int timezone = -7; // Your UTC offset
|
48
|
48
|
time_t rawtime;
|
49
|
49
|
struct tm * gmt;
|
50
|
|
- char myTime[4];
|
|
50
|
+ char myTime[5];
|
51
|
51
|
|
52
|
52
|
fprintf(stdout, "TM1637 Display Example\n");
|
53
|
53
|
signal(SIGINT, sig_handler);
|
|
@@ -62,8 +62,10 @@ main(int argc, char** argv)
|
62
|
62
|
time(&rawtime); // Update raw time
|
63
|
63
|
gmt = gmtime(&rawtime); // Get current time
|
64
|
64
|
|
|
65
|
+ int hour = (gmt) ? gmt->tm_hour : 0;
|
|
66
|
+ int min = (gmt) ? gmt->tm_min : 0;
|
65
|
67
|
// Format and store the time in 24 hour format
|
66
|
|
- sprintf(myTime, "%2d%02d", (gmt->tm_hour + timezone + 24) % 24, gmt->tm_min);
|
|
68
|
+ snprintf(myTime, 5, "%2d%02d", (hour + timezone + 24) % 24, min);
|
67
|
69
|
|
68
|
70
|
myDisplay.write(myTime); // Write to display as string
|
69
|
71
|
myDisplay.setColon(point ^= true); // Toggle the dots on the display
|