Bmag incl gps rettelse

Dependencies:   mbed WDT MODSERIAL BME280

Revision:
12:2b46960a5d41
Parent:
11:d3d26d0e71ea
Child:
13:45b333983206
--- a/main.cpp	Fri Mar 31 12:30:20 2017 +0000
+++ b/main.cpp	Wed Apr 05 13:00:10 2017 +0000
@@ -20,7 +20,6 @@
 int missingGpsCnt = 0;
 int GpsCntWithoutMagData = 0;
 int magCntWithoutGpsData = 0;
-bool userNotifiedOfNoGGAFix = false;
 
 string INTERPRETERID = "";
 char interpreterTmpID[10];
@@ -40,10 +39,6 @@
 int timeSetManuallyCount = 0;
 
 
-//global display variables
-char line1[10];
-char line2[10];
-
 //batteryvoltage
 char batteryvoltagearr[5];
 string batteryvoltage;
@@ -72,10 +67,6 @@
     memset(batteryvoltagearr,'\0',5);
     batteryvoltage = "";   
     
-    //init display lines
-    memset(line1,'\0',10);
-    memset(line2,'\0',10);
-    
     //Analog battery reading
     AnalogIn battery(A5);  
 
@@ -144,7 +135,6 @@
     
     //Init errorhandler
     ErrorHandler dispTxtHandler(&batteryvoltage, &GGA_Fix_Present, &magParser);
-    
     dispTxtHandler.setErrorState(NONE); 
             
     //infinite loop running after initialization
@@ -161,10 +151,6 @@
         
         if(BMAG_Data_Rdy){
             
-            //init display lines
-            memset(line1,'\0',10);
-            memset(line2,'\0',10);
-            
             //if mag data is present but gps data is not
             if(magCntWithoutGpsData < 100){
                 magCntWithoutGpsData += 1;
@@ -211,7 +197,7 @@
             sprintf(batteryvoltagearr, "%0.1f",(0.00036621652)*battery.read_u16());
             batteryvoltage.assign(batteryvoltagearr);
             
-            if((toggler && (missingGpsCnt < GPSACQTIMELIMITINSECONDS)) || (toggler && userNotifiedOfNoGGAFix)){
+            if((toggler && (missingGpsCnt < GPSACQTIMELIMITINSECONDS)) || (toggler && dispTxtHandler.getMagTimePromtStatus())){
                 //show battery voltage and gps fix status for 10 mag reading cycles                
                 dispTxtHandler.setErrorState(DISPLAY_VBAT_FIX);
                                 
@@ -223,7 +209,7 @@
                           
             }
             
-            if((!toggler && missingGpsCnt < GPSACQTIMELIMITINSECONDS) || (!toggler && userNotifiedOfNoGGAFix)){                
+            if((!toggler && missingGpsCnt < GPSACQTIMELIMITINSECONDS) || (!toggler && dispTxtHandler.getMagTimePromtStatus())){                
                 //show magnT reading for 10 mag reading cycles
                 dispTxtHandler.setErrorState(DISPLAY_MAG_MEASUREMENT);
                 
@@ -236,20 +222,10 @@
 
             
             //if gga fix is not present for a prolonged period of time, prompt user
-            if((missingGpsCnt > GPSACQTIMELIMITINSECONDS) && !userNotifiedOfNoGGAFix){
-                
-                //prompt user to set mag time in a 5 minute duration
-                if(magTimePromptCount < 300){
-                    magTimePromptCount += 1;
-                    
-                    //Prompt user to set mag time manually
-                    dispTxtHandler.setErrorState(DISPLAY_MAG_MEASUREMENT);
-                     
-                }
-                
-                if(magTimePromptCount >= 300 || magTimeSetManually){
-                    userNotifiedOfNoGGAFix = true;    
-                }           
+            if((missingGpsCnt > GPSACQTIMELIMITINSECONDS) && !dispTxtHandler.getMagTimePromtStatus()){
+        
+                //Prompt user to set mag time manually
+                dispTxtHandler.setErrorState(NO_FIX);
             }
             
             
@@ -309,7 +285,8 @@
                     
             }
             
-            if(!timeSetManuallyButton){  
+            //if user has been notified of time settings needed on bmag, pushbutton can be held for a few cycles to circumvent the set mag time display prompt.
+            if(!timeSetManuallyButton && dispTxtHandler.getMagTimePromtStatus()){  
                 timeSetManuallyCount += 1;
                 
                 if(timeSetManuallyCount > 3){