Threads_Labs

Dependencies:   mbed mbed-rtos C12832_lcd LCD_fonts

Files at this revision

API Documentation at this revision

Comitter:
chbyrne79
Date:
Fri Aug 07 11:06:08 2020 +0000
Parent:
3:3ec443c0842a
Commit message:
Threads_Labs

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 3ec443c0842a -r 4df6ff15b6dc main.cpp
--- a/main.cpp	Wed Dec 05 08:06:20 2012 +0000
+++ b/main.cpp	Fri Aug 07 11:06:08 2020 +0000
@@ -10,6 +10,12 @@
 #include "stdio.h"
 #include "C12832_lcd.h"
 
+//Joystick
+BusIn joy(p15,p12,p13,p16);
+DigitalIn fire(p14);
+BusOut leds(LED1,LED2,LED3,LED4);
+
+
 // LCD object
 C12832_LCD LCD;
 
@@ -20,6 +26,7 @@
 // mutex to make the lcd lib thread save
 Mutex lcd_mutex;
 
+
 // Thread 1
 // print counter into first line and wait for 1 s
 void thread1(void const *args)
@@ -94,6 +101,22 @@
 }
 }
 
+// Thread 5
+// Use the joystick to control the LEDs
+
+void thread5(void const *args)
+{
+
+    while(1) {
+        if (fire) {
+            leds=0xf;
+        } else {
+            leds=joy;
+        }
+        Thread::wait(0.1);
+    }
+}
+
 
 // print the actual contrast 
 int main()
@@ -105,6 +128,7 @@
     Thread t2(thread2); //start thread2
     Thread t3(thread3); //start thread3
     Thread t4(thread4); //start thread4
+    Thread t5(thread5); //start thread4
 
     while(true) {       // main is the next thread
         lcd_mutex.lock();