-
Notifications
You must be signed in to change notification settings - Fork 544
support for fix quality and fix mode #38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -50,6 +50,35 @@ struct RawDegrees | |
| {} | ||
| }; | ||
|
|
||
| enum FixQuality { Invalid = 0, GPS = 1, DGPS = 2, PPS = 3, RTK = 4, FloatRTK = 5, Estimated = 6, Manual = 7, Simulated = 8 }; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Consider enum class. |
||
| enum FixMode { N = 'N', A = 'A', D = 'D', E = 'E'}; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same. Consider an 'inivalid'. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same. Consider an Invalid member. |
||
|
|
||
| struct TinyGPSTime | ||
| { | ||
| friend class TinyGPSPlus; | ||
| friend class TinyGPSLocation; | ||
| public: | ||
| bool isValid() const { return valid; } | ||
| bool isUpdated() const { return updated; } | ||
| uint32_t age() const { return valid ? millis() - lastCommitTime : (uint32_t)ULONG_MAX; } | ||
|
|
||
| uint32_t value() { updated = false; return time; } | ||
| uint8_t hour(); | ||
| uint8_t minute(); | ||
| uint8_t second(); | ||
| uint8_t centisecond(); | ||
|
|
||
| TinyGPSTime() : valid(false), updated(false), time(0) | ||
| {} | ||
|
|
||
| private: | ||
| bool valid, updated; | ||
| uint32_t time, newTime; | ||
| uint32_t lastCommitTime; | ||
| void commit(); | ||
| void setTime(const char *term); | ||
| }; | ||
|
|
||
| struct TinyGPSLocation | ||
| { | ||
| friend class TinyGPSPlus; | ||
|
|
@@ -59,19 +88,25 @@ struct TinyGPSLocation | |
| uint32_t age() const { return valid ? millis() - lastCommitTime : (uint32_t)ULONG_MAX; } | ||
| const RawDegrees &rawLat() { updated = false; return rawLatData; } | ||
| const RawDegrees &rawLng() { updated = false; return rawLngData; } | ||
| const TinyGPSTime &Time() { updated = false; return time; } | ||
| double lat(); | ||
| double lng(); | ||
| FixQuality Quality() { updated = false; return fixQuality; } | ||
| FixMode Mode() { updated = false; return fixMode; } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should return an std::optional |
||
|
|
||
| TinyGPSLocation() : valid(false), updated(false) | ||
| TinyGPSLocation() : valid(false), updated(false), fixQuality(Invalid), newFixQuality(Invalid), fixMode(N), newFixMode(N) | ||
| {} | ||
|
|
||
| private: | ||
| bool valid, updated; | ||
| RawDegrees rawLatData, rawLngData, rawNewLatData, rawNewLngData; | ||
| TinyGPSTime time; | ||
| uint32_t lastCommitTime; | ||
| void commit(); | ||
| void setLatitude(const char *term); | ||
| void setLongitude(const char *term); | ||
| FixQuality fixQuality, newFixQuality; | ||
| FixMode fixMode, newFixMode; | ||
| }; | ||
|
|
||
| struct TinyGPSDate | ||
|
|
@@ -98,30 +133,6 @@ struct TinyGPSDate | |
| void setDate(const char *term); | ||
| }; | ||
|
|
||
| struct TinyGPSTime | ||
| { | ||
| friend class TinyGPSPlus; | ||
| public: | ||
| bool isValid() const { return valid; } | ||
| bool isUpdated() const { return updated; } | ||
| uint32_t age() const { return valid ? millis() - lastCommitTime : (uint32_t)ULONG_MAX; } | ||
|
|
||
| uint32_t value() { updated = false; return time; } | ||
| uint8_t hour(); | ||
| uint8_t minute(); | ||
| uint8_t second(); | ||
| uint8_t centisecond(); | ||
|
|
||
| TinyGPSTime() : valid(false), updated(false), time(0) | ||
| {} | ||
|
|
||
| private: | ||
| bool valid, updated; | ||
| uint32_t time, newTime; | ||
| uint32_t lastCommitTime; | ||
| void commit(); | ||
| void setTime(const char *term); | ||
| }; | ||
|
|
||
| struct TinyGPSDecimal | ||
| { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
enum class allows stronger typechecking than the old C style: https://en.cppreference.com/w/cpp/language/enum