runinig version

Dependencies:   C12832_lcd NetServices freezer_guard_running mbed

Fork of Freezer_Guard_prog by team moped

Revision:
0:fc20669f5ba8
Child:
2:896a33daab3d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jun 11 08:54:46 2015 +0000
@@ -0,0 +1,96 @@
+/*
+TODO:
+* Display entmüllen
+* Displayausgabefunktion anpassen (übergabe von koordinaten)
+* Emailfunktion anpassen (Text und Werte einsetzen)
+# wait anweisungen überprüfen und wenn möglich eliminieren
+# Datentypen reduzieren
+# Ungarische Notation einführen  (->  Coding Richtline)
+# bei printfunktionen string direkt übergeben
+#Doku
+#Demo VErsion mit Alarm bei >temp erstellen
+# DEBUG ausgaben entfernen
+*/
+
+
+/******************************************************
+*File Name: Freezer_Guard main.cpp
+*Purpose: Freezer Guard System protects your freezer from unintentionaly defrost
+*
+*Author: denis schnier and fabian bitz @ University of applied sciences bingen
+*Changes:
+*
+* 18.05.2015 initial version
+* ...
+*******************************************************/
+
+/******************************************************
+*1 Initialisierungsfunktion aufrufen
+*2 
+*3 readValue() aufrufen
+*3 Rueckgabewert pruefen
+    *3a Zustandsautomat auf Alarm oder zurück setzen 
+*4 ggf. sendMail() aufrufen
+    *4a sendMail initialisiert Ethertnet IF
+    *4b sendMail versendet email (alle ausgabe über serielle Konsole) 
+*5 audioAlarm() aufrufen und Alarmsound ausgeben 
+*6 springe zu *3   
+*******************************************************/
+#include "guard.h"
+#include "string.h"
+#define LIMIT -10   // Temperature Alarm Threshold
+byte bState;
+byte bError;
+char cString[25];
+char data_array[2];
+
+
+int main()
+{
+    int i8Value=0;
+    bState=0; //statemachine: 0=no Alarm, 1=Alarm and no Mail sent, 2=Alarm and Mail sent
+    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) {
+    case 0: { //normal case
+        vLcdIntPrint(i8Value);
+         break;
+         }
+         
+    case 1:{
+        vLcdIntPrint(i8Value);
+        strcpy(cString,"Alarm!");
+        vLcdStringPrint(cString);        
+        bError=SendMail(i8Value);
+        vAudioAlarm();
+        bState=2;
+          break;
+          }
+    case 2:{
+         vLcdIntPrint(i8Value);
+          strcpy(cString,"Mail Sent!");
+         vLcdStringPrint(cString);
+         vAudioAlarm();
+          break;
+            }
+    case 3:{                            //bState=3 could only be set by ISR
+         vLcdIntPrint(i8Value);
+         strcpy(cString,"Alarm Confirmed");
+         vLcdStringPrint(cString);
+         break;
+            }        
+    default:{
+           strcpy(cString,"State Machine Error!");
+          vLcdStringPrint(cString);
+          break;
+          }
+        }//state machine
+    }//while(1)
+
+}//main