a program i made a while back to log gps/accelerometer data
Dependencies: FatFileSystem mbed
GPS_LS20031.cpp@0:82a02991476c, 2012-09-08 (annotated)
- Committer:
- Xach
- Date:
- Sat Sep 08 20:40:58 2012 +0000
- Revision:
- 0:82a02991476c
a program i made a while back to log gps/accelerometer data
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Xach | 0:82a02991476c | 1 | |
Xach | 0:82a02991476c | 2 | #include "GPS_LS20031.h" |
Xach | 0:82a02991476c | 3 | #include "mbed.h" |
Xach | 0:82a02991476c | 4 | |
Xach | 0:82a02991476c | 5 | |
Xach | 0:82a02991476c | 6 | |
Xach | 0:82a02991476c | 7 | char checkSum(char* theseChars) { |
Xach | 0:82a02991476c | 8 | char check = 0; |
Xach | 0:82a02991476c | 9 | // iterate over the string, XOR each byte with the total sum: |
Xach | 0:82a02991476c | 10 | |
Xach | 0:82a02991476c | 11 | for (int c = 1;theseChars[c]!= '*'; c++) { |
Xach | 0:82a02991476c | 12 | check = char(check ^ theseChars[c]); |
Xach | 0:82a02991476c | 13 | } |
Xach | 0:82a02991476c | 14 | // return the result |
Xach | 0:82a02991476c | 15 | return check; |
Xach | 0:82a02991476c | 16 | } |
Xach | 0:82a02991476c | 17 | |
Xach | 0:82a02991476c | 18 | bool NMEA_parse(char *msg) { |
Xach | 0:82a02991476c | 19 | char ns, ew,av; |
Xach | 0:82a02991476c | 20 | float magVar; |
Xach | 0:82a02991476c | 21 | |
Xach | 0:82a02991476c | 22 | |
Xach | 0:82a02991476c | 23 | // Check if it is a GPGGA msg (matches both locked and non-locked msg) |
Xach | 0:82a02991476c | 24 | if (sscanf(msg, "$GPRMC,%f,%c,%f,%c,%f,%c,%f,%f,%f", &timeG, &av, &latitude, &ns, &longitude, &ew, &speed_knotts, &magVar, &date) >= 1) { |
Xach | 0:82a02991476c | 25 | if (av == 'A') { |
Xach | 0:82a02991476c | 26 | if (ns == 'S') { |
Xach | 0:82a02991476c | 27 | latitude *= -1.0; |
Xach | 0:82a02991476c | 28 | } |
Xach | 0:82a02991476c | 29 | if (ew == 'W') { |
Xach | 0:82a02991476c | 30 | longitude *= -1.0; |
Xach | 0:82a02991476c | 31 | } |
Xach | 0:82a02991476c | 32 | return true; |
Xach | 0:82a02991476c | 33 | /* float degrees = trunc(latitude / 100.0f); |
Xach | 0:82a02991476c | 34 | float minutes = latitude - (degrees * 100.0f); |
Xach | 0:82a02991476c | 35 | latitude = degrees + minutes / 60.0f; |
Xach | 0:82a02991476c | 36 | degrees = trunc(longitude / 100.0f); //a term had to be removed from this line |
Xach | 0:82a02991476c | 37 | minutes = longitude - (degrees * 100.0f); |
Xach | 0:82a02991476c | 38 | longitude = degrees + minutes / 60.0f;*/ |
Xach | 0:82a02991476c | 39 | } |
Xach | 0:82a02991476c | 40 | else { |
Xach | 0:82a02991476c | 41 | longitude = 0.0; |
Xach | 0:82a02991476c | 42 | latitude = 0.0; |
Xach | 0:82a02991476c | 43 | return false; |
Xach | 0:82a02991476c | 44 | } |
Xach | 0:82a02991476c | 45 | |
Xach | 0:82a02991476c | 46 | } |
Xach | 0:82a02991476c | 47 | return false; |
Xach | 0:82a02991476c | 48 | |
Xach | 0:82a02991476c | 49 | } |