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.
Fork of GPS_Google_Cadenas by
Revision 3:d7d5111a39ac, committed 2017-04-28
- Comitter:
- tony63
- Date:
- Fri Apr 28 13:16:09 2017 +0000
- Parent:
- 2:5abd8a794703
- Commit message:
- ESTE PROGRAMA SE ENCARGA DE LEER UN GPS Y GENERAR UNA CADENA DE GEOLOCALIZACION; PARA SER ENVIADA COMO LINK EN UN MENSAJE DE TEXTO; UTIL PARA IMPLEMENTAR UN RASTREADOR SATELITAL; EN CASO DE NO TENER GPS USE UN EMULADOR COMO SATGEMNMEA;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 5abd8a794703 -r d7d5111a39ac main.cpp --- a/main.cpp Mon Apr 27 02:09:46 2015 +0000 +++ b/main.cpp Fri Apr 28 13:16:09 2017 +0000 @@ -1,20 +1,90 @@ +//ESTE PROGRAMA SE ENCARGA DE LEER UN GPS Y GENERAR UNA CADENA DE GEOLOCALIZACION +//PARA SER ENVIADA COMO LINK EN UN MENSAJE DE TEXTO +//UTIL PARA IMPLEMENTAR UN RASTREADOR SATELITAL +//EN CASO DE NO TENER GPS USE UN EMULADOR COMO SATGEMNMEA +//https://www.labsat.co.uk/index.php/en/free-gps-nmea-simulator-software + #include "mbed.h" #include "GPS.h" +#include <stdio.h> +#include <string.h> +#include <math.h> Serial pc(USBTX, USBRX); -GPS gps(PTE22, PTE23); -float frac_long, frac_lat; +GPS gps(PTE0, PTE1); +int z; +int Lo_E,Lo_F,La_E,La_F;//longitud entera y fraccionaria +float frac_long, frac_lat; //fraccion longitud y fraccion latitud +char long_E[4]; //Subcadena con la longitud entera +char long_F[7];//Subcadena con la longitud fraccionaria(6 digitos) +char lat_E[4];//Subcadena con la latitud entera +char lat_F[7];////Subcadena con la latitud fraccionaria(6 digitos) +char GooMap[55]="http://maps.google.com/maps?q="; +char str[55]; +void tostring(char[], int); //FUNCION QUE CONVIERTE UN ENTERO EN CARACTER Y VICEVERSA +int num; int main() { + while(1) { if(gps.sample()) { - pc.printf("longitud_entera=%d, Latitud entera=%d\n", (int)gps.longitude, (int)gps.latitude); - frac_long=gps.longitude-(int)gps.longitude; - pc.printf("Longitud Fraccionaria=%d\n", (int)abs(1000000*frac_long)); - frac_lat=gps.latitude-(int)gps.latitude; - pc.printf("Latitud fraccionaria=%d\n", (int)abs(1000000*frac_lat)); - } else { + Lo_E = abs((int)gps.longitude); + Lo_F = (int)abs(1000000*(gps.longitude-(int)gps.longitude)); + La_E = abs((int)gps.latitude); + La_F = (int)abs(1000000*(gps.latitude-(int)gps.latitude)); + + //calculo las cuatro subcadenas de las partes enteras y fraccionarias falta adicionar los puntos,las comas y los signos + tostring(long_E, Lo_E); + tostring(long_F, Lo_F); + tostring(lat_E, La_E); + tostring(lat_F, La_F); + + if(gps.latitude<0){ + strcat(GooMap,"-"); + } + strcat(GooMap,lat_E); + strcat(GooMap,"."); + strcat(GooMap,lat_F); + strcat(GooMap,","); + if(gps.longitude<0){ + strcat(GooMap,"-"); + } + strcat(GooMap,long_E); + strcat(GooMap,"."); + strcat(GooMap,long_F); + strcat(GooMap,"\n"); + pc.printf("%s\n",GooMap); //la omprimo o hago algo con ella + for(z=30;z<51;z++){ //la lleno de ceros para evitar problemas despues!! + GooMap[z]=0; + } + } + + else { pc.printf("Oh Dear! No lock :(\n"); } } -} +} + + +//*********************************************************************************************** +//funcion que convierte entero en caracter + void tostring(char str[], int num) + { + int i, rem, len = 0, n; + + n = num; + while (n != 0) + { + len++; + n /= 10; + } + for (i = 0; i < len; i++) + { + rem = num % 10; + num = num / 10; + str[len - (i + 1)] = rem + '0'; + } + str[len] = '\0'; + } + +