first compiled version

Dependencies:   mbed-rtos mbed C12832_lcd LM75B

Revision:
2:43cd60e0e32f
Parent:
1:83bc9f91d154
Child:
4:6c17983d6192
--- a/main.cpp	Wed Feb 26 05:34:37 2014 +0000
+++ b/main.cpp	Fri Feb 28 22:05:13 2014 +0000
@@ -3,38 +3,92 @@
 #include "mbed.h"
 #include "rtos.h"
 
+Serial      pc(USBTX, USBRX);   //To differentiate from LCD functions
+
 AnalogIn pot1(p19);
 Queue<float,10> potReadingQueue;
 
+
+/******************************************************************
+*
+*An LCD thread that updates the LCD based on information 
+*received from other threads via IPC
+*
+*Uses the top 3 lines of the LCD to reflect the pot, the 
+*temperature, and the cookie. This task must use IPC (with 
+*timeout) methods to get data from each of the previous threads
+*
+*******************************************************************/
 void lcdUpdate(void const*){
 while(1){
        osEvent evt = potReadingQueue.get();
         if (evt.status == osEventMail) {
             float *queue = (float*)evt.value.p;
-            printf("\nVoltage: %.2f V\n\r"   , *queue);
-      
+            pc.printf("\nVoltage: %.2f V\n\r"   , *queue);
+            
+            pc.printf("LCD updated");
             Thread::wait(1000);
         }
     }
 }
 
+/******************************************************************
+*
+*A POT thread that reads the pot value in a polling loop 
+*every 10 seconds and sends value to LCD thread via IPC Queue 
+*
+*******************************************************************/
 void readPOT(void const*){    
 while(1){
         float *queue;
         *queue = pot1; 
         potReadingQueue.put(queue);
-     
-    Thread::wait(10000);
+        pc.printf("POT read");
+        Thread::wait(10000);
+    }
+    
+}
+
+/******************************************************************
+*
+*A TEMP thread that read the temperature every 60 seconds 
+*and sends the value to the LCD task via IPC Queue
+*
+*******************************************************************/
+void readTemp(void const*){
+    while(1){
+        pc.printf("TEMP read");
+        Thread::wait(60000);
     }
     
 }
 
-void readTemp(void const*){
-    
+/******************************************************************
+*
+*A SCANF thread that reads in a fortune cookie from user 
+*and sends it to the LCD task via IPC Memory Pool
+*
+*******************************************************************/
+void threadCookie(void const*){
+    //Checks often but low priority?
+    while(1){
+        Thread::wait(1000);
+    }  
 }
 
-void threadCookie(void const*){
-    
+
+/******************************************************************
+*
+*A TOD thread that updates the 4th line of the LCD with time 
+*of day once a minute. It shares the LCD with the LCD thread 
+*using mutual exclusion
+*
+*******************************************************************/
+void threadTOD(void const*){
+        while(1){
+            pc.printf("TOD updated");
+            Thread::wait(60000);
+    } 
 }
 
 DigitalOut myled(LED1);