![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
gps
Dependencies: C12832_lcd FatFileSystemCpp GPS mbed MMA7660 PowerControl PwmIn
Fork of MSCUsbHost by
main.cpp@4:071ff93721f8, 2014-05-09 (annotated)
- Committer:
- AlexF64
- Date:
- Fri May 09 18:25:57 2014 +0000
- Revision:
- 4:071ff93721f8
- Parent:
- 0:e294af8d0e07
- Child:
- 6:9303188c8010
No changes
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
igorsk | 0:e294af8d0e07 | 1 | #include "mbed.h" |
AlexF64 | 4:071ff93721f8 | 2 | #include "GPS.h" |
AlexF64 | 4:071ff93721f8 | 3 | #include "C12832_lcd.h" |
igorsk | 0:e294af8d0e07 | 4 | #include "MSCFileSystem.h" |
AlexF64 | 4:071ff93721f8 | 5 | |
igorsk | 0:e294af8d0e07 | 6 | |
igorsk | 0:e294af8d0e07 | 7 | #define FSNAME "msc" |
AlexF64 | 4:071ff93721f8 | 8 | |
igorsk | 0:e294af8d0e07 | 9 | MSCFileSystem msc(FSNAME); |
AlexF64 | 4:071ff93721f8 | 10 | Serial pc(USBTX, USBRX); |
AlexF64 | 4:071ff93721f8 | 11 | GPS gps(p9, p10); |
AlexF64 | 4:071ff93721f8 | 12 | C12832_LCD lcd; |
AlexF64 | 4:071ff93721f8 | 13 | |
AlexF64 | 4:071ff93721f8 | 14 | float timing; |
igorsk | 0:e294af8d0e07 | 15 | |
AlexF64 | 4:071ff93721f8 | 16 | int main() { |
AlexF64 | 4:071ff93721f8 | 17 | |
AlexF64 | 4:071ff93721f8 | 18 | FILE *fp; |
AlexF64 | 4:071ff93721f8 | 19 | fp = fopen( "/" FSNAME "/GPSData.txt", "w"); |
AlexF64 | 4:071ff93721f8 | 20 | fprintf(fp,""); |
AlexF64 | 4:071ff93721f8 | 21 | fclose(fp); |
AlexF64 | 4:071ff93721f8 | 22 | |
AlexF64 | 4:071ff93721f8 | 23 | while(1) |
igorsk | 0:e294af8d0e07 | 24 | { |
AlexF64 | 4:071ff93721f8 | 25 | |
AlexF64 | 4:071ff93721f8 | 26 | if(gps.sample()) |
igorsk | 0:e294af8d0e07 | 27 | { |
AlexF64 | 4:071ff93721f8 | 28 | fp = fopen( "/" FSNAME "/GPSData.txt", "a"); |
AlexF64 | 4:071ff93721f8 | 29 | fprintf(fp, "%.1f ",timing); //time when read |
AlexF64 | 4:071ff93721f8 | 30 | fprintf(fp, "Longitude: %f ", gps.longitude); |
AlexF64 | 4:071ff93721f8 | 31 | fprintf(fp, "Latitude: %f\n", gps.latitude); |
AlexF64 | 4:071ff93721f8 | 32 | |
AlexF64 | 4:071ff93721f8 | 33 | pc.printf("%f, %f\r\n",gps.latitude,gps.longitude); |
AlexF64 | 4:071ff93721f8 | 34 | lcd.cls(); |
AlexF64 | 4:071ff93721f8 | 35 | lcd.locate(3,3); |
AlexF64 | 4:071ff93721f8 | 36 | lcd.printf("%.3f\n",gps.latitude);//print x to LCD at locate position |
AlexF64 | 4:071ff93721f8 | 37 | lcd.locate(28,3);//move LCD location for y component |
AlexF64 | 4:071ff93721f8 | 38 | lcd.printf("%.3f\n",gps.longitude);//print y to LCD to new locate position |
AlexF64 | 4:071ff93721f8 | 39 | |
AlexF64 | 4:071ff93721f8 | 40 | |
AlexF64 | 4:071ff93721f8 | 41 | wait(0.5); |
AlexF64 | 4:071ff93721f8 | 42 | fclose(fp); |
AlexF64 | 4:071ff93721f8 | 43 | timing = timing + 0.5; |
AlexF64 | 4:071ff93721f8 | 44 | } |
AlexF64 | 4:071ff93721f8 | 45 | |
AlexF64 | 4:071ff93721f8 | 46 | else |
AlexF64 | 4:071ff93721f8 | 47 | { |
AlexF64 | 4:071ff93721f8 | 48 | pc.printf("Oh Dear! No lock :(\r\n"); |
AlexF64 | 4:071ff93721f8 | 49 | lcd.cls(); |
AlexF64 | 4:071ff93721f8 | 50 | lcd.locate(3,3); |
AlexF64 | 4:071ff93721f8 | 51 | lcd.printf("No GPS Lock"); |
igorsk | 0:e294af8d0e07 | 52 | } |
AlexF64 | 4:071ff93721f8 | 53 | |
igorsk | 0:e294af8d0e07 | 54 | } |
AlexF64 | 4:071ff93721f8 | 55 | } |