gps
Dependencies: mbed gps_event_vitesse
main.cpp@0:97a29d1f8dd5, 2016-05-09 (annotated)
- Committer:
- schnf30
- Date:
- Mon May 09 19:20:30 2016 +0000
- Revision:
- 0:97a29d1f8dd5
- Child:
- 2:64eaefb1790e
Test Gps NMEA avec Event
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
schnf30 | 0:97a29d1f8dd5 | 1 | #include "mbed.h" |
schnf30 | 0:97a29d1f8dd5 | 2 | #include "gps_event_vitesse.h" |
schnf30 | 0:97a29d1f8dd5 | 3 | #define PCBAUD 9600 |
schnf30 | 0:97a29d1f8dd5 | 4 | #define GPSRX p10 |
schnf30 | 0:97a29d1f8dd5 | 5 | #define GPSTX p9 |
schnf30 | 0:97a29d1f8dd5 | 6 | #define GPSBAUD 9600 |
schnf30 | 0:97a29d1f8dd5 | 7 | |
schnf30 | 0:97a29d1f8dd5 | 8 | Gps gps(GPSTX,GPSRX); |
schnf30 | 0:97a29d1f8dd5 | 9 | Serial pc(USBTX, USBRX); |
schnf30 | 0:97a29d1f8dd5 | 10 | DigitalOut myled(LED1); |
schnf30 | 0:97a29d1f8dd5 | 11 | |
schnf30 | 0:97a29d1f8dd5 | 12 | int main() |
schnf30 | 0:97a29d1f8dd5 | 13 | { |
schnf30 | 0:97a29d1f8dd5 | 14 | pc.baud(PCBAUD); |
schnf30 | 0:97a29d1f8dd5 | 15 | gps.baud(GPSBAUD); |
schnf30 | 0:97a29d1f8dd5 | 16 | |
schnf30 | 0:97a29d1f8dd5 | 17 | pc.printf("Hello, Gps event.\r\n"); |
schnf30 | 0:97a29d1f8dd5 | 18 | pc.printf("Patientez attente Gps\r\n"); |
schnf30 | 0:97a29d1f8dd5 | 19 | while(1) { |
schnf30 | 0:97a29d1f8dd5 | 20 | if (gps.sample()) { |
schnf30 | 0:97a29d1f8dd5 | 21 | pc.printf("Trame $GPGGA recue "); |
schnf30 | 0:97a29d1f8dd5 | 22 | if (gps.lock()) |
schnf30 | 0:97a29d1f8dd5 | 23 | { |
schnf30 | 0:97a29d1f8dd5 | 24 | pc.printf("Gps verouille %f, %f, %c ,%f ,%c ,%d\r\n",gps.time(),gps.latitude(),gps.ns(),gps.longitude(),gps.ew(),gps.nbsattelite()); |
schnf30 | 0:97a29d1f8dd5 | 25 | if (gps.vitesse_ok()) pc.printf("Vitesse %fkm/h",gps.vitesse()); |
schnf30 | 0:97a29d1f8dd5 | 26 | } |
schnf30 | 0:97a29d1f8dd5 | 27 | |
schnf30 | 0:97a29d1f8dd5 | 28 | else pc.printf("Gps non verouille, %d sattelite(s) : %f, %f, %c ,%f ,%c\r\n",gps.nbsattelite(),gps.time(),gps.latitude(),gps.ns(),gps.longitude(),gps.ew()); |
schnf30 | 0:97a29d1f8dd5 | 29 | } |
schnf30 | 0:97a29d1f8dd5 | 30 | } |
schnf30 | 0:97a29d1f8dd5 | 31 | } |