Digital Clock with Arch and Grove - 4 Digit Display

Dependencies:   DigitDisplay mbed

Fork of DigitDisplay_Clock by Seeed Studio

Files at this revision

API Documentation at this revision

Comitter:
seeed
Date:
Sat Feb 08 05:56:25 2014 +0000
Commit message:
initial

Changed in this revision

DigitDisplay.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 20e070e8ecca DigitDisplay.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DigitDisplay.lib	Sat Feb 08 05:56:25 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/seeed/code/DigitDisplay/#d3173c8bfd48
diff -r 000000000000 -r 20e070e8ecca main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Feb 08 05:56:25 2014 +0000
@@ -0,0 +1,54 @@
+#include "mbed.h"
+#include "DigitDisplay.h"
+
+DigitalOut myled(LED1);
+
+DigitDisplay display(P1_14, P1_13);
+
+Ticker tick;
+
+uint8_t hour   = 20;
+uint8_t minute = 14;
+uint8_t second = 0;
+
+void beat()
+{
+    static uint8_t colon = 0;
+    
+    display.setColon(colon);
+    if (colon) {
+        second++;
+        if (second >= 60) {
+            second = 0;
+            minute++;
+            if (minute >= 60) {
+                minute = 0;
+                
+                hour++;
+                if (hour >= 24) {
+                    hour = 0;
+                }
+                display.write(0, hour / 10);
+                display.write(1, hour % 10);
+            }
+            display.write(2, minute / 10);
+            display.write(3, minute % 10);
+        }
+    }
+    colon = 1 - colon;
+}
+
+int main() {
+    display.write(0, hour / 10);
+    display.write(1, hour % 10);
+    display.write(2, minute / 10);
+    display.write(3, minute % 10);
+    display.setColon(true);
+    tick.attach(&beat, 0.5);
+    while(1) {
+        myled = 1;
+        wait(0.5);
+        myled = 0;
+        wait(0.5);
+    }
+}
diff -r 000000000000 -r 20e070e8ecca mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Feb 08 05:56:25 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file