modifiche posizione iniziale e sistema d'allarme.
Dependencies: MTK3339 TextLCD mbed tsi_sensor
Fork of app_gps by
main.cpp@0:828a0c36c3e2, 2013-11-07 (annotated)
- Committer:
- embeddedartists
- Date:
- Thu Nov 07 11:53:56 2013 +0000
- Revision:
- 0:828a0c36c3e2
- Child:
- 1:80d31bcee0e5
First commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
embeddedartists | 0:828a0c36c3e2 | 1 | #include "mbed.h" |
embeddedartists | 0:828a0c36c3e2 | 2 | #include "MTK3339.h" |
embeddedartists | 0:828a0c36c3e2 | 3 | |
embeddedartists | 0:828a0c36c3e2 | 4 | static int waitData = 0; |
embeddedartists | 0:828a0c36c3e2 | 5 | static MTK3339 gps(P4_22, P4_23); |
embeddedartists | 0:828a0c36c3e2 | 6 | |
embeddedartists | 0:828a0c36c3e2 | 7 | |
embeddedartists | 0:828a0c36c3e2 | 8 | static void dataAvailable() { |
embeddedartists | 0:828a0c36c3e2 | 9 | waitData |= gps.getAvailableDataType(); |
embeddedartists | 0:828a0c36c3e2 | 10 | } |
embeddedartists | 0:828a0c36c3e2 | 11 | |
embeddedartists | 0:828a0c36c3e2 | 12 | int main(void) { |
embeddedartists | 0:828a0c36c3e2 | 13 | |
embeddedartists | 0:828a0c36c3e2 | 14 | gps.start(&dataAvailable, (MTK3339::NmeaGga|MTK3339::NmeaVtg)); |
embeddedartists | 0:828a0c36c3e2 | 15 | |
embeddedartists | 0:828a0c36c3e2 | 16 | while(1) { |
embeddedartists | 0:828a0c36c3e2 | 17 | while(waitData == 0); |
embeddedartists | 0:828a0c36c3e2 | 18 | |
embeddedartists | 0:828a0c36c3e2 | 19 | if ((waitData & MTK3339::NmeaGga) != 0) { |
embeddedartists | 0:828a0c36c3e2 | 20 | waitData &= ~(MTK3339::NmeaGga); |
embeddedartists | 0:828a0c36c3e2 | 21 | printf("gpa: fix=%d, sats=%d, alt=%f, lat=%f, lon=%f\n", |
embeddedartists | 0:828a0c36c3e2 | 22 | gps.gga.fix, gps.gga.satellites, gps.gga.altitude, |
embeddedartists | 0:828a0c36c3e2 | 23 | gps.getLatitudeAsDegrees(), gps.getLongitudeAsDegrees()); |
embeddedartists | 0:828a0c36c3e2 | 24 | } |
embeddedartists | 0:828a0c36c3e2 | 25 | if ((waitData & MTK3339::NmeaVtg) != 0) { |
embeddedartists | 0:828a0c36c3e2 | 26 | waitData &= ~(MTK3339::NmeaVtg); |
embeddedartists | 0:828a0c36c3e2 | 27 | printf("vtg: course=%f, speed=%f km/h, mode=%c\n", |
embeddedartists | 0:828a0c36c3e2 | 28 | gps.vtg.course, gps.vtg.speedKmHour, gps.vtg.mode); |
embeddedartists | 0:828a0c36c3e2 | 29 | } |
embeddedartists | 0:828a0c36c3e2 | 30 | |
embeddedartists | 0:828a0c36c3e2 | 31 | waitData &= (MTK3339::NmeaGga|MTK3339::NmeaVtg); |
embeddedartists | 0:828a0c36c3e2 | 32 | } |
embeddedartists | 0:828a0c36c3e2 | 33 | |
embeddedartists | 0:828a0c36c3e2 | 34 | |
embeddedartists | 0:828a0c36c3e2 | 35 | |
embeddedartists | 0:828a0c36c3e2 | 36 | } |