Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of HL_GPS_Example by
main.cpp
- Committer:
- HackerLabATTKit01
- Date:
- 2017-03-14
- Revision:
- 20:a728f1075fb1
- Parent:
- 18:7ba014531492
- Child:
- 21:dfa20810d1d0
File content as of revision 20:a728f1075fb1:
#include "mbed.h" #include "GPRMCSentence.h" #define GPSBUFFSIZE 256 Serial pc(USBTX, USBRX); // tx, rx Serial xgps(PTC15, PTC14); // If using MODSERIAL (as part of the WNC Interface for the AT&T IoT Starter Kit): // MODSERIAL xgps(PTC15, PTC14, GPSBUFFSIZE, GPSBUFFSIZE); unsigned gpsSentenceIndex = 0; char gpsSentence[GPSBUFFSIZE]; GPRMCSentence lastPosition; void clearGpsSentence() { for(int i=0;i<GPSBUFFSIZE;i++) gpsSentence[i] = '\0'; gpsSentenceIndex = 0; } int main() { pc.printf("Where am I? ----------- \n"); clearGpsSentence(); while(1) { gpsSentence[gpsSentenceIndex] = xgps.getc(); //pc.putc(gpsSentence[gpsSentenceIndex]); gpsSentenceIndex++; if(gpsSentence[gpsSentenceIndex - 1] == '\n') { gpsSentence[gpsSentenceIndex] = '\0'; if (parseGPRMCStrToStruct(gpsSentence, &lastPosition) >= 0) { pc.printf("time: %s Status: %c \n\r" , lastPosition.time, lastPosition.status); pc.printf("Lat : %s %c \n\r" , lastPosition.latitude, lastPosition.latdir); pc.printf("Long: %s %c \n\r" , lastPosition.longitude, lastPosition.longdir); } clearGpsSentence(); } } } /*include "mbed.h" DigitalOut rled(LED_RED); DigitalOut gled(LED_GREEN); DigitalOut bled(LED_BLUE); int main() { while(1) { rled = 0; gled = 0; bled = 0; wait(0.2); rled = 0; gled = 0; bled = 1; wait(0.2); rled = 0; gled = 1; bled = 0; wait(0.2); rled = 0; gled = 1; bled = 1; wait(0.2); rled = 1; gled = 0; bled = 0; wait(0.2); rled = 1; gled = 0; bled = 1; wait(0.2); rled = 1; gled = 1; bled = 0; wait(0.2); rled = 1; gled = 1; bled = 1; wait(0.2); } }*/