GPS and Compass update every1 sec

Dependencies:   HMC6352 mbed

Committer:
airaylee
Date:
Thu Dec 05 23:57:55 2013 +0000
Revision:
3:5eba63777267
v1.4

Who changed what in which revision?

UserRevisionLine numberNew contents of line
airaylee 3:5eba63777267 1 /* mbed EM-406 GPS Module Library
airaylee 3:5eba63777267 2 * Copyright (c) 2008-2010, sford
airaylee 3:5eba63777267 3 *
airaylee 3:5eba63777267 4 * Permission is hereby granted, free of charge, to any person obtaining a copy
airaylee 3:5eba63777267 5 * of this software and associated documentation files (the "Software"), to deal
airaylee 3:5eba63777267 6 * in the Software without restriction, including without limitation the rights
airaylee 3:5eba63777267 7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
airaylee 3:5eba63777267 8 * copies of the Software, and to permit persons to whom the Software is
airaylee 3:5eba63777267 9 * furnished to do so, subject to the following conditions:
airaylee 3:5eba63777267 10 *
airaylee 3:5eba63777267 11 * The above copyright notice and this permission notice shall be included in
airaylee 3:5eba63777267 12 * all copies or substantial portions of the Software.
airaylee 3:5eba63777267 13 *
airaylee 3:5eba63777267 14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
airaylee 3:5eba63777267 15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
airaylee 3:5eba63777267 16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
airaylee 3:5eba63777267 17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
airaylee 3:5eba63777267 18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
airaylee 3:5eba63777267 19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
airaylee 3:5eba63777267 20 * THE SOFTWARE.
airaylee 3:5eba63777267 21 */
airaylee 3:5eba63777267 22
airaylee 3:5eba63777267 23 #include "mbed.h"
airaylee 3:5eba63777267 24
airaylee 3:5eba63777267 25 #ifndef MBED_GPS_H
airaylee 3:5eba63777267 26 #define MBED_GPS_H
airaylee 3:5eba63777267 27
airaylee 3:5eba63777267 28 /** A GPS interface for reading from a Globalsat EM-406 GPS Module */
airaylee 3:5eba63777267 29 class GPS {
airaylee 3:5eba63777267 30 public:
airaylee 3:5eba63777267 31
airaylee 3:5eba63777267 32 /** Create the GPS interface, connected to the specified serial port
airaylee 3:5eba63777267 33 */
airaylee 3:5eba63777267 34 GPS(PinName tx, PinName rx);
airaylee 3:5eba63777267 35
airaylee 3:5eba63777267 36 /** Sample the incoming GPS data, returning whether there is a lock
airaylee 3:5eba63777267 37 *
airaylee 3:5eba63777267 38 * @return 1 if there was a lock when the sample was taken (and therefore .longitude and .latitude are valid), else 0
airaylee 3:5eba63777267 39 */
airaylee 3:5eba63777267 40 int sample();
airaylee 3:5eba63777267 41
airaylee 3:5eba63777267 42 /** The longitude (call sample() to set) */
airaylee 3:5eba63777267 43 float longitude;
airaylee 3:5eba63777267 44
airaylee 3:5eba63777267 45 /** The latitude (call sample() to set) */
airaylee 3:5eba63777267 46 float latitude;
airaylee 3:5eba63777267 47
airaylee 3:5eba63777267 48 private:
airaylee 3:5eba63777267 49 float trunc(float v);
airaylee 3:5eba63777267 50 void getline();
airaylee 3:5eba63777267 51
airaylee 3:5eba63777267 52 Serial _gps;
airaylee 3:5eba63777267 53 char msg[256];
airaylee 3:5eba63777267 54
airaylee 3:5eba63777267 55 };
airaylee 3:5eba63777267 56
airaylee 3:5eba63777267 57 #endif