GPS + Logging
Dependencies: FatFileSystem MBed_Adafruit-GPS-Library mbed
Fork of SDHCFileSystem by
Diff: main.cpp
- Revision:
- 3:54628390bca8
- Parent:
- 2:d5500685a878
--- a/main.cpp Thu Nov 19 20:24:50 2015 +0000 +++ b/main.cpp Fri Nov 20 01:59:33 2015 +0000 @@ -1,21 +1,22 @@ -//https://developer.mbed.org/users/mlee350/notebook/adafruit-ultimate-gps-breakout-board/ -#include "mbed.h" -#include "MBed_Adafruit_GPS.h" -#include "string" -#include "SDHCFileSystem.h" + #include "mbed.h" + #include "string" + #include "SDHCFileSystem.h" + #include "MBed_Adafruit_GPS.h" Serial * gps_Serial; Serial pc (USBTX, USBRX); -SDFileSystem sd(p5, p6, p7, p8, "sd"); // mosi, miso, sclk, cs - -int main() { - +SDFileSystem sd(p5, p6, p7, p8, "sd"); // mosi, miso, sclk, cs + + int main() { + printf("Hello World!\n"); + mkdir("/sd/mydir", 0777); - FILE *fp = fopen("/sd/mydir/GPS_Logging.txt", "a"); + FILE *fp = fopen("/sd/mydir/sdtest.txt", "a"); if(fp == NULL) { error("Could not open file for write\n"); } + fprintf(fp, "Hello fun SD Card World!\n"); pc.baud(115200); //sets virtual COM serial communication to high rate; this is to allow more time to be spent on GPS retrieval @@ -54,20 +55,27 @@ //note if refresh_Time is too low or pc.baud is too low, GPS data may be lost during printing if (refresh_Timer.read_ms() >= refresh_Time) { refresh_Timer.reset(); - FILE *fp = fopen("/sd/mydir/GPS_Logging.txt", "a"); + FILE *fp = fopen("/sd/mydir/sdtest.txt", "a"); if(fp == NULL) { error("Could not open file for write\n"); } fprintf(fp, "-------------------------------------\n"); + wait(0.05); fprintf(fp, "Fix: %d Quality: %d\n", (int) myGPS.fix, (int) myGPS.fixquality); + wait(0.05); if (myGPS.fix) { - fprintf(fp, "Location: %5.2f%c, %5.2f%c\n", myGPS.latitude, myGPS.lat, myGPS.longitude, myGPS.lon); + fprintf(fp, "Location: %5.7f%c, %5.7f%c\n", myGPS.latitude, myGPS.lat, myGPS.longitude, myGPS.lon); + wait(0.05); fprintf(fp, "Speed: %5.2f knots\n", myGPS.speed); - fprintf(fp, "Angle: %5.2f\n", myGPS.angle); - fprintf(fp, "Altitude: %5.2f\n", myGPS.altitude); + wait(0.05); + fprintf(fp, "Angle: %5.7f\n", myGPS.angle); + wait(0.05); + fprintf(fp, "Altitude: %5.7f\n", myGPS.altitude); + wait(0.05); fprintf(fp, "Satellites: %d\n", myGPS.satellites); + wait(0.05); } fclose(fp); } - } -} \ No newline at end of file + } + } \ No newline at end of file