check two CRC types
[u360gts.git] / src / main / tracker / TinyGPS.h
bloba441aba80a562cdfe636cde622a9a7c12baa4f50
1 /*
2 TinyGPS - a small GPS library for Arduino providing basic NMEA parsing
3 Based on work by and "distance_to" and "course_to" courtesy of Maarten Lamers.
4 Suggestion to add satellites(), course_to(), and cardinal(), by Matt Monson.
5 Precision improvements suggested by Wayne Holder.
6 Copyright (C) 2008-2013 Mikal Hart
7 All rights reserved.
9 This library is free software; you can redistribute it and/or
10 modify it under the terms of the GNU Lesser General Public
11 License as published by the Free Software Foundation; either
12 version 2.1 of the License, or (at your option) any later version.
14 This library is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 Lesser General Public License for more details.
19 You should have received a copy of the GNU Lesser General Public
20 License along with this library; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
24 #define _GPS_VERSION 13 // software version of this library
25 #define _GPS_MPH_PER_KNOT 1.15077945
26 #define _GPS_MPS_PER_KNOT 0.51444444
27 #define _GPS_KMPH_PER_KNOT 1.852
28 #define _GPS_MILES_PER_METER 0.00062137112
29 #define _GPS_KM_PER_METER 0.001
30 // #define _GPS_NO_STATS
31 #define _GPRMC_TERM "GPRMC"
32 #define _GPGGA_TERM "GPGGA"
33 #define _GNGGA_TERM "GNGGA"
35 #define GPS_INVALID_AGE 0xFFFFFFFF
36 #define GPS_INVALID_ANGLE 999999999
37 #define GPS_INVALID_ALTITUDE 999999999
38 #define GPS_INVALID_DATE 0
39 #define GPS_INVALID_TIME 0xFFFFFFFF
40 #define GPS_INVALID_SPEED 999999999
41 #define GPS_INVALID_FIX_TIME 0xFFFFFFFF
42 #define GPS_INVALID_SATELLITES 0xFF
43 #define GPS_INVALID_HDOP 0xFFFFFFFF
45 static const float GPS_INVALID_F_ANGLE, GPS_INVALID_F_ALTITUDE, GPS_INVALID_F_SPEED;
47 // properties
48 unsigned long _time, _new_time;
49 unsigned long _date, _new_date;
50 long _latitude, _new_latitude;
51 long _longitude, _new_longitude;
52 unsigned short _fixtype, _new_fixtype;
53 long _altitude, _new_altitude;
54 unsigned long _speed, _new_speed;
55 unsigned long _course, _new_course;
56 unsigned long _hdop, _new_hdop;
57 unsigned short _numsats, _new_numsats;
59 unsigned long _last_time_fix, _new_time_fix;
60 unsigned long _last_position_fix, _new_position_fix;
62 // parsing state variables
63 uint8_t _parity;
64 bool _is_checksum_term;
65 char _term[15];
66 uint8_t _sentence_type;
67 uint8_t _term_number;
68 uint8_t _term_offset;
69 bool _gps_data_good;
70 uint8_t _fix_type;
72 #ifndef _GPS_NO_STATS
73 // statistics
74 unsigned long _encoded_characters;
75 unsigned short _good_sentences;
76 unsigned short _failed_checksum;
77 unsigned short _passed_checksum;
78 #endif
80 /*bool encode(char c); // process one character received from GPS
82 //TinyGPS &operator << (char c) {encode(c); return *this;}*/
84 // lat/long in MILLIONTHs of a degree and age of fix in milliseconds
85 // (note: versions 12 and earlier gave lat/long in 100,000ths of a degree.
86 void get_position(long *latitude, long *longitude, unsigned long *fix_age);
88 // date as ddmmyy, time as hhmmsscc, and age in milliseconds
89 void get_datetime(unsigned long *date, unsigned long *time, unsigned long *age);
91 // signed altitude in centimeters (from GPGGA sentence)
92 inline long altitude() { return _altitude; }
94 // course in last full GPRMC sentence in 100th of a degree
95 inline unsigned long course() { return _course; }
97 // speed in last full GPRMC sentence in 100ths of a knot
98 inline unsigned long speed() { return _speed; }
100 // satellites used in last full GPGGA sentence
101 uint8_t satellites();
103 // horizontal dilution of precision in 100ths
104 inline unsigned long hdop() { return _hdop; }
106 void f_get_position(float *latitude, float *longitude, unsigned long *fix_age);
107 void crack_datetime(int *year, uint8_t *month, uint8_t *day,
108 uint8_t *hour, uint8_t *minute, uint8_t *second, uint8_t *hundredths, unsigned long *fix_age);
109 float f_altitude(void);
110 float f_course(void);
111 float f_speed_knots(void);
112 float f_speed_mph(void);
113 float f_speed_mps(void);
114 float f_speed_kmph(void);
115 float f_hdop(void);
116 uint8_t f_fixtype(void);
118 uint8_t get_sentence_type(void);
119 //static int library_version() { return _GPS_VERSION; }
121 float distance_between (float lat1, float long1, float lat2, float long2);
122 float course_to (float lat1, float long1, float lat2, float long2);
123 static const char *cardinal(float course);
125 #ifndef _GPS_NO_STATS
126 void stats(unsigned long *chars, unsigned short *good_sentences, unsigned short *failed_cs);
127 #endif
129 enum {_GPS_SENTENCE_GPGGA, _GPS_SENTENCE_GNGGA, _GPS_SENTENCE_GPRMC, _GPS_SENTENCE_OTHER};
131 bool TinyGPS_encode(char c);
133 // internal utilities
134 /*int from_hex(char a);
135 unsigned long parse_decimal();
136 unsigned long parse_degrees();
137 bool term_complete();
138 bool gpsisdigit(char c);
139 long gpsatol(const char *str);
140 int gpsstrcmp(const char *str1, const char *str2);*/