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.
Dependencies: mbed
Fork of test_GPS_15_mai by
main.cpp
00001 #include "mbed.h" 00002 #include "stdio.h" 00003 #include "Serial.h" 00004 #include <string> 00005 #include <cstdlib> 00006 00007 DigitalOut led1(LED1); 00008 DigitalOut led2(LED2); 00009 DigitalOut led3(LED3); 00010 DigitalOut led4(LED4); 00011 DigitalOut led5(p7); 00012 Serial pc(USBTX, USBRX, 4800); 00013 Serial gps(p13, p14, 4800); 00014 char debut_trame[7]="XXXXXX"; 00015 char trame[81] ; 00016 char lat[8]; 00017 char lat_NS; 00018 char lon[9]; 00019 char lon_EW; 00020 float lat_cnv; 00021 float lon_cnv; 00022 int lat_deg = 0; 00023 float lat_dec; 00024 int lon_deg = 0; 00025 float lon_dec; 00026 char rx ; 00027 int e ; 00028 00029 int main() { 00030 00031 led1=0; 00032 led5=0; 00033 pc.printf("debut "); 00034 e = 0 ; 00035 while(1) { 00036 00037 rx = gps.getc(); 00038 for(int i = 0; i <80; i++) 00039 { 00040 trame[i] = trame[i+1]; 00041 } 00042 trame[76]=rx ; 00043 strncpy(debut_trame,trame,6); 00044 00045 if (strcmp(debut_trame,"$GPGGA") == 0) 00046 { 00047 led1=1; 00048 00049 for (int i = 0; i<=8; i++) 00050 { 00051 lat[i] = trame [18+i]; 00052 lat_cnv = atof(lat); 00053 } 00054 lat_NS = trame [28]; 00055 00056 for (int a=0; a<=9; a++) 00057 { 00058 lon[a] = trame [30+a]; 00059 lon_cnv = atof(lon); 00060 } 00061 lon_EW = trame [41]; 00062 00063 lat_cnv = lat_cnv/100; 00064 lat_deg = (int)lat_cnv; 00065 lat_dec = lat_cnv - lat_deg; 00066 lat_dec = (lat_dec/60)*100; 00067 lat_cnv = lat_deg + lat_dec; 00068 00069 lon_cnv = lon_cnv/100; 00070 lon_deg = (int)lon_cnv; 00071 lon_dec = lon_cnv - lon_deg; 00072 lon_dec = (lon_dec/60)*100; 00073 lon_cnv = lon_deg + lon_dec; 00074 00075 if (lat_NS=='N') 00076 { 00077 lat_cnv = lat_cnv*1; 00078 } 00079 00080 else if (lat_NS=='S') 00081 { 00082 lat_cnv = lat_cnv*(-1); 00083 } 00084 00085 if (lon_EW=='E') 00086 { 00087 lat_cnv = lat_cnv*1; 00088 } 00089 00090 else if (lon_EW=='W') 00091 { 00092 lat_cnv = lat_cnv*(-1); 00093 } 00094 pc.printf("%f, %c, %f, %c \n\r", lat_cnv, lat_NS, lon_cnv, lon_EW); 00095 } 00096 } 00097 }
Generated on Sun Jul 24 2022 08:58:32 by
