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 #include "mbed.h" 00002 00003 DigitalOut myled(LED1); 00004 Serial gps(D1, D0); // tx, rx 00005 Serial pc(USBTX, USBRX); // tx, rx 00006 00007 void pc_rx() { 00008 00009 unsigned char c; 00010 int i,rlock; 00011 char gps_data[256],gps2_data[256]; 00012 char ns,ew; 00013 float time,hokui,tokei; 00014 float g_hokui,g_tokei; 00015 float d_hokui,m_hokui,d_tokei,m_tokei; 00016 00017 gps.baud(9600); 00018 pc.printf("*** GPS GT-720F ***"); 00019 00020 while (1) { 00021 i=0; 00022 while(gps.getc()!='$'){ 00023 } 00024 00025 while((gps_data[i]=gps.getc()) != '\r'){ 00026 i++; 00027 if(i==256){ 00028 pc.printf("*** Div Error! ***\n"); 00029 i=255; 00030 break; 00031 } 00032 } 00033 gps_data[i]='\0'; 00034 00035 if( sscanf(gps_data, "GPGGA,%f,%f,%c,%f,%c,%d",&time,&hokui,&ns,&tokei,&ew,&rlock) >= 1){ 00036 if(rlock==1){ 00037 pc.printf("Status:Lock(%d)\n\r",rlock); 00038 //logitude 00039 d_tokei= int(tokei/100); 00040 m_tokei= (tokei-d_tokei*100)/60; 00041 g_tokei= d_tokei+m_tokei; 00042 pc.printf("Log:%4.5f,",g_tokei); 00043 //Latitude 00044 d_hokui=int(hokui/100); 00045 m_hokui=(hokui-d_hokui*100)/60; 00046 g_hokui=d_hokui+m_hokui; 00047 pc.printf("Lat:%4.5f\n\r",g_hokui); 00048 00049 } 00050 else{ 00051 pc.printf("\n\rStatus:unLock(%d)\n\r",rlock); 00052 for(i=0;i<40;i++){ 00053 pc.printf("%c",gps_data[i]); 00054 } 00055 } 00056 }//if 00057 }//while 00058 } 00059 00060 int main(){ 00061 gps.attach(pc_rx,Serial::RxIrq); 00062 while(1) { 00063 myled = 1; 00064 wait(0.2); 00065 myled = 0; 00066 wait(0.2); 00067 } 00068 }
Generated on Wed Jul 13 2022 11:17:47 by
1.7.2