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 int tt, hours, minutes, seconds, tday; 00031 int months[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; 00032 printf("Thread Initialized\r\n"); 00033 while(true) { 00034 char latBuffer[16], lonBuffer[16]; 00035 gps.getLatitude(latBuffer); 00036 gps.getLongitude(lonBuffer); 00037 00038 // Utilize latitude and longitude values here 00039 printf("\r\nLa=%s Lo=%s\r\n", latBuffer, lonBuffer); 00040 tt = gps.gps_zda.utc_time; 00041 hours = tt / 10000; 00042 tt = tt - (hours*10000); 00043 minutes = tt / 100; 00044 seconds = tt - (minutes*100); 00045 // Correct UTC to PAcific time 00046 hours -= 7; 00047 tday = gps.gps_zda.day; 00048 if(hours < 0) { // UTC Correct 00049 hours += 24; 00050 tday -= 1; 00051 if(!tday) { 00052 tday = months[gps.gps_zda.month]; 00053 } 00054 } 00055 printf("\r\n%02d", seconds); 00056 wait(1); 00057 } 00058 } 00059 00060 int main() { 00061 GPS_init(); 00062 printf("GPS Initialized\r\n"); 00063 // Start a thread to get updated GPS values 00064 gpsThread.start(callback(gps_updater_thread)); 00065 00066 // do nothing while the library does all the work 00067 while (true) { 00068 00069 } 00070 00071 return 0; 00072 }
Generated on Sun Jul 17 2022 00:46:36 by
1.7.2
