Replace Thread::wait with wait
Fork of Workshop-1-Example-3 by
main.cpp@1:2c029f8a45c8, 2017-01-05 (annotated)
- Committer:
- amaste01
- Date:
- Thu Jan 05 16:46:34 2017 +0000
- Revision:
- 1:2c029f8a45c8
- Parent:
- 0:04fa7fb0681e
Replace "Thread::wait" with "wait" and change ms to s
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| sarahmarshy | 0:04fa7fb0681e | 1 | #include "mbed.h" |
| sarahmarshy | 0:04fa7fb0681e | 2 | #include "rtos.h" |
| sarahmarshy | 0:04fa7fb0681e | 3 | |
| sarahmarshy | 0:04fa7fb0681e | 4 | DigitalOut led1(LED1); |
| sarahmarshy | 0:04fa7fb0681e | 5 | DigitalOut led2(LED2); |
| sarahmarshy | 0:04fa7fb0681e | 6 | |
| sarahmarshy | 0:04fa7fb0681e | 7 | void led2_thread(void const *args) { |
| sarahmarshy | 0:04fa7fb0681e | 8 | while (true) { |
| sarahmarshy | 0:04fa7fb0681e | 9 | led2 = !led2; |
| amaste01 | 1:2c029f8a45c8 | 10 | wait(1); |
| sarahmarshy | 0:04fa7fb0681e | 11 | } |
| sarahmarshy | 0:04fa7fb0681e | 12 | } |
| sarahmarshy | 0:04fa7fb0681e | 13 | |
| sarahmarshy | 0:04fa7fb0681e | 14 | int main() { |
| sarahmarshy | 0:04fa7fb0681e | 15 | //Create a thread to execute the function led2_thread |
| sarahmarshy | 0:04fa7fb0681e | 16 | Thread thread(led2_thread); |
| sarahmarshy | 0:04fa7fb0681e | 17 | //led2_thread is executing concurrently with main at this point |
| sarahmarshy | 0:04fa7fb0681e | 18 | |
| sarahmarshy | 0:04fa7fb0681e | 19 | while (true) { |
| sarahmarshy | 0:04fa7fb0681e | 20 | led1 = !led1; |
| amaste01 | 1:2c029f8a45c8 | 21 | wait(0.5); |
| sarahmarshy | 0:04fa7fb0681e | 22 | } |
| sarahmarshy | 0:04fa7fb0681e | 23 | } |
