Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: DigitDisplay mbed
Fork of Arch_Digit_Display by
Revision 1:f45925081128, committed 2014-08-20
- Comitter:
- yihui
- Date:
- Wed Aug 20 08:35:13 2014 +0000
- Parent:
- 0:89330707469d
- Commit message:
- Digital Clock
Changed in this revision
| 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 |
--- a/main.cpp Mon Apr 28 00:59:56 2014 +0000
+++ b/main.cpp Wed Aug 20 08:35:13 2014 +0000
@@ -4,12 +4,40 @@
DigitDisplay display(P1_14, P1_13); // 4-Digit Display connected to UART Grove connector
DigitalOut led(LED1);
-int main() {
- int count = 0;
- while(1) {
- display = count;
- count++;
- led = !led;
- wait(1);
+Ticker ticker;
+volatile uint8_t second = 0;
+volatile uint8_t minute = 0;
+volatile uint8_t hour = 12;
+volatile bool colon_enable = false;
+
+void tick()
+{
+ colon_enable = !colon_enable;
+ display.setColon(colon_enable);
+
+ if (colon_enable) {
+ second++;
+ if (second >= 60) {
+ second = 0;
+ minute++;
+ if (minute >= 60) {
+ minute = 0;
+ hour++;
+ if (hour >= 24) {
+ hour = 0;
+ }
+ }
+
+ display.write(hour * 100 + minute);
+ }
}
}
+
+int main() {
+ display.write(hour * 100 + minute);
+ ticker.attach(tick, 0.5);
+ while(1) {
+ led = !led;
+ wait(0.5);
+ }
+}
--- a/mbed.bld Mon Apr 28 00:59:56 2014 +0000 +++ b/mbed.bld Wed Aug 20 08:35:13 2014 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/6473597d706e \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/9327015d4013 \ No newline at end of file
