first compiled version
Dependencies: mbed-rtos mbed C12832_lcd LM75B
main.cpp
- Committer:
- robertwharrell
- Date:
- 2014-02-28
- Revision:
- 2:43cd60e0e32f
- Parent:
- 1:83bc9f91d154
- Child:
- 4:6c17983d6192
File content as of revision 2:43cd60e0e32f:
//Rob in the house #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; 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); 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); } } /****************************************************************** * *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); } } /****************************************************************** * *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); int main() { Thread threadLCD(lcdUpdate); Thread threadPOT(readPOT); Thread threadTemp(readTemp); while(1) { } }