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.
main.cpp@1:4939dd38bafd, 2019-02-12 (annotated)
- Committer:
- stersky
- Date:
- Tue Feb 12 14:51:04 2019 +0000
- Revision:
- 1:4939dd38bafd
- Parent:
- 0:39b09b3d8731
ok
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| Michael Ray | 0:39b09b3d8731 | 1 | |
| Michael Ray | 0:39b09b3d8731 | 2 | #include "mbed.h" | 
| Michael Ray | 0:39b09b3d8731 | 3 | |
| Michael Ray | 0:39b09b3d8731 | 4 | #include "GroveGPS.h" | 
| Michael Ray | 0:39b09b3d8731 | 5 | |
| stersky | 1:4939dd38bafd | 6 | Serial gps_serial(p9, p10, 9600); | 
| stersky | 1:4939dd38bafd | 7 | Serial pc(USBTX, USBRX); //Initialise une liason série via le connecteur USB du pc | 
| Michael Ray | 0:39b09b3d8731 | 8 | |
| Michael Ray | 0:39b09b3d8731 | 9 | Thread gpsThread; | 
| Michael Ray | 0:39b09b3d8731 | 10 | GroveGPS gps; | 
| Michael Ray | 0:39b09b3d8731 | 11 | |
| Michael Ray | 0:39b09b3d8731 | 12 | // Runs at 1Hz and updates the GPS location every second | 
| Michael Ray | 0:39b09b3d8731 | 13 | void gps_updater_thread() { | 
| stersky | 1:4939dd38bafd | 14 | char i; | 
| Michael Ray | 0:39b09b3d8731 | 15 | while(true) { | 
| Michael Ray | 0:39b09b3d8731 | 16 | char latBuffer[16], lonBuffer[16]; | 
| Michael Ray | 0:39b09b3d8731 | 17 | gps.getLatitude(latBuffer); | 
| Michael Ray | 0:39b09b3d8731 | 18 | gps.getLongitude(lonBuffer); | 
| Michael Ray | 0:39b09b3d8731 | 19 | |
| Michael Ray | 0:39b09b3d8731 | 20 | // Utilize latitude and longitude values here | 
| stersky | 1:4939dd38bafd | 21 | pc.printf("Latitude: %s, Longitude: %s\n\r", latBuffer, lonBuffer); | 
| stersky | 1:4939dd38bafd | 22 | /*for(i=0;i<16;i++) | 
| stersky | 1:4939dd38bafd | 23 | { | 
| stersky | 1:4939dd38bafd | 24 | pc.printf("%c ",latBuffer[i]); | 
| stersky | 1:4939dd38bafd | 25 | } | 
| stersky | 1:4939dd38bafd | 26 | pc.printf("\n\r");*/ | 
| Michael Ray | 0:39b09b3d8731 | 27 | wait(1); | 
| Michael Ray | 0:39b09b3d8731 | 28 | } | 
| Michael Ray | 0:39b09b3d8731 | 29 | } | 
| Michael Ray | 0:39b09b3d8731 | 30 | |
| Michael Ray | 0:39b09b3d8731 | 31 | int main() { | 
| stersky | 1:4939dd38bafd | 32 | |
| stersky | 1:4939dd38bafd | 33 | pc.baud(115200);//Initialise la vitesse de la communication série | 
| Michael Ray | 0:39b09b3d8731 | 34 | |
| Michael Ray | 0:39b09b3d8731 | 35 | // Start a thread to get updated GPS values | 
| Michael Ray | 0:39b09b3d8731 | 36 | gpsThread.start(gps_updater_thread); | 
| Michael Ray | 0:39b09b3d8731 | 37 | |
| Michael Ray | 0:39b09b3d8731 | 38 | // Read the serial bus to get NMEA GPS details | 
| Michael Ray | 0:39b09b3d8731 | 39 | while (true) { | 
| Michael Ray | 0:39b09b3d8731 | 40 | if (gps_serial.readable()) { | 
| Michael Ray | 0:39b09b3d8731 | 41 | gps.readCharacter(gps_serial.getc()); | 
| Michael Ray | 0:39b09b3d8731 | 42 | } | 
| Michael Ray | 0:39b09b3d8731 | 43 | } | 
| Michael Ray | 0:39b09b3d8731 | 44 | |
| Michael Ray | 0:39b09b3d8731 | 45 | return 0; | 
| Michael Ray | 0:39b09b3d8731 | 46 | } |