Grove GPS Example

Dependencies:   GroveGPS

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 // ----------------------------------------------------------------------------
00002 // Copyright 2019 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 #include "GroveGPS.h"
00021 
00022 GroveGPS gps(A3, A2);
00023 
00024 void read_gps() {
00025     char latBuffer[16], lonBuffer[16];
00026     gps.getLatitude(latBuffer);
00027     gps.getLongitude(lonBuffer);
00028 
00029     // Utilize latitude and longitude values here
00030     printf("\r\nLatitude: %s\r\nLongitude: %s\r\n", latBuffer, lonBuffer);
00031 }
00032 
00033 int main() {
00034     EventQueue queue;
00035     queue.call_every(1000, read_gps);
00036     gps.start();
00037     queue.dispatch();
00038 }