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: TextLCD mbed-rtos mbed
Diff: main.cpp
- Revision:
- 1:38e744366b97
- Parent:
- 0:c204b3ecd227
- Child:
- 2:91cb258f9745
--- a/main.cpp Fri Oct 03 19:17:39 2014 +0000
+++ b/main.cpp Fri Oct 03 19:26:13 2014 +0000
@@ -21,9 +21,9 @@
int main() {
Thread thread_display(update_display);
- //Thread thread_mm(update_mm);
- //RtosTimer thread_ss(update_ss);
- //RtosTimer thread_MM(update_MM);
+ Thread thread_mm(update_mm);
+ Thread thread_ss(update_ss);
+ Thread thread_MM(update_MM);
while (true) {
@@ -33,46 +33,51 @@
void update_display(void const *args) {
while (1) {
lcd.printf("%d%d:%d%d:%d%d\n\n", MM[1], MM[0],ss[1],ss[0],mm[1],mm[0]);
- Thread::wait(1000);
+ Thread::wait(10);
}
}
void update_mm(void const *args) {
- mm[0]++;
- if (mm[0] >= 10) {
- mm[0] = 0;
- mm[1]++;
+ while (1) {
+ Thread::wait(10);
+ mm[0]++;
+ if (mm[0] >= 10) {
+ mm[0] = 0;
+ mm[1]++;
+ }
+ if (mm[1] >= 10) {
+ mm[0] = 0;
+ mm[1] = 0;
+ }
}
- if (mm[1] >= 10) {
- mm[0] = 0;
- mm[1] = 0;
- }
- wait(10);
}
-/*
+
void update_ss(void const *args) {
- ss[0]++;
- if (ss[0] >= 10) {
- ss[0] = 0;
- ss[1]++;
+ while (1) {
+ Thread::wait(1000);
+ ss[0]++;
+ if (ss[0] >= 10) {
+ ss[0] = 0;
+ ss[1]++;
+ }
+ if (ss[1] >= 6) {
+ ss[0] = 0;
+ ss[1] = 0;
+ }
}
- if (ss[1] >= 6) {
- ss[0] = 0;
- ss[1] = 0;
- }
- Thread::wait(100);
}
void update_MM(void const *args) {
+ while (1) {
+ Thread::wait(60000);
MM[0]++;
- if (MM[0] >= 10) {
- MM[0] = 0;
- MM[1]++;
+ if (MM[0] >= 10) {
+ MM[0] = 0;
+ MM[1]++;
+ }
+ if (MM[1] >= 6) {
+ MM[0] = 0;
+ MM[1] = 0;
+ }
}
- if (MM[1] >= 6) {
- MM[0] = 0;
- MM[1] = 0;
- }
- Thread::wait(60000);
}
-*/
\ No newline at end of file