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.
Diff: main.cpp
- Revision:
- 13:e84e74cba750
- Parent:
- 9:3b8bf3ce2801
diff -r bdb7c703f81e -r e84e74cba750 main.cpp
--- a/main.cpp Thu Oct 24 10:13:17 2019 +0000
+++ b/main.cpp Thu Feb 25 13:04:26 2021 +0800
@@ -4,18 +4,32 @@
DigitalOut led1(LED1);
DigitalOut led2(LED2);
-void led2_thread(void const *args) {
+void led2_thread(DigitalOut *led) {
while (true) {
- led2 = !led2;
+ *led = !*led;
+#if MBED_MAJOR_VERSION >= 6
+ ThisThread::sleep_for(1000);
+#else
Thread::wait(1000);
+#endif
}
}
int main() {
- Thread thread(led2_thread);
-
+ Thread thread;
+
+#ifdef MBED_MAJOR_VERSION
+ printf("Mbed OS version %d.%d.%d\r\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION);
+#endif
+
+ thread.start(callback(led2_thread, &led2));
+
while (true) {
led1 = !led1;
+#if MBED_MAJOR_VERSION >= 6
+ ThisThread::sleep_for(500);
+#else
Thread::wait(500);
+#endif
}
}