GPS Program for Eco Car
Dependencies: MBed_Adafruit-GPS-Library SDFileSystem SDWriteTestShellEco TextLCD mbed
Fork of SDWriteTestShellEco by
main.cpp
- Committer:
- mburns1
- Date:
- 2015-03-30
- Revision:
- 1:4eff6f5ccb2b
- Parent:
- 0:d96c133bf9d2
File content as of revision 1:4eff6f5ccb2b:
#include "mbed.h" #include "SDFileSystem.h" #include "stdio.h" #include "string.h" #include "TextLCD.h" DigitalOut myled(LED1); //initialize on board LED DigitalIn toggle(p21); //initialize toggle switch Serial GPS(p9, p10); //initialize gps board Serial pc(USBTX, USBRX);//initialize serial pc connection SDFileSystem sd(p5,p6,p7,p11,"sd"); //Initializes filesystem (DI, D0, CLK, CS) TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7 int hasbeenopened = 1; int haslooped = 0; int main() { char cc; toggle.mode(PullUp); FILE *fp = fopen("/sd/gpsdata.txt", "a"); while(1){ while(toggle==1){ if (hasbeenopened==0){ FILE *fp = fopen("/sd/gpsdata.txt", "a"); hasbeenopened=1; } myled=1; cc = GPS.getc(); fprintf(fp,"%c", cc); char str1[2] = {cc , '\0'}; char str2[5] = ""; lcd.printf(strcpy(str2,str1)); haslooped=1; } myled=0; if (haslooped==1){ fclose(fp); hasbeenopened=0; haslooped=1; } } }