Buffer working with LCD, Serial and SD Card

Dependencies:   BMP280

Fork of Thread_Communication by BDG

main.cpp

Committer:
benparkes
Date:
2017-12-12
Revision:
0:cb3a5c15b01e
Child:
1:bca9993a0df3

File content as of revision 0:cb3a5c15b01e:

#include "mbed.h"
#include "main.h"




LCD  lcd(PD_15, PF_12, PF_13, PE_9, PF_14, PF_15); 

BMP280 Sensor(D14, D15);
void PrintLCD ();



float LDR_Value;
float temp_Value;
float press_Value;
Thread t1;
Thread t2;

Mutex door;

void PrintLCD () {
    
    int i = 0;
    while(1){
        char DataString[16];
        lcd.Clear();
        lcd.RowSelect(0);
        
        switch (i){
        case 0:
            
            
            sprintf(DataString,"%.4f", LDR_Value);
            lcd.Write("Light Level:");
            i++;
            break;
        case 1:
        
            
            sprintf(DataString,"%2.2f", temp_Value);
            lcd.Write("Temperature:");
            i++;

            break;
        
        case 2:
         
            sprintf(DataString,"%4.2f", press_Value);
            lcd.Write("Pressure:");
            i =0;
            break;
        default:
            i = 0;
            break;
        }
        
        lcd.RowSelect(1);
        lcd.Write(DataString);
        Thread::wait (5000);
        }
}
    

int main() {

    t1.start(PrintLCD);
    
        while(1) {
        Green_int = 1;
        
        
        door.lock();
       
        LDR_Value = LDR_In.read();
        temp_Value = Sensor.getTemperature();
        press_Value = Sensor.getPressure();
        door.unlock();
        
        
        Thread::wait (15000);
        }

}

/*int main(void){

    float temp = 0;
    //float pressure = 0;
    char tempString[16];
    Sensor->initialize();
    temp = Sensor->getTemperature();
    lcd->Clear();
    lcd->RowSelect(0);
    lcd->Write("Temperature:");
    sprintf(tempString,"%f",temp);
    lcd->RowSelect(1);
    lcd->Write(tempString);
    
    }*/