first compiled version

Dependencies:   mbed-rtos mbed C12832_lcd LM75B

Files at this revision

API Documentation at this revision

Comitter:
nleoni
Date:
Tue Mar 11 05:40:23 2014 +0000
Parent:
6:45c3ad45a252
Parent:
7:4992146d9872
Child:
9:f40c7c08d1c2
Commit message:
Added _DEBUGMODE precompiler definition to easily turn on/off diagnostic strings printed to terminal

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
main.cpp.orig Show diff for this revision Revisions of this file
--- a/main.cpp	Mon Mar 10 20:32:26 2014 +0000
+++ b/main.cpp	Tue Mar 11 05:40:23 2014 +0000
@@ -1,3 +1,8 @@
+//LAB 6: RTOS AND IPC
+//WRITTEN BY: ROBERT HARRELL AND NAPOLEON LEONI
+
+
+//IPC: INTER PROGRAMMER COMMUNICATION....
 //Rob I updated the LCD update and read pot thread and they are working
 //One key issues was adding timeout for the put and get methods of the queue
 //Maybe you can work on the TOD thread and MUTEX (you'll need to add it to the 
@@ -7,7 +12,7 @@
 //the pot values in the queue is asynchronous you need a buffer to keep the values
 //and this is provided by the MemoryPool.
 
-//I also merged your changes with mine.....temproarily commented out the pc.printf meessage for pot read.
+//I also merged your changes with mine.....temproarily commented out the pc.printf meessage for pot read. 3/4/14
 
 
 #include "mbed.h"
@@ -16,6 +21,7 @@
 #include "LM75B.h"
 #include <string>
 
+//#define _DEBUGMODE  //Uncomment to enter debug mode which prints some diagnostic strings to the terminal
 #define BUFFER 17
 #define COOKIEQUEUE 30
 
@@ -89,7 +95,9 @@
         float *queue = potReadingBuffer.alloc();
         *queue = pot1; 
         potReadingQueue.put(queue,1200);
+        #ifdef _DEBUGMODE
         pc.printf("POT read");
+        #endif
         Thread::wait(10000);
     }
     
--- a/main.cpp.orig	Mon Mar 10 20:32:26 2014 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,107 +0,0 @@
-//Rob I updated the LCD update and read pot thread and they are working
-//One key issues was adding timeout for the put and get methods of the queue
-//Maybe you can work on the TOD thread and MUTEX (you'll need to add it to the 
-//LCD thread and I will finish the scan thread, sounds like Plan?? :-)
-//In the end I had to add the memory pool combined with the queue as otherwise
-//the queues just keep pointers to data and being that the putting and getting of
-//the pot values in the queue is asynchronous you need a buffer to keep the values
-//and this is provided by the MemoryPool.
-
-
-#include "mbed.h"
-#include "rtos.h"
-#include "C12832_lcd.h"
-#include <string>
-
-#define BUFFER 17
-#define COOKIEQUEUE 30
-
-C12832_LCD lcd;
-Serial pc(USBTX, USBRX); // tx, rx
-
-AnalogIn pot1(p19);
-MemoryPool<float, 10> potReadingBuffer;
-Queue<float,10> potReadingQueue;
-
-MemoryPool<char[BUFFER], COOKIEQUEUE> cookieReadingBuffer;
-Queue<char[BUFFER],COOKIEQUEUE> cookieReadingQueue;
-
-void lcdUpdate(void const*){
-while(1){
-       osEvent evtPot = potReadingQueue.get(1200);
-        if (evtPot.status == osEventMessage) {
-            float *queuePot = (float*)evtPot.value.p;
-            lcd.locate(0,3);
-            lcd.printf("Voltage: %.2f V", *queuePot);
-            potReadingBuffer.free(queuePot);      
-        }
-       osEvent evtCookie = cookieReadingQueue.get(1200);
-        if (evtCookie.status == osEventMessage) {
-            char (*queueCookie)[BUFFER] = (char (*)[BUFFER])evtCookie.value.p;
-            lcd.locate(0,15);
-            string str(*queueCookie);
-            lcd.printf("F.Cookie: %s", str);    
-            cookieReadingBuffer.free(queueCookie);      
-        }
-        Thread::wait(1000);
-    }
-}
-
-void readPOT(void const*){    
-while(1){
-        float *queue = potReadingBuffer.alloc();
-        *queue = pot1; 
-        potReadingQueue.put(queue,1200);
-     
-    Thread::wait(10000);
-    }
-    
-}
-
-
-
-void readTemp(void const*){
-    
-}
-
-void readCookie(void const*){
-    pc.printf(">Enter your fortune cookie\n>");
-    char (*ptrBuffer)[BUFFER] = cookieReadingBuffer.alloc();
-    char *ptrChar;
-    ptrChar=*ptrBuffer;
-    while(1){
-        if(pc.readable()){
-            *ptrChar=pc.getc();
-            pc.putc(*ptrChar);
-            if((*ptrChar=='\n') || ((ptrChar-*ptrBuffer)>=(BUFFER-1)) ){
-                   if((ptrChar-*ptrBuffer)>=(BUFFER-1)) *++ptrChar='\n';
-                   while((ptrChar-*ptrBuffer)<=(BUFFER-1)){
-                       *ptrChar++=' ';
-                    }
-                   *ptrChar='\0';
-                   cookieReadingQueue.put(ptrBuffer,500);
-                   pc.printf(">Enter your fortune cookie\n>");
-                   ptrChar=*ptrBuffer;
-            } else {
-                ptrChar++;
-            }
-        }
-    Thread::wait(10);
-    }
-}
-
-DigitalOut myled(LED1);
-
-int main() {
-lcd.cls();
-
-Thread threadLCD(lcdUpdate);
-Thread threadPOT(readPOT);
-Thread threadTemp(readTemp);
-Thread threadCookie(readCookie);
-
-    while(1) {
-        Thread::wait(250);       
-        
-    }
-}