affichage d m s

Dependencies:   mbed

Fork of GPS by tito tito

main.cpp

Committer:
vallarjohann
Date:
2016-03-18
Revision:
3:8234e0d5854e
Parent:
2:addb687a4e73

File content as of revision 3:8234e0d5854e:

#include "mbed.h"
#include <Serial.h>
#include "getline.h"

Serial pc(USBTX, USBRX);
//GPS gps(p13, p14);
 
Serial uart1(p13, p14); //pin RX et TX du GPS
char c;
 int event_callback_t ;
        int     event;
        unsigned char   char_match ;
 char msg[1000];
  /** The longitude (call sample() to set) */
    float longitude,longitude2;

    /** The latitude (call sample() to set) */
    float latitude,latitude2,time2;
    
    char ns, ew;
    int lock;
int main() {
    uart1.baud(9600);   //vitesse de transmission de informations
    printf("hello\n");  //test
    while (1){
        if (uart1.readable())
         {
                
             getline(uart1,msg,999);
            if ( sscanf(msg, "$GPGGA,%f,%f,%c,%f,%c,%d", &time2, &latitude, &ns, &longitude, &ew, &lock )>=1)
            {    pc.printf("long= %f %c  latitude= %f %c\n",longitude, ew, latitude, ns);       
                if(!lock) {
                    longitude = 0.0;
                    latitude = 0.0; 
                    pc.printf("long= %f %c  latitude= %f %c\n",&longitude, &ew, &latitude, &ns);   
                } else {
                    if(ns == 'S') {    latitude  *= -1.0; }
                    if(ew == 'W') {    longitude *= -1.0; }
                    int iDeg=(int) latitude/100;
                    int iMin=(int) (latitude-iDeg*100);
                    float iSec= ((latitude-(iDeg*100+iMin))*60);
                     pc.printf(" latitude degree= %d  minutes=%d secondes=%f \n", iDeg,iMin,iSec); 
                    int iDeg2=(int) longitude/100;
                    int iMin2=(int) (longitude-iDeg2*100);
                    float iSec2= ((longitude-(iDeg2*100+iMin2))*60);
                     pc.printf(" longitude= %d  minutes=%d secondes=%f \n", iDeg2,iMin2,iSec2);  
                   
                    
                    
                    
              }//end else
           }//end if
        }//end if
    }  //end while
}  //end main      

             /*
         c=uart1.getc();
         pc.printf("%c",c);
      */
       /*  }

        
  */      
/*      
    while(1) {
        //wait(1.0);
        //printf("hello bis\n");
        
        if(gps.sample()) {
            printf("I'm at %f, %f\n", gps.longitude, gps.latitude);
        } else {
            printf("Oh Dear! No lock :(\n");
        }
    }
}


// Print "Hello World" to the PC
 
#include "mbed.h"
*/