Weather Station using an mBed microcontroller and a Windows CE Device
Dependencies: TextLCD mbed HMC6352
GPS.h@0:75e6a2e50519, 2011-12-15 (annotated)
- Committer:
- mafischl
- Date:
- Thu Dec 15 13:38:51 2011 +0000
- Revision:
- 0:75e6a2e50519
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mafischl | 0:75e6a2e50519 | 1 | /* mbed EM-406 GPS Module Library |
mafischl | 0:75e6a2e50519 | 2 | * Copyright (c) 2008-2010, sford |
mafischl | 0:75e6a2e50519 | 3 | * |
mafischl | 0:75e6a2e50519 | 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
mafischl | 0:75e6a2e50519 | 5 | * of this software and associated documentation files (the "Software"), to deal |
mafischl | 0:75e6a2e50519 | 6 | * in the Software without restriction, including without limitation the rights |
mafischl | 0:75e6a2e50519 | 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
mafischl | 0:75e6a2e50519 | 8 | * copies of the Software, and to permit persons to whom the Software is |
mafischl | 0:75e6a2e50519 | 9 | * furnished to do so, subject to the following conditions: |
mafischl | 0:75e6a2e50519 | 10 | * |
mafischl | 0:75e6a2e50519 | 11 | * The above copyright notice and this permission notice shall be included in |
mafischl | 0:75e6a2e50519 | 12 | * all copies or substantial portions of the Software. |
mafischl | 0:75e6a2e50519 | 13 | * |
mafischl | 0:75e6a2e50519 | 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
mafischl | 0:75e6a2e50519 | 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
mafischl | 0:75e6a2e50519 | 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
mafischl | 0:75e6a2e50519 | 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
mafischl | 0:75e6a2e50519 | 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
mafischl | 0:75e6a2e50519 | 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
mafischl | 0:75e6a2e50519 | 20 | * THE SOFTWARE. |
mafischl | 0:75e6a2e50519 | 21 | */ |
mafischl | 0:75e6a2e50519 | 22 | |
mafischl | 0:75e6a2e50519 | 23 | #include "mbed.h" |
mafischl | 0:75e6a2e50519 | 24 | |
mafischl | 0:75e6a2e50519 | 25 | #ifndef MBED_GPS_H |
mafischl | 0:75e6a2e50519 | 26 | #define MBED_GPS_H |
mafischl | 0:75e6a2e50519 | 27 | |
mafischl | 0:75e6a2e50519 | 28 | /** A GPS interface for reading from a Globalsat EM-406 GPS Module */ |
mafischl | 0:75e6a2e50519 | 29 | class GPS { |
mafischl | 0:75e6a2e50519 | 30 | public: |
mafischl | 0:75e6a2e50519 | 31 | |
mafischl | 0:75e6a2e50519 | 32 | /** Create the GPS interface, connected to the specified serial port |
mafischl | 0:75e6a2e50519 | 33 | */ |
mafischl | 0:75e6a2e50519 | 34 | GPS(PinName tx, PinName rx); |
mafischl | 0:75e6a2e50519 | 35 | |
mafischl | 0:75e6a2e50519 | 36 | /** Sample the incoming GPS data, returning whether there is a lock |
mafischl | 0:75e6a2e50519 | 37 | * |
mafischl | 0:75e6a2e50519 | 38 | * @return 1 if there was a lock when the sample was taken (and therefore .longitude and .latitude are valid), else 0 |
mafischl | 0:75e6a2e50519 | 39 | */ |
mafischl | 0:75e6a2e50519 | 40 | int sample(); |
mafischl | 0:75e6a2e50519 | 41 | |
mafischl | 0:75e6a2e50519 | 42 | /** The longitude (call sample() to set) */ |
mafischl | 0:75e6a2e50519 | 43 | float longitude; |
mafischl | 0:75e6a2e50519 | 44 | |
mafischl | 0:75e6a2e50519 | 45 | /** The latitude (call sample() to set) */ |
mafischl | 0:75e6a2e50519 | 46 | float latitude; |
mafischl | 0:75e6a2e50519 | 47 | |
mafischl | 0:75e6a2e50519 | 48 | /** Create a value for gps lock/unlocked */ |
mafischl | 0:75e6a2e50519 | 49 | int lock; |
mafischl | 0:75e6a2e50519 | 50 | |
mafischl | 0:75e6a2e50519 | 51 | /** Altitude of Sensor from Sea Level */ |
mafischl | 0:75e6a2e50519 | 52 | float altitude; |
mafischl | 0:75e6a2e50519 | 53 | |
mafischl | 0:75e6a2e50519 | 54 | /** Number of Satillites */ |
mafischl | 0:75e6a2e50519 | 55 | int numSat; |
mafischl | 0:75e6a2e50519 | 56 | |
mafischl | 0:75e6a2e50519 | 57 | /** Horizontal Dilution */ |
mafischl | 0:75e6a2e50519 | 58 | float horDil; |
mafischl | 0:75e6a2e50519 | 59 | |
mafischl | 0:75e6a2e50519 | 60 | /** Time */ |
mafischl | 0:75e6a2e50519 | 61 | float GPStime; |
mafischl | 0:75e6a2e50519 | 62 | |
mafischl | 0:75e6a2e50519 | 63 | /** Date */ |
mafischl | 0:75e6a2e50519 | 64 | int GPSdate; |
mafischl | 0:75e6a2e50519 | 65 | |
mafischl | 0:75e6a2e50519 | 66 | private: |
mafischl | 0:75e6a2e50519 | 67 | float trunc(float v); |
mafischl | 0:75e6a2e50519 | 68 | void getline(); |
mafischl | 0:75e6a2e50519 | 69 | |
mafischl | 0:75e6a2e50519 | 70 | Serial _gps; |
mafischl | 0:75e6a2e50519 | 71 | char msg[256]; |
mafischl | 0:75e6a2e50519 | 72 | |
mafischl | 0:75e6a2e50519 | 73 | }; |
mafischl | 0:75e6a2e50519 | 74 | |
mafischl | 0:75e6a2e50519 | 75 | #endif |