C027_C20_U20_G35 revB with SARA-G350 GPS library.
Dependencies: GPS_C027_C20_U20_G35_revB_SARA_G350 mbed
Fork of C027_HelloWorld by
main.cpp@6:7f0ed1d69dc1, 2014-02-22 (annotated)
- Committer:
- timrock
- Date:
- Sat Feb 22 13:28:33 2014 +0000
- Revision:
- 6:7f0ed1d69dc1
- Parent:
- 5:41b123533b79
Add a sample program to show how to use the library
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mazgch | 0:7626456dca2c | 1 | #include "mbed.h" |
timrock | 6:7f0ed1d69dc1 | 2 | #include "GPS.h" |
timrock | 6:7f0ed1d69dc1 | 3 | |
timrock | 6:7f0ed1d69dc1 | 4 | Serial pc(USBTX, USBRX); |
timrock | 6:7f0ed1d69dc1 | 5 | GPS gps(P0_10, P0_11, 9600); |
mazgch | 0:7626456dca2c | 6 | |
mazgch | 0:7626456dca2c | 7 | int main() { |
timrock | 6:7f0ed1d69dc1 | 8 | pc.baud(9600); |
timrock | 6:7f0ed1d69dc1 | 9 | |
timrock | 6:7f0ed1d69dc1 | 10 | while (1) { |
timrock | 6:7f0ed1d69dc1 | 11 | wait(3); |
timrock | 6:7f0ed1d69dc1 | 12 | pc.printf("hello, a test \n"); |
timrock | 6:7f0ed1d69dc1 | 13 | gps.sample(); |
timrock | 6:7f0ed1d69dc1 | 14 | pc.printf("GPS Sats number is %d \n", gps.sats); |
timrock | 6:7f0ed1d69dc1 | 15 | |
timrock | 6:7f0ed1d69dc1 | 16 | if (gps.ns == 'S') |
timrock | 6:7f0ed1d69dc1 | 17 | pc.printf("GPS Latitude = %.4f South; ", gps.latitude * -1.0); |
timrock | 6:7f0ed1d69dc1 | 18 | else if (gps.ns == 'N') |
timrock | 6:7f0ed1d69dc1 | 19 | pc.printf("GPS Latitude = %.4f North; ", gps.latitude); |
timrock | 6:7f0ed1d69dc1 | 20 | if (gps.ew == 'W') |
timrock | 6:7f0ed1d69dc1 | 21 | pc.printf("Longitude = %.4f West; ", gps.longitude * - 1.0); |
timrock | 6:7f0ed1d69dc1 | 22 | else if (gps.ew == 'E') |
timrock | 6:7f0ed1d69dc1 | 23 | pc.printf("Longitude = %.4f East; ", gps.longitude); |
timrock | 6:7f0ed1d69dc1 | 24 | pc.printf("Alt = %.4f ", gps.alt); |
timrock | 6:7f0ed1d69dc1 | 25 | |
timrock | 6:7f0ed1d69dc1 | 26 | } |
timrock | 6:7f0ed1d69dc1 | 27 | |
timrock | 6:7f0ed1d69dc1 | 28 | |
mazgch | 0:7626456dca2c | 29 | } |