Threads

Dependencies:   mbed mbed-rtos C12832_lcd LCD_fonts

Files at this revision

API Documentation at this revision

Comitter:
mariana_batalim
Date:
Sat Jun 20 10:44:28 2020 +0000
Parent:
3:3ec443c0842a
Child:
5:9f4b49b1adbf
Commit message:
T00215868_Threads

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Dec 05 08:06:20 2012 +0000
+++ b/main.cpp	Sat Jun 20 10:44:28 2020 +0000
@@ -10,15 +10,31 @@
 #include "stdio.h"
 #include "C12832_lcd.h"
 
-// LCD object
+BusIn joy(p15,p12,p13,p16);
+DigitalIn fire(p14);
+BusOut leds(LED1,LED2,LED3,LED4);
 C12832_LCD LCD;
-
 AnalogIn Pot1(p19);
 AnalogIn Pot2(p20);
+Mutex lcd_mutex;
 
 
-// mutex to make the lcd lib thread save
-Mutex lcd_mutex;
+// Thread 0
+// LEDs controlled by JOYSTICK
+void thread0(void const *args)
+{
+    int j; 
+    while(true) {       // thread loop
+        if (fire) {
+            leds=0xf;
+        } else {
+            leds=joy;
+        }
+        wait(0.1);
+    }
+}
+
+
 
 // Thread 1
 // print counter into first line and wait for 1 s
@@ -101,6 +117,7 @@
     int j;
     LCD.cls();
   
+    Thread t0(thread0); //start thread0 
     Thread t1(thread1); //start thread1
     Thread t2(thread2); //start thread2
     Thread t3(thread3); //start thread3