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: EthernetInterface NTPClient mbed-rtos mbed
Fork of MbedClock by
Revision 11:4d4334d909d3, committed 2016-02-11
- Comitter:
- ismaia
- Date:
- Thu Feb 11 13:42:13 2016 +0000
- Parent:
- 10:d9ed3d95e5eb
- Child:
- 12:bcced6833b8f
- Commit message:
- Thread version RGB blinking
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Feb 11 13:28:37 2016 +0000
+++ b/main.cpp Thu Feb 11 13:42:13 2016 +0000
@@ -8,9 +8,24 @@
EthernetInterface eth;
TCPSocketConnection server;
NTPClient ntp;
-DigitalOut myled(LED2);
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
time_t ctTime;
+
+void thread_func1(void const *args) {
+ while (1) {
+ led1 = !led1;
+ Thread::wait(1000);
+ }
+}
+
+void thread_func2(void const *args) {
+ while (1) {
+ led2 = !led2;
+ Thread::wait(500);
+ }
+}
int main() {
printf("Setting up ethernet interface...\r\n");
@@ -41,11 +56,12 @@
}
eth.disconnect();
ctTime = time(NULL);
+
+ Thread thread1(thread_func1);
+ Thread thread2(thread_func2);
+
while(1) {
- myled = 1;
+ printf("Current time is: %s\r\n", ctime(&ctTime));
wait(1);
- myled = 0;
- wait(1);
- printf("Current time is: %s\r\n", ctime(&ctTime));
}
}
