Exemple d'utilisation de la librairie Gps NMEA

Dependencies:   gps_event_vitesse mbed

Committer:
schnf30
Date:
Fri May 20 16:25:50 2016 +0000
Revision:
1:a963d11a19d2
Parent:
0:49a81d0d029d
Programme adapt? ? EM406 et EM506 attention Gps.baud = 4800 bauds

Who changed what in which revision?

UserRevisionLine numberNew contents of line
schnf30 0:49a81d0d029d 1 #include "mbed.h"
schnf30 0:49a81d0d029d 2 #include "gps_event_vitesse.h"
schnf30 0:49a81d0d029d 3 #define PCBAUD 115200
schnf30 0:49a81d0d029d 4 #define GPSRX p10
schnf30 0:49a81d0d029d 5 #define GPSTX p9
schnf30 1:a963d11a19d2 6 #define GPSBAUD 4800
schnf30 0:49a81d0d029d 7 #define BLUERX p27
schnf30 0:49a81d0d029d 8 #define BLUETX p28
schnf30 0:49a81d0d029d 9
schnf30 0:49a81d0d029d 10 #define bluetooth
schnf30 0:49a81d0d029d 11
schnf30 0:49a81d0d029d 12 Gps gps(GPSTX,GPSRX);
schnf30 0:49a81d0d029d 13 Serial blue(BLUETX, BLUERX); // TX, RX
schnf30 0:49a81d0d029d 14 Serial pc(USBTX, USBRX);
schnf30 0:49a81d0d029d 15 DigitalOut myled(LED1);
schnf30 0:49a81d0d029d 16
schnf30 0:49a81d0d029d 17 int main()
schnf30 0:49a81d0d029d 18 {
schnf30 0:49a81d0d029d 19 pc.baud(PCBAUD);
schnf30 1:a963d11a19d2 20 gps.baud(GPSBAUD);
schnf30 0:49a81d0d029d 21
schnf30 0:49a81d0d029d 22 // pc.printf("Hello, Gps event.\r\n");
schnf30 0:49a81d0d029d 23 // pc.printf("Patientez attente Gps\r\n");
schnf30 0:49a81d0d029d 24 while(1) {
schnf30 0:49a81d0d029d 25 if (gps.sample()) {
schnf30 0:49a81d0d029d 26
schnf30 0:49a81d0d029d 27 if (gps.lock()) {
schnf30 0:49a81d0d029d 28 #ifdef bluetooth
schnf30 1:a963d11a19d2 29 blue.printf("Gps Locked,%d,%06.0lf,%d,%f,%c,%lf,%c,%.0lf,%.0lf,$\r\n",gps.nbsattelite(),gps.time(),gps.lock(),gps.latitude(),gps.ns(),gps.longitude(),gps.ew(),gps.vitesse(),gps.vitesse_gps());
schnf30 0:49a81d0d029d 30 #else
schnf30 1:a963d11a19d2 31 pc.printf("Gps Locked,%d,%06.0lf,%d,%f,%c,%lf,%c,%.0lf,%.0lf,$\r\n",gps.nbsattelite(),gps.time(),gps.lock(),gps.latitude(),gps.ns(),gps.longitude(),gps.ew(),gps.vitesse(),gps.vitesse_gps());
schnf30 0:49a81d0d029d 32 #endif
schnf30 0:49a81d0d029d 33 }
schnf30 0:49a81d0d029d 34
schnf30 0:49a81d0d029d 35 else {
schnf30 0:49a81d0d029d 36 #ifdef bluetooth
schnf30 1:a963d11a19d2 37 blue.printf("Gps UnLocked,%d,%06.0lf,%d,%lf,%c,%lf,%c,%s,%s,$\r\n",gps.nbsattelite(),gps.time(),gps.lock(),gps.latitude(),gps.ns(),gps.longitude(),gps.ew(),"--","--");
schnf30 0:49a81d0d029d 38 #else
schnf30 1:a963d11a19d2 39 pc.printf("Gps UnLocked,%d,%06.0lf,%d,%lf,%c,%lf,%c,%s,%s,$\r\n",gps.nbsattelite(),gps.time(),gps.lock(),gps.latitude(),gps.ns(),gps.longitude(),gps.ew(),"--","--");
schnf30 0:49a81d0d029d 40 #endif
schnf30 0:49a81d0d029d 41 }
schnf30 0:49a81d0d029d 42 }
schnf30 0:49a81d0d029d 43 }
schnf30 0:49a81d0d029d 44 }