Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 //GPS GT-720F Logger01 00002 #include "mbed.h" 00003 #include "TextLCD0420.h" 00004 00005 #define ON 1 00006 #define OFF 0 00007 00008 DigitalOut mled0(LED1); 00009 DigitalOut mled1(LED2); 00010 DigitalIn sw1(p5); 00011 00012 TextLCD lcd(p24, p25, p26, p27, p28, p29, p30,20,4); // rs, rw, e, d0, d1, d2, d3 00013 Serial gps(p9,p10); 00014 LocalFileSystem local("local"); 00015 Ticker flipper; 00016 FILE *fp; 00017 float g_hokui,g_tokei; 00018 int fp_count=0; 00019 00020 void gps_rec() { 00021 mled0=ON; 00022 fprintf(fp,"%4.6f,%3.6f,\n",g_tokei,g_hokui); 00023 wait(1.0); 00024 mled0=OFF; 00025 fp_count++; 00026 } 00027 00028 int main() { 00029 00030 char c; 00031 int i,rlock=0,stn=0; 00032 char gps_data[256]; 00033 char ns,ew; 00034 float time,hokui,tokei; 00035 00036 float d_hokui,m_hokui,d_tokei,m_tokei; 00037 int h_time=0,m_time=0,s_time=0; 00038 int rec_flag=0; 00039 00040 gps.baud(9600); 00041 lcd.cls(); 00042 lcd.printf("*** GPS GT-720F ****\n"); 00043 lcd.locate(0,1); 00044 lcd.printf("File open...\n"); 00045 wait(1.0); 00046 fp=fopen("/local/GPS.txt","a"); 00047 if(!fp || sw1==0){ 00048 lcd.cls(); 00049 lcd.printf("Can't Loging ... \n"); 00050 lcd.printf("System close...\n"); 00051 lcd.printf(">\n"); 00052 exit(1); 00053 } 00054 lcd.printf("System start...\n"); 00055 lcd.printf("Loging ready ok...\n"); 00056 fprintf(fp,"\n"); 00057 wait(1.0); 00058 00059 while (1) { 00060 if(sw1==0){ 00061 fclose(fp); 00062 lcd.cls(); 00063 lcd.printf("System close...\n"); 00064 lcd.printf(">\n"); 00065 exit(1); 00066 } 00067 00068 i=0; 00069 while(gps.getc()!='$'){ 00070 } 00071 00072 while( (gps_data[i]=gps.getc()) != '\r'){ 00073 i++; 00074 if(i==256){ 00075 lcd.printf("*** Data read Error! ***\n"); 00076 i=255; 00077 break; 00078 } 00079 } 00080 gps_data[i]='\0'; 00081 00082 //test 00083 /* Test data 00084 rlock=1; 00085 stn=3; 00086 hokui=3532.25024; //=>35.537502 00087 tokei=13751.86820;//=>137.864471 00088 time=114107.046; 00089 */ 00090 if( sscanf(gps_data, "GPGGA,%f,%f,%c,%f,%c,%d,%d",&time,&hokui,&ns,&tokei,&ew,&rlock,&stn) >= 1){ 00091 if(rlock >= 1){ 00092 00093 //hokui 00094 d_hokui=int(hokui/100); 00095 m_hokui=(hokui-d_hokui*100)/60; 00096 g_hokui=d_hokui+m_hokui; 00097 //tokei 00098 d_tokei=int(tokei/100); 00099 m_tokei=(tokei-d_tokei*100)/60; 00100 g_tokei=d_tokei+m_tokei; 00101 //g_hokui=int(hokui/100)+(hokui-int(hokui/100))/60; 00102 //g_tokei=int(tokei/100)+(tokei-int(tokei/100))/60; 00103 00104 //time set 00105 h_time=int(time/10000); 00106 m_time=int((time-h_time*10000)/100); 00107 s_time=int(time-h_time*10000-m_time*100); 00108 h_time=h_time+9;//UTC =>JST 00109 00110 // Record start 00111 if(rec_flag==0){ 00112 flipper.attach(&gps_rec, 10.0); 00113 rec_flag=1; 00114 fprintf(fp,"JST %2d:%2d:%2d\n",h_time,m_time,s_time); 00115 lcd.cls(); 00116 mled0=ON; 00117 lcd.printf("Loging start...."); 00118 wait(5.0); 00119 mled0=ON; 00120 } 00121 00122 lcd.cls(); 00123 lcd.locate(0,0); 00124 lcd.printf("*GPS JST %2d:%2d:%2d",h_time,m_time,s_time); 00125 lcd.locate(0,1); 00126 lcd.printf("Lk(%d),St(%d),%d",rlock,stn,fp_count); 00127 //Latitude=Hokui 00128 lcd.locate(0,2); 00129 lcd.printf("Lat/d:%4.6f",g_hokui); 00130 // Logitude=tokei 00131 lcd.locate(0,3); 00132 lcd.printf("Log/d:%4.6f",g_tokei); 00133 } 00134 else{ 00135 flipper.detach(); 00136 rec_flag=0; 00137 lcd.cls(); 00138 lcd.locate(0,0); 00139 lcd.printf("*** GPS GT-720F ***"); 00140 lcd.locate(0,1); 00141 lcd.printf("Lk(%d),St(%d)",rlock,stn); 00142 lcd.locate(0,2); 00143 for(i=0;i<40;i++){ 00144 lcd.printf("%c",gps_data[i]); 00145 } 00146 } 00147 }//if 00148 }//while 00149 }//main 00150 00151 00152
Generated on Wed Jul 20 2022 10:42:33 by
1.7.2