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
00001 // ---------------------------------------------------------------------------- 00002 // Copyright 2016-2017 ARM Ltd. 00003 // 00004 // SPDX-License-Identifier: Apache-2.0 00005 // 00006 // Licensed under the Apache License, Version 2.0 (the "License"); 00007 // you may not use this file except in compliance with the License. 00008 // You may obtain a copy of the License at 00009 // 00010 // http://www.apache.org/licenses/LICENSE-2.0 00011 // 00012 // Unless required by applicable law or agreed to in writing, software 00013 // distributed under the License is distributed on an "AS IS" BASIS, 00014 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00015 // See the License for the specific language governing permissions and 00016 // limitations under the License. 00017 // ---------------------------------------------------------------------------- 00018 00019 #include "mbed.h" 00020 00021 #include "GroveGPS.h" 00022 00023 Serial gps_serial(D1, D0, 9600); 00024 00025 Thread gpsThread; 00026 GroveGPS gps; 00027 00028 // Runs at 1Hz and updates the GPS location every second 00029 void gps_updater_thread() { 00030 while(true) { 00031 char latBuffer[16], lonBuffer[16]; 00032 gps.getLatitude(latBuffer); 00033 gps.getLongitude(lonBuffer); 00034 00035 // Utilize latitude and longitude values here 00036 printf("Latitude: %f\n, Longitude: %f\n", latBuffer, lonBuffer); 00037 wait(1); 00038 } 00039 } 00040 00041 int main() { 00042 00043 // Start a thread to get updated GPS values 00044 gpsThread.start(gps_updater_thread); 00045 00046 // Read the serial bus to get NMEA GPS details 00047 while (true) { 00048 if (gps_serial.readable()) { 00049 gps.readCharacter(gps_serial.getc()); 00050 } 00051 } 00052 00053 return 0; 00054 }
Generated on Mon Jul 18 2022 17:38:21 by
1.7.2
Grove GPS