lab4
Dependencies: 4DGL-uLCD-SE mbed-rtos mbed
main.cpp@3:8bef7af1ba84, 2015-03-10 (annotated)
- Committer:
- sheldonfernandes2404
- Date:
- Tue Mar 10 03:54:34 2015 +0000
- Revision:
- 3:8bef7af1ba84
- Parent:
- 2:437fc6e9a1c3
- Child:
- 4:403b2f7060c4
added a header file
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sheldonfernandes2404 | 3:8bef7af1ba84 | 1 | #include "head.h" |
sheldonfernandes2404 | 0:fcc91e110a28 | 2 | |
sheldonfernandes2404 | 3:8bef7af1ba84 | 3 | void start(); |
sheldonfernandes2404 | 3:8bef7af1ba84 | 4 | void forward(void const *args); |
sheldonfernandes2404 | 3:8bef7af1ba84 | 5 | void steering(void const *args); |
sheldonfernandes2404 | 3:8bef7af1ba84 | 6 | void obstacle(void const *args); |
sheldonfernandes2404 | 0:fcc91e110a28 | 7 | |
sheldonfernandes2404 | 3:8bef7af1ba84 | 8 | |
sheldonfernandes2404 | 0:fcc91e110a28 | 9 | |
sheldonfernandes2404 | 3:8bef7af1ba84 | 10 | |
sheldonfernandes2404 | 0:fcc91e110a28 | 11 | int main(void) |
sheldonfernandes2404 | 0:fcc91e110a28 | 12 | { |
sheldonfernandes2404 | 3:8bef7af1ba84 | 13 | start(); |
sheldonfernandes2404 | 2:437fc6e9a1c3 | 14 | |
sheldonfernandes2404 | 2:437fc6e9a1c3 | 15 | while(timer); |
sheldonfernandes2404 | 2:437fc6e9a1c3 | 16 | |
sheldonfernandes2404 | 0:fcc91e110a28 | 17 | Thread thread1(steering); |
sheldonfernandes2404 | 0:fcc91e110a28 | 18 | Thread thread2(obstacle); |
sim91 | 1:070b617f00f3 | 19 | Thread thread3(forward); |
sheldonfernandes2404 | 0:fcc91e110a28 | 20 | |
sheldonfernandes2404 | 0:fcc91e110a28 | 21 | while (1) { |
sheldonfernandes2404 | 0:fcc91e110a28 | 22 | stdio_mutex.lock(); |
sheldonfernandes2404 | 0:fcc91e110a28 | 23 | int wait=450*force; |
sheldonfernandes2404 | 0:fcc91e110a28 | 24 | lcd.locate(13,0); |
sheldonfernandes2404 | 0:fcc91e110a28 | 25 | lcd.printf("%d",--count); |
sheldonfernandes2404 | 0:fcc91e110a28 | 26 | |
sheldonfernandes2404 | 0:fcc91e110a28 | 27 | Thread::wait(600-wait); |
sheldonfernandes2404 | 0:fcc91e110a28 | 28 | if(count==0) { |
sim91 | 1:070b617f00f3 | 29 | lcd.cls(); |
sheldonfernandes2404 | 0:fcc91e110a28 | 30 | lcd.locate(1,8); |
sheldonfernandes2404 | 0:fcc91e110a28 | 31 | lcd.printf("Congrats You win!"); |
sheldonfernandes2404 | 0:fcc91e110a28 | 32 | exit(0); |
sheldonfernandes2404 | 0:fcc91e110a28 | 33 | } |
sheldonfernandes2404 | 0:fcc91e110a28 | 34 | stdio_mutex.unlock(); |
sheldonfernandes2404 | 0:fcc91e110a28 | 35 | } |
sheldonfernandes2404 | 0:fcc91e110a28 | 36 | } |