今までのメインプログラムとGPSのプログラムを統合した。

Dependencies:   HMC5883L SDFileSystem TextOLED mbed

Fork of GPS_Test05 by basyo matsuo

Files at this revision

API Documentation at this revision

Comitter:
Joeatsumi
Date:
Thu Feb 15 05:47:19 2018 +0000
Parent:
3:0a4a3d9ca7d4
Commit message:
GPS???????????????????

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 0a4a3d9ca7d4 -r 39845036d492 main.cpp
--- a/main.cpp	Thu Feb 15 05:05:28 2018 +0000
+++ b/main.cpp	Thu Feb 15 05:47:19 2018 +0000
@@ -67,6 +67,16 @@
 unsigned char Log_flag = OFF;
 unsigned char SD_flag = OFF;
       
+      char c;
+      int i3,rlock,stn;
+      char gps_data[256];
+      char ns,ew;
+      float time3,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;
+      
       
 
 //プロトタイプ宣言
@@ -102,15 +112,7 @@
 
 int main() {
 
-      char c;
-      int i3,rlock,stn;
-      char gps_data[256];
-      char ns,ew;
-      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のフォルダをつくる。
  
@@ -190,13 +192,13 @@
        hokui=3532.25024; //=>35.537502
        tokei=13751.86820;//=>137.864471
       */  
-      if( sscanf(gps_data, "GPGGA,%f,%f,%c,%f,%c,%d,%d",&time,&hokui,&ns,&tokei,&ew,&rlock,&stn) >= 1){
+      if( sscanf(gps_data, "GPGGA,%f,%f,%c,%f,%c,%d,%d",&time3,&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=int(time3/10000);
+          m_time=int((time3-h_time*10000)/100);
+          s_time=int(time3-h_time*10000-m_time*100);
           h_time=h_time+9;//UTC =>JST
           
           //hokui
@@ -212,15 +214,7 @@
         
           
           //==================================================//
-         
          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);
-          
           //==================================================//
           
           
@@ -248,18 +242,25 @@
           
         fp = fopen("/sd/mydir/TP.txt", "a");
         
+        
         if (NULL == fp) {
             pilot_oled.locate(0, 0);
             pilot_oled.printf("There is no SD!!");
             pc.printf("There is no SD!!\n");
             error("Could not open file for write \n");
         } else {
-            fprintf(fp, "NO:%d,%02d:%02d,%1.0f,%0.3f,%0.3f,%0.3f,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
+            fprintf(fp, "NO:%d,%02d:%02d,%1.0f,%0.3f,%0.3f,%0.3f,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\r\n",
                          SD_count, min, sec, rpm, speed, height,compass,up2,up1,E_neut,down1,down2,left2,left1,R_neut,right1,right2);
-                   //      fprintf(fp,"%4.6f,;%3.6f,;\r\n",g_tokei,g_hokui);
+                       
+                      //  fprintf(fp,";%3.6f;,%3.6f,;\r\n",g_tokei,g_hokui);
             fclose(fp);     
                                                                                                                 //操舵データ
         }
+           fp = fopen("/sd/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);
     }
     led2 = 0;
     //   __enable_irq();