Skip to content

Commit c093432

Browse files
committed
1.1-beta1: Several user-suggested pull requests incorporated
1 parent ca29434 commit c093432

7 files changed

Lines changed: 83 additions & 45 deletions

File tree

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
################################################################################
2+
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
3+
################################################################################
4+
5+
/.vs

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
11
# TinyGPSPlus
2+
23
A new, customizable Arduino NMEA parsing library
34
A *NEW* Full-featured GPS/NMEA Parser for Arduino
45
TinyGPSPlus is a new Arduino library for parsing NMEA data streams provided by GPS modules.
56

6-
Like its predecessor, TinyGPS, this library provides compact and easy-to-use methods for extracting position, date, time, altitude, speed, and course from consumer GPS devices.
7+
1.1-beta update: Several pull requests incorporated (or equiv)
8+
9+
* 38 Added Fix Quality and Fix Mode
10+
* 66/109 Fix stringop truncation warning
11+
* 69 Support for non-Arduino platforms
12+
* 88 Slight change to earth radius
13+
* 106 Support all satellite groups
14+
15+
Like its predecessor, TinyGPS, this library provides compact and easy-to-use methods for extracting position, date, time, altitude, speed, and course from consumer GPS devices.
716

817
However, TinyGPSPlus’s programmer interface is considerably simpler to use than TinyGPS, and the new library can extract arbitrary data from any of the myriad NMEA sentences out there, even proprietary ones.
918

library.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
22
"name": "TinyGPSPlus",
3-
"version": "1.0.3",
3+
"version": "1.1.0",
44
"keywords": "gps,NMEA",
5-
"description": "A new, customizable Arduino NMEA parsing library",
5+
"description": "A tiny, customizable Arduino NMEA parsing library",
66
"repository":
77
{
88
"type": "git",

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=TinyGPSPlus
2-
version=1.0.3
2+
version=1.1.0
33
author=Mikal Hart
44
maintainer=Mikal Hart<mikal@arduniana.org>
55
sentence=TinyGPSPlus provides object-oriented parsing of GPS (NMEA) sentences

src/TinyGPS++.cpp

Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ TinyGPS++ - a small GPS library for Arduino providing universal NMEA parsing
33
Based on work by and "distanceBetween" and "courseTo" courtesy of Maarten Lamers.
44
Suggestion to add satellites, courseTo(), and cardinal() by Matt Monson.
55
Location precision improvements suggested by Wayne Holder.
6-
Copyright (C) 2008-2013 Mikal Hart
6+
Copyright (C) 2008-2024 Mikal Hart
77
All rights reserved.
88
99
This library is free software; you can redistribute it and/or
@@ -27,10 +27,21 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2727
#include <ctype.h>
2828
#include <stdlib.h>
2929

30-
#define _GPRMCterm "GPRMC"
31-
#define _GPGGAterm "GPGGA"
32-
#define _GNRMCterm "GNRMC"
33-
#define _GNGGAterm "GNGGA"
30+
#define _RMCterm "RMC"
31+
#define _GGAterm "GGA"
32+
33+
#if !defined(ARDUINO) && !defined(__AVR__)
34+
// Alternate implementation of millis() that relies on std
35+
unsigned long millis()
36+
{
37+
static auto start_time = std::chrono::high_resolution_clock::now();
38+
39+
auto end_time = std::chrono::high_resolution_clock::now();
40+
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end_time - start_time);
41+
42+
return static_cast<unsigned long>(duration.count());
43+
}
44+
#endif
3445

3546
TinyGPSPlus::TinyGPSPlus()
3647
: parity(0)
@@ -170,7 +181,7 @@ bool TinyGPSPlus::endOfTermHandler()
170181

171182
switch(curSentenceType)
172183
{
173-
case GPS_SENTENCE_GPRMC:
184+
case GPS_SENTENCE_RMC:
174185
date.commit();
175186
time.commit();
176187
if (sentenceHasFix)
@@ -180,7 +191,7 @@ bool TinyGPSPlus::endOfTermHandler()
180191
course.commit();
181192
}
182193
break;
183-
case GPS_SENTENCE_GPGGA:
194+
case GPS_SENTENCE_GGA:
184195
time.commit();
185196
if (sentenceHasFix)
186197
{
@@ -209,10 +220,10 @@ bool TinyGPSPlus::endOfTermHandler()
209220
// the first term determines the sentence type
210221
if (curTermNumber == 0)
211222
{
212-
if (!strcmp(term, _GPRMCterm) || !strcmp(term, _GNRMCterm))
213-
curSentenceType = GPS_SENTENCE_GPRMC;
214-
else if (!strcmp(term, _GPGGAterm) || !strcmp(term, _GNGGAterm))
215-
curSentenceType = GPS_SENTENCE_GPGGA;
223+
if (term[0] == 'G' && strchr("PNABL", term[1]) != NULL && !strcmp(term + 2, _RMCterm))
224+
curSentenceType = GPS_SENTENCE_RMC;
225+
else if (term[0] == 'G' && strchr("PNABL", term[1]) != NULL && !strcmp(term + 2, _GGAterm))
226+
curSentenceType = GPS_SENTENCE_GGA;
216227
else
217228
curSentenceType = GPS_SENTENCE_OTHER;
218229

@@ -227,50 +238,54 @@ bool TinyGPSPlus::endOfTermHandler()
227238
if (curSentenceType != GPS_SENTENCE_OTHER && term[0])
228239
switch(COMBINE(curSentenceType, curTermNumber))
229240
{
230-
case COMBINE(GPS_SENTENCE_GPRMC, 1): // Time in both sentences
231-
case COMBINE(GPS_SENTENCE_GPGGA, 1):
241+
case COMBINE(GPS_SENTENCE_RMC, 1): // Time in both sentences
242+
case COMBINE(GPS_SENTENCE_GGA, 1):
232243
time.setTime(term);
233244
break;
234-
case COMBINE(GPS_SENTENCE_GPRMC, 2): // GPRMC validity
245+
case COMBINE(GPS_SENTENCE_RMC, 2): // RMC validity
235246
sentenceHasFix = term[0] == 'A';
236247
break;
237-
case COMBINE(GPS_SENTENCE_GPRMC, 3): // Latitude
238-
case COMBINE(GPS_SENTENCE_GPGGA, 2):
248+
case COMBINE(GPS_SENTENCE_RMC, 3): // Latitude
249+
case COMBINE(GPS_SENTENCE_GGA, 2):
239250
location.setLatitude(term);
240251
break;
241-
case COMBINE(GPS_SENTENCE_GPRMC, 4): // N/S
242-
case COMBINE(GPS_SENTENCE_GPGGA, 3):
252+
case COMBINE(GPS_SENTENCE_RMC, 4): // N/S
253+
case COMBINE(GPS_SENTENCE_GGA, 3):
243254
location.rawNewLatData.negative = term[0] == 'S';
244255
break;
245-
case COMBINE(GPS_SENTENCE_GPRMC, 5): // Longitude
246-
case COMBINE(GPS_SENTENCE_GPGGA, 4):
256+
case COMBINE(GPS_SENTENCE_RMC, 5): // Longitude
257+
case COMBINE(GPS_SENTENCE_GGA, 4):
247258
location.setLongitude(term);
248259
break;
249-
case COMBINE(GPS_SENTENCE_GPRMC, 6): // E/W
250-
case COMBINE(GPS_SENTENCE_GPGGA, 5):
260+
case COMBINE(GPS_SENTENCE_RMC, 6): // E/W
261+
case COMBINE(GPS_SENTENCE_GGA, 5):
251262
location.rawNewLngData.negative = term[0] == 'W';
252263
break;
253-
case COMBINE(GPS_SENTENCE_GPRMC, 7): // Speed (GPRMC)
264+
case COMBINE(GPS_SENTENCE_RMC, 7): // Speed (RMC)
254265
speed.set(term);
255266
break;
256-
case COMBINE(GPS_SENTENCE_GPRMC, 8): // Course (GPRMC)
267+
case COMBINE(GPS_SENTENCE_RMC, 8): // Course (RMC)
257268
course.set(term);
258269
break;
259-
case COMBINE(GPS_SENTENCE_GPRMC, 9): // Date (GPRMC)
270+
case COMBINE(GPS_SENTENCE_RMC, 9): // Date (RMC)
260271
date.setDate(term);
261272
break;
262-
case COMBINE(GPS_SENTENCE_GPGGA, 6): // Fix data (GPGGA)
273+
case COMBINE(GPS_SENTENCE_GGA, 6): // Fix data (GGA)
263274
sentenceHasFix = term[0] > '0';
275+
location.newFixQuality = (TinyGPSLocation::Quality)term[0];
264276
break;
265-
case COMBINE(GPS_SENTENCE_GPGGA, 7): // Satellites used (GPGGA)
277+
case COMBINE(GPS_SENTENCE_GGA, 7): // Satellites used (GGA)
266278
satellites.set(term);
267279
break;
268-
case COMBINE(GPS_SENTENCE_GPGGA, 8): // HDOP
280+
case COMBINE(GPS_SENTENCE_GGA, 8): // HDOP
269281
hdop.set(term);
270282
break;
271-
case COMBINE(GPS_SENTENCE_GPGGA, 9): // Altitude (GPGGA)
283+
case COMBINE(GPS_SENTENCE_GGA, 9): // Altitude (GGA)
272284
altitude.set(term);
273285
break;
286+
case COMBINE(GPS_SENTENCE_RMC, 12):
287+
location.newFixMode = (TinyGPSLocation::Mode)term[0];
288+
break;
274289
}
275290

276291
// Set custom values as needed
@@ -286,7 +301,7 @@ double TinyGPSPlus::distanceBetween(double lat1, double long1, double lat2, doub
286301
{
287302
// returns distance in meters between two positions, both specified
288303
// as signed decimal-degrees latitude and longitude. Uses great-circle
289-
// distance computation for hypothetical sphere of radius 6372795 meters.
304+
// distance computation for hypothetical sphere of radius 6371009 meters.
290305
// Because Earth is no exact sphere, rounding errors may be up to 0.5%.
291306
// Courtesy of Maarten Lamers
292307
double delta = radians(long1-long2);
@@ -304,7 +319,7 @@ double TinyGPSPlus::distanceBetween(double lat1, double long1, double lat2, doub
304319
delta = sqrt(delta);
305320
double denom = (slat1 * slat2) + (clat1 * clat2 * cdlong);
306321
delta = atan2(delta, denom);
307-
return delta * 6372795;
322+
return delta * _GPS_EARTH_MEAN_RADIUS;
308323
}
309324

310325
double TinyGPSPlus::courseTo(double lat1, double long1, double lat2, double long2)
@@ -338,6 +353,8 @@ void TinyGPSLocation::commit()
338353
{
339354
rawLatData = rawNewLatData;
340355
rawLngData = rawNewLngData;
356+
fixQuality = newFixQuality;
357+
fixMode = newFixMode;
341358
lastCommitTime = millis();
342359
valid = updated = true;
343360
}
@@ -484,7 +501,7 @@ void TinyGPSCustom::commit()
484501

485502
void TinyGPSCustom::set(const char *term)
486503
{
487-
strncpy(this->stagingBuffer, term, sizeof(this->stagingBuffer));
504+
strncpy(this->stagingBuffer, term, sizeof(this->stagingBuffer) - 1);
488505
}
489506

490507
void TinyGPSPlus::insertCustom(TinyGPSCustom *pElt, const char *sentenceName, int termNumber)

src/TinyGPS++.h

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ TinyGPS++ - a small GPS library for Arduino providing universal NMEA parsing
33
Based on work by and "distanceBetween" and "courseTo" courtesy of Maarten Lamers.
44
Suggestion to add satellites, courseTo(), and cardinal() by Matt Monson.
55
Location precision improvements suggested by Wayne Holder.
6-
Copyright (C) 2008-2022 Mikal Hart
6+
Copyright (C) 2008-2024 Mikal Hart
77
All rights reserved.
88
99
This library is free software; you can redistribute it and/or
@@ -21,24 +21,24 @@ License along with this library; if not, write to the Free Software
2121
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
2222
*/
2323

24+
25+
2426
#ifndef __TinyGPSPlus_h
2527
#define __TinyGPSPlus_h
2628

27-
#if defined(ARDUINO) && ARDUINO >= 100
29+
#include <inttypes.h>
2830
#include "Arduino.h"
29-
#else
30-
#include "WProgram.h"
31-
#endif
3231
#include <limits.h>
3332

34-
#define _GPS_VERSION "1.0.3" // software version of this library
33+
#define _GPS_VERSION "1.1.0" // software version of this library
3534
#define _GPS_MPH_PER_KNOT 1.15077945
3635
#define _GPS_MPS_PER_KNOT 0.51444444
3736
#define _GPS_KMPH_PER_KNOT 1.852
3837
#define _GPS_MILES_PER_METER 0.00062137112
3938
#define _GPS_KM_PER_METER 0.001
4039
#define _GPS_FEET_PER_METER 3.2808399
4140
#define _GPS_MAX_FIELD_SIZE 15
41+
#define _GPS_EARTH_MEAN_RADIUS 6371009 // old: 6372795
4242

4343
struct RawDegrees
4444
{
@@ -54,20 +54,27 @@ struct TinyGPSLocation
5454
{
5555
friend class TinyGPSPlus;
5656
public:
57+
enum Quality { Invalid = '0', GPS = '1', DGPS = '2', PPS = '3', RTK = '4', FloatRTK = '5', Estimated = '6', Manual = '7', Simulated = '8' };
58+
enum Mode { N = 'N', A = 'A', D = 'D', E = 'E'};
59+
5760
bool isValid() const { return valid; }
5861
bool isUpdated() const { return updated; }
5962
uint32_t age() const { return valid ? millis() - lastCommitTime : (uint32_t)ULONG_MAX; }
6063
const RawDegrees &rawLat() { updated = false; return rawLatData; }
6164
const RawDegrees &rawLng() { updated = false; return rawLngData; }
6265
double lat();
6366
double lng();
67+
Quality FixQuality() { updated = false; return fixQuality; }
68+
Mode FixMode() { updated = false; return fixMode; }
6469

65-
TinyGPSLocation() : valid(false), updated(false)
70+
TinyGPSLocation() : valid(false), updated(false), fixQuality(Invalid), fixMode(N)
6671
{}
6772

6873
private:
6974
bool valid, updated;
7075
RawDegrees rawLatData, rawLngData, rawNewLatData, rawNewLngData;
76+
Quality fixQuality, newFixQuality;
77+
Mode fixMode, newFixMode;
7178
uint32_t lastCommitTime;
7279
void commit();
7380
void setLatitude(const char *term);
@@ -247,7 +254,7 @@ class TinyGPSPlus
247254
uint32_t passedChecksum() const { return passedChecksumCount; }
248255

249256
private:
250-
enum {GPS_SENTENCE_GPGGA, GPS_SENTENCE_GPRMC, GPS_SENTENCE_OTHER};
257+
enum {GPS_SENTENCE_GGA, GPS_SENTENCE_RMC, GPS_SENTENCE_OTHER};
251258

252259
// parsing state variables
253260
uint8_t parity;

src/TinyGPSPlus.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ TinyGPSPlus - a small GPS library for Arduino providing universal NMEA parsing
33
Based on work by and "distanceBetween" and "courseTo" courtesy of Maarten Lamers.
44
Suggestion to add satellites, courseTo(), and cardinal() by Matt Monson.
55
Location precision improvements suggested by Wayne Holder.
6-
Copyright (C) 2008-2013 Mikal Hart
6+
Copyright (C) 2008-2024 Mikal Hart
77
All rights reserved.
88
99
This library is free software; you can redistribute it and/or

0 commit comments

Comments
 (0)