Grove GPS Example

Dependencies:   GroveGPS

Committer:
sarahmarshy
Date:
Tue Jun 04 21:06:53 2019 +0000
Revision:
3:93a9216a7c84
Parent:
2:c8839c41737b
Update GPS library;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
sarahmarshy 2:c8839c41737b 1 // ----------------------------------------------------------------------------
sarahmarshy 2:c8839c41737b 2 // Copyright 2019 ARM Ltd.
sarahmarshy 2:c8839c41737b 3 //
sarahmarshy 2:c8839c41737b 4 // SPDX-License-Identifier: Apache-2.0
sarahmarshy 2:c8839c41737b 5 //
sarahmarshy 2:c8839c41737b 6 // Licensed under the Apache License, Version 2.0 (the "License");
sarahmarshy 2:c8839c41737b 7 // you may not use this file except in compliance with the License.
sarahmarshy 2:c8839c41737b 8 // You may obtain a copy of the License at
sarahmarshy 2:c8839c41737b 9 //
sarahmarshy 2:c8839c41737b 10 // http://www.apache.org/licenses/LICENSE-2.0
sarahmarshy 2:c8839c41737b 11 //
sarahmarshy 2:c8839c41737b 12 // Unless required by applicable law or agreed to in writing, software
sarahmarshy 2:c8839c41737b 13 // distributed under the License is distributed on an "AS IS" BASIS,
sarahmarshy 2:c8839c41737b 14 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
sarahmarshy 2:c8839c41737b 15 // See the License for the specific language governing permissions and
sarahmarshy 2:c8839c41737b 16 // limitations under the License.
sarahmarshy 2:c8839c41737b 17 // ----------------------------------------------------------------------------
sarahmarshy 2:c8839c41737b 18
Michael Ray 0:39b09b3d8731 19 #include "mbed.h"
Michael Ray 0:39b09b3d8731 20 #include "GroveGPS.h"
Michael Ray 0:39b09b3d8731 21
sarahmarshy 3:93a9216a7c84 22 GroveGPS gps(A3, A2);
Michael Ray 0:39b09b3d8731 23
sarahmarshy 1:1497469db426 24 void read_gps() {
sarahmarshy 1:1497469db426 25 char latBuffer[16], lonBuffer[16];
sarahmarshy 1:1497469db426 26 gps.getLatitude(latBuffer);
sarahmarshy 1:1497469db426 27 gps.getLongitude(lonBuffer);
Michael Ray 0:39b09b3d8731 28
sarahmarshy 1:1497469db426 29 // Utilize latitude and longitude values here
sarahmarshy 1:1497469db426 30 printf("\r\nLatitude: %s\r\nLongitude: %s\r\n", latBuffer, lonBuffer);
Michael Ray 0:39b09b3d8731 31 }
Michael Ray 0:39b09b3d8731 32
Michael Ray 0:39b09b3d8731 33 int main() {
sarahmarshy 1:1497469db426 34 EventQueue queue;
sarahmarshy 1:1497469db426 35 queue.call_every(1000, read_gps);
sarahmarshy 1:1497469db426 36 gps.start();
sarahmarshy 1:1497469db426 37 queue.dispatch();
sarahmarshy 1:1497469db426 38 }