modifiche posizione iniziale e sistema d'allarme.

Dependencies:   MTK3339 TextLCD mbed tsi_sensor

Fork of app_gps by Dennis Morello

Revision:
8:c285a6043b98
Parent:
7:ffc4ef2442fa
--- a/main.cpp	Mon Jul 13 16:52:40 2015 +0000
+++ b/main.cpp	Tue Jul 14 08:24:15 2015 +0000
@@ -107,22 +107,21 @@
         coords[LON][i%N] = gps.getLongitudeAsDegrees();
         wait(1);
         
-        if (i>=N) {
+        if (i >= 2*N) {
             meanLat  = mean(coords[LAT], N);
             meanLon  = mean(coords[LON], N);
             stdevLat = stdev(coords[LAT], N);
             stdevLon = stdev(coords[LON], N);
             
             lcd.cls();
-            lcd.printf("ACCURACY\n%f m (loop %d)", 2*distThomas(0, 0, 3*stdevLat, 3*stdevLon), i);
+            lcd.printf("ACCURACY (%d)\n%f m", i, distThomas(0, 0, 3*stdevLat, 3*stdevLon));
             
-            if (distThomas(0, 0, stdevLat, stdevLon) < 2.5) {
+            if (distThomas(0, 0, 3*stdevLat, 3*stdevLon) < 3) {
                 initPos[LAT] = coords[LAT][i%N];
                 initPos[LON] = coords[LON][i%N];
                 set = true;
             }
         }
-        
         i++;
     }
 }
@@ -153,7 +152,7 @@
             } else {
                 // Prendi la soglia impostata dall'utente
                 if (slider.readPercentage() != 0.0) {
-                    thrs = floor(slider.readPercentage() * 7.5 + 2.5);
+                    thrs = floor(slider.readPercentage() * 7.0 + 3.0);
                 }
 
                 // Calcola la distanza tra punto iniziale e attuale
@@ -161,12 +160,14 @@
 
                 // Verifica che la soglia sia superata
                 if (d > thrs) {
-                    if(++c > 5){
-                        lcd.printf("THRS=%2.0fm SATS=%d\nDIST=%2.0fm ALARM!", thrs, gps.gga.satellites, d);
+                    if (c >= 5 ){
+                        lcd.printf("TH=%2.0fm SATS=%d\nDIST=%2.1fm ALARM", thrs, gps.gga.satellites, d);
                         setRGBColor(1, 0, 0);
+                    } else {
+                        c++;
                     }
                 } else {
-                    lcd.printf("THRS=%2.0fm SATS=%d\nDIST=%2.0fm    OK!", thrs, gps.gga.satellites, d);
+                    lcd.printf("TH=%2.0fm SATS=%d\nDIST=%2.1fm OK", thrs, gps.gga.satellites, d);
                     setRGBColor(0, 1, 0);
                     c=0;
                 }