V4
Dependencies: BMP280
Fork of Thread_Communication_V3 by
Diff: main.cpp
- Revision:
- 14:7c4d87dfc388
- Parent:
- 13:089f3adb3813
- Child:
- 15:864d936b51cf
--- a/main.cpp Fri Jan 05 19:47:33 2018 +0000 +++ b/main.cpp Sat Jan 06 12:22:12 2018 +0000 @@ -18,6 +18,7 @@ void circBuff(); void writeRemove_SD(); void Network1(); +void LCD_timerISR(); // USER_BUTTON ISRs (Debounce) @@ -28,7 +29,7 @@ // Tickers & Timeouts Timeout userButtonTimeout; // FOR debouncing User Switch Ticker read; // ***Sets sampling period!*** (ISR Signals sampling Thread) - +Ticker refresh; /* LOCKS */ Mutex DataBuffer; Mutex dataLock; @@ -46,6 +47,7 @@ volatile char TIME[21]; volatile double sampleTime = 15.0; +//int LCD_refresh = 1; // int to hold current switch state int userButtonState = FallingEdge; @@ -94,6 +96,7 @@ userButton.rise(&userButtonRise); read.attach(&readISR, sampleTime); + refresh.attach(&LCD_timerISR, LCD_REFRESH); while (1) { Yellow_ext = ON; @@ -184,61 +187,88 @@ /*--------------------------------------------------------------------*/ /*--------------------------------LCD---------------------------------*/ +void LCD_timerISR () { + _PrintLCD.signal_set(LCD_READY); + } + void PrintLCD () { int i = 0; + int j = 4; + char lightString[16]; + char tempString[16]; + char pressString[16]; + char lcd_TIME[21]; + while(1){ - char lightString[16]; - char tempString[16]; - char pressString[16]; + + lcd.RowSelect(3); + + + if (j == 4) { - lcd.Clear(); - lcd.RowSelect(0); - - switch (i){ - case 0:{ - osEvent evt = mail_box.get(); - - if (evt.status == osEventMail) { - mail_t *mail = (mail_t*)evt.value.p; - - sprintf(lightString,"%.4f", mail->LDR_Value); - sprintf(tempString,"%2.2f", mail->temp_Value); - sprintf(pressString,"%4.2f", mail->press_Value); - - mail_box.free(mail); + lcd.Clear(); + lcd.RowSelect(0); + switch (i) { + case 0: { + osEvent evt = mail_box.get(); + + if (evt.status == osEventMail) { + mail_t *mail = (mail_t*)evt.value.p; + + sprintf(lightString,"%.4f", mail->LDR_Value); + sprintf(tempString,"%2.2f", mail->temp_Value); + sprintf(pressString,"%4.2f", mail->press_Value); + + mail_box.free(mail); + } + + lcd.Write("Light:"); + lcd.RowSelect(1); + lcd.Write(lightString); + i++; + j = 0; + break; } - - lcd.Write("Light:"); - lcd.RowSelect(1); - lcd.Write(lightString); - i++; - break; - } - case 1: - lcd.Write("Temperature(C):"); - lcd.RowSelect(1); - lcd.Write(tempString); - i++; - break; - - case 2: - lcd.Write("Pressure(mBar):"); - lcd.RowSelect(1); - lcd.Write(pressString); - i =0; - break; - - default: - i = 0; - break; + case 1: + lcd.Write("Temperature(C):"); + lcd.RowSelect(1); + lcd.Write(tempString); + i++; + j = 0; + break; + + case 2: + lcd.Write("Pressure(mBar):"); + lcd.RowSelect(1); + lcd.Write(pressString); + i =0; + j = 0; + break; + + default: + i = 0; + j = 0; + break; + }//end switch + }// end if + else{ + j++; } - - Red_int = !Red_int; + lcd.RowSelect(3); - Thread::wait (5000); - } -} + dataLock.lock(); + memset(lcd_TIME, NULL, 21); + time(&raw_time); + sample_epoch = localtime(&raw_time); + strftime( lcd_TIME,21,"%d/%m/%Y %X", sample_epoch); + dataLock.unlock(); + + lcd.Write(lcd_TIME); + Thread::signal_wait(LCD_READY); + Red_int = !Red_int; + }//end while +}// end thread /*--------------------------------------------------------------------*/ /*------------------------------SERIAL_CMD----------------------------*/ @@ -749,10 +779,15 @@ pc.printf("LCD Test\n\r"); lcd.Clear(); + lcd.RowSelect(0); + lcd.Write("1******LCD*********1"); lcd.RowSelect(1); - lcd.Write("*******LCD******"); + lcd.Write("2******TEST********2"); lcd.RowSelect(2); - lcd.Write("******TEST******"); + lcd.Write("3******LCD*********3"); + lcd.RowSelect(3); + lcd.Write("4******TEST********4"); + wait(1); lcd.Clear(); pc.printf("Basic POST end\n\r");