sdカードに経路緯度を保存する。txt形式で保存の後、kml形式にしてGoogle mapで経路を確認。 kml形式変換の参考サイト http://www.oidenansho.com/elekijack/mbed/2bk0208_GPS_logger/GPS_logger.htm

Dependencies:   SDFileSystem mbed

Fork of 2bk0123_GPS_Test05 by Takeuchi Kouichi

Revision:
1:04787f83fac1
Parent:
0:f3ff53b5b707
--- a/main.cpp	Wed Feb 02 06:03:53 2011 +0000
+++ b/main.cpp	Thu Feb 15 03:02:13 2018 +0000
@@ -1,15 +1,23 @@
 //GPS GT-720F Test05
 #include "mbed.h"
-#include "TextLCD0420.h"
+
+#include "SDFileSystem.h"
 
 #define ON 1
 #define OFF 0
+Serial gps(p9,p10);// tx, rx 
+
+LocalFileSystem local("local");
 
 DigitalOut mled0(LED1);
 DigitalOut mled1(LED2);
 
-TextLCD lcd(p24, p25, p26, p27, p28, p29, p30,20,4); // rs, rw, e, d0, d1, d2, d3
-Serial gps(p9,p10);
+SDFileSystem    sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board
+
+
+Serial pc(USBTX, USBRX); // tx, rx 
+
+FILE *fp;
 
 int main() {
 
@@ -20,11 +28,12 @@
       float time,hokui,tokei;
       float g_hokui,g_tokei;
       float d_hokui,m_hokui,d_tokei,m_tokei;
-
+ 
+      int h_time=0,m_time=0,s_time=0;
+      
+ mkdir("/sd/gps_data", 0777);//まずsdのフォルダをつくる。
+ 
       gps.baud(9600);
-      lcd.cls();
-      lcd.locate(0,0);
-      lcd.printf("*** GPS GT-720F ***");    
 
     while (1) {
       i=0;
@@ -34,7 +43,7 @@
       while( (gps_data[i]=gps.getc()) != '\r'){
         i++;
         if(i==256){
-           lcd.printf("*** Data read  Error! ***\n");
+         
            i=255;
            break;
          }
@@ -49,6 +58,13 @@
       */  
       if( sscanf(gps_data, "GPGGA,%f,%f,%c,%f,%c,%d,%d",&time,&hokui,&ns,&tokei,&ew,&rlock,&stn) >= 1){
         if(rlock >= 1){
+          
+          //time set
+          h_time=int(time/10000);
+          m_time=int((time-h_time*10000)/100);
+          s_time=int(time-h_time*10000-m_time*100);
+          h_time=h_time+9;//UTC =>JST
+          
           //hokui
           d_hokui=int(hokui/100);
           m_hokui=(hokui-d_hokui*100)/60;
@@ -59,26 +75,23 @@
           g_tokei=d_tokei+m_tokei;
           //g_hokui=int(hokui/100)+(hokui-int(hokui/100))/60;
           //g_tokei=int(tokei/100)+(tokei-int(tokei/100))/60;
+        
           
-          lcd.cls();
-          lcd.locate(0,0);
-          lcd.printf("*** GPS GT-720F ***");  
-          lcd.locate(0,1);
-          lcd.printf("Lock(%d),Stn(%d)",rlock,stn);  
-         //Latitude=Hokui
-          lcd.locate(0,2);
-          lcd.printf("Lat/dd:%4.6f",g_hokui);
-         // Logitude=tokei 
-          lcd.locate(0,3);
-          lcd.printf("Log/dd:%4.6f",g_tokei);
-        }
-        else{
-          lcd.locate(0,1);
-          lcd.printf("Lock(%d),Stn(%d)",rlock,stn);
-          lcd.locate(0,2);
-          for(i=0;i<40;i++){
-            lcd.printf("%c",gps_data[i]);
-          }
+          //==================================================//
+         
+         pc.printf("%2d,%2d,%2d,%4.6f,,%3.6f,\r\n",h_time,m_time,s_time,g_tokei,g_hokui);
+         
+         fp = fopen("/sd/gps_data/log.txt", "a");
+    
+        //  fprintf(fp,"%2d,%2d,%2d,%4.6f,,%3.6f,\r\n",h_time,m_time,s_time,g_tokei,g_hokui);
+        fprintf(fp,"%4.6f,%3.6f,\r\n",g_tokei,g_hokui);
+          fclose(fp);
+          
+          //==================================================//
+          
+          
+         
+        //}
         }
       }//if
     }//while