Skip to content

Commit

Permalink
Implement $PGRMF speed
Browse files Browse the repository at this point in the history
* refactor parseSpeedKph from PUBX,00 sentence
  • Loading branch information
SlashDevin committed May 31, 2018
1 parent 47c01ce commit 18db945
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Garmin/GrmNMEA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ bool GarminNMEA::parseF( char chr )
PARSE_LOC(6);
//case 10: return parseFix( char ); // not needed, because next field sets status
case 11: return parseFix( chr );
//case 12: return parseSpeed( chr ); // a little messier because units are km/h, not kts/h
case 12: return parseSpeedKph( chr );
case 13: return parseHeading( chr );
case 14: return parsePDOP( chr );
//case 15: return parseTDOP( chr ); // not yet supported
Expand Down
20 changes: 20 additions & 0 deletions src/NMEAGPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1725,6 +1725,26 @@ bool NMEAGPS::parseSpeed( char chr )

//----------------------------------------------------------------

bool NMEAGPS::parseSpeedKph( char chr )
{
#ifdef GPS_FIX_SPEED
parseSpeed( chr );

if ((chr == ',') && m_fix.valid.speed) {
uint32_t kph = m_fix.spd.int32_000();
// Convert to Nautical Miles/Hour
uint32_t nmiph = (kph * 1000) / gps_fix::M_PER_NMI;
m_fix.spd.whole = nmiph / 1000;
m_fix.spd.frac = (nmiph - m_fix.spd.whole*1000);
}
#endif

return true;

} // parseSpeedKph

//----------------------------------------------------------------

bool NMEAGPS::parseHeading( char chr )
{
#ifdef GPS_FIX_HEADING
Expand Down
1 change: 1 addition & 0 deletions src/NMEAGPSprivate.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@
bool parseLon ( char chr );
bool parseEW ( char chr );
bool parseSpeed ( char chr );
bool parseSpeedKph ( char chr );
bool parseHeading ( char chr );
bool parseAlt ( char chr );
bool parseGeoidHeight( char chr );
Expand Down

0 comments on commit 18db945

Please sign in to comment.