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 GroveGPS-Example by
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 extern int GPS_init(); 00024 extern GroveGPS gps; 00025 Thread gpsThread(osPriorityNormal); 00026 00027 00028 // Runs at 1Hz and updates the GPS location every second 00029 void gps_updater_thread() { 00030 printf("Thread Initialized\r\n"); 00031 while(true) { 00032 char latBuffer[16], lonBuffer[16]; 00033 gps.getLatitude(latBuffer); 00034 gps.getLongitude(lonBuffer); 00035 00036 // Utilize latitude and longitude values here 00037 printf("\r\nLa=%s Lo=%s\r\n", latBuffer, lonBuffer); 00038 wait(1); 00039 } 00040 } 00041 00042 int main() { 00043 GPS_init(); 00044 printf("GPS Initialized\r\n"); 00045 // Start a thread to get updated GPS values 00046 gpsThread.start(callback(gps_updater_thread)); 00047 00048 // do nothing while the library does all the work 00049 while (true) { 00050 // Include a long wait to unblock the threads 00051 wait(100000); 00052 } 00053 00054 return 0; 00055 }
Generated on Thu Jul 14 2022 17:34:43 by
1.7.2
