runinig version

Dependencies:   C12832_lcd NetServices freezer_guard_running mbed

Fork of Freezer_Guard_prog by team moped

Revision:
4:cc87d93fd170
Parent:
3:94c8a14df287
--- a/main.cpp	Tue Jun 16 11:25:55 2015 +0000
+++ b/main.cpp	Sat Jun 27 09:33:58 2015 +0000
@@ -1,18 +1,3 @@
-/*
-TODO:
-* Display entmüllen
-* Displayausgabefunktion anpassen (übergabe von koordinaten)
-OK Emailfunktion anpassen (Text und Werte einsetzen)
-OK wait anweisungen überprüfen und wenn möglich eliminieren
-OK Datentypen reduzieren
-OK Ungarische Notation einführen  (->  Coding Richtline)
-OK 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
@@ -24,26 +9,14 @@
 * ...
 *******************************************************/
 
-/******************************************************
-*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
+#define LIMIT 25   // Temperature Alarm Threshold
 byte MAIN_bState;
 byte bError;
 char cString[25];
 char data_array[2];
-
+DigitalOut led4(LED4);  //DEBUG
 
 int main()
 {
@@ -51,7 +24,7 @@
     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(); 
-    
+    led4=0; //DEBUG
     while(1){
     i8Value=readValue(MCP9808_ADDR);
     wait(1);
@@ -60,30 +33,35 @@
     switch(MAIN_bState) {
     case 0: { //normal case
         vLcdIntPrint(i8Value);
+         vLcdAlarmPrint("System Running"); 
+         vLcdStringPrint("Temperature Ok   \n        ");   
          break;
          }
          
     case 1:{
         vLcdIntPrint(i8Value);
-        vLcdStringPrint("Alarm!");        
-        bError=SendMail(i8Value);
-        vAudioAlarm();
-        MAIN_bState=2;
+        vLcdAlarmPrint("Alarm!        ");   
+        vAudioAlarm();     
+//        bError=SendMail(i8Value);
+        if(SendMail(i8Value))vLcdStringPrint("Mail Sent!      \n         ");
+            else{
+                vLcdStringPrint("Mail Not Sent!     \n         ");
+                }
+        led4=1; //DEBUG
+
+         MAIN_bState=2;
           break;
           }
-    case 2:{
+    case 2:{                        // case: mail sent, alarm pending
          vLcdIntPrint(i8Value);
-         vLcdStringPrint("Mail Sent!");
          vAudioAlarm();
           break;
             }
     case 3:{                            //MAIN_bState=3 could only be set by ISR
          vLcdIntPrint(i8Value);
-         vLcdStringPrint("Alarm Confirmed");
          break;
             }        
     default:{
-         //  strcpy(cString,"State Machine Error!");
           vLcdStringPrint("State Machine Error!");
           break;
           }