![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
runinig version
Dependencies: C12832_lcd NetServices freezer_guard_running mbed
Fork of Freezer_Guard_prog by
Diff: main.cpp
- Revision:
- 2:896a33daab3d
- Parent:
- 0:fc20669f5ba8
- Child:
- 3:94c8a14df287
diff -r 356f5c46585f -r 896a33daab3d main.cpp --- a/main.cpp Thu Jun 11 09:01:12 2015 +0000 +++ b/main.cpp Tue Jun 16 11:16:33 2015 +0000 @@ -2,11 +2,11 @@ TODO: * Display entmüllen * Displayausgabefunktion anpassen (übergabe von koordinaten) -* Emailfunktion anpassen (Text und Werte einsetzen) -# wait anweisungen überprüfen und wenn möglich eliminieren +OK Emailfunktion anpassen (Text und Werte einsetzen) +OK wait anweisungen überprüfen und wenn möglich eliminieren # Datentypen reduzieren # Ungarische Notation einführen (-> Coding Richtline) -# bei printfunktionen string direkt übergeben +OK bei printfunktionen string direkt übergeben #Doku #Demo VErsion mit Alarm bei >temp erstellen # DEBUG ausgaben entfernen @@ -39,7 +39,7 @@ #include "guard.h" #include "string.h" #define LIMIT -10 // Temperature Alarm Threshold -byte bState; +byte MAIN_bState; byte bError; char cString[25]; char data_array[2]; @@ -47,17 +47,17 @@ int main() { - int i8Value=0; - bState=0; //statemachine: 0=no Alarm, 1=Alarm and no Mail sent, 2=Alarm and Mail sent + int8 i8Value=0; //value has 8 bit + sign + MAIN_bState=0; //statemachine: 0=no Alarm, 1=Alarm and no Mail sent, 2=Alarm and Mail sent, 3= Pending Alarm Confirmed bError=0; vGuardInit(); while(1){ i8Value=readValue(MCP9808_ADDR); wait(1); - if(i8Value>LIMIT && bState==0) bState=1; - if(i8Value<LIMIT) bState=0; - switch(bState) { + if(i8Value>LIMIT && MAIN_bState==0) MAIN_bState=1; + if(i8Value<LIMIT) MAIN_bState=0; + switch(MAIN_bState) { case 0: { //normal case vLcdIntPrint(i8Value); break; @@ -65,29 +65,26 @@ case 1:{ vLcdIntPrint(i8Value); - strcpy(cString,"Alarm!"); - vLcdStringPrint(cString); + vLcdStringPrint("Alarm!"); bError=SendMail(i8Value); vAudioAlarm(); - bState=2; + MAIN_bState=2; break; } case 2:{ vLcdIntPrint(i8Value); - strcpy(cString,"Mail Sent!"); - vLcdStringPrint(cString); + vLcdStringPrint("Mail Sent!"); vAudioAlarm(); break; } - case 3:{ //bState=3 could only be set by ISR + case 3:{ //MAIN_bState=3 could only be set by ISR vLcdIntPrint(i8Value); - strcpy(cString,"Alarm Confirmed"); - vLcdStringPrint(cString); + vLcdStringPrint("Alarm Confirmed"); break; } default:{ - strcpy(cString,"State Machine Error!"); - vLcdStringPrint(cString); + // strcpy(cString,"State Machine Error!"); + vLcdStringPrint("State Machine Error!"); break; } }//state machine