Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions src/FuGPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,17 @@ byte FuGPS::checksum(const char * sentence)
return checksum;
}

void FuGPS::parseDateTime(float value, byte & val1, byte & val2, float & val3)
{
val1 = (int)(value / 10000);
value -= val1 * 10000.0;

val2 = (int)(value / 100);
value -= val2 * 100.0;

val3 = value;
}

void FuGPS::parseDateTime(float value, byte & val1, byte & val2, byte & val3)
{
val1 = (int)(value / 10000);
Expand Down Expand Up @@ -239,7 +250,7 @@ void FuGPS::process()
#ifdef FUGPS_DEBUG
rmc_counter++;
#endif
float time = atoi(_tokens[1]);
float time = atof(_tokens[1]);
parseDateTime(time, Hours, Minutes, Seconds);

_fix = *_tokens[2] == 'A';
Expand All @@ -262,7 +273,7 @@ void FuGPS::process()
#ifdef FUGPS_DEBUG
gga_counter++;
#endif
float time = atoi(_tokens[1]);
float time = atof(_tokens[1]);
parseDateTime(time, Hours, Minutes, Seconds);

Latitude = atof(_tokens[2]);
Expand Down
4 changes: 3 additions & 1 deletion src/FuGPS.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class FuGPS

static byte checksum(const char * sentence);
static void parseDateTime(float data, byte & val1, byte & val2, byte & val3);
static void parseDateTime(float data, byte & val1, byte & val2, float & val3);
static float toDecimal(float coordinate, char coordinateRef);

void sendCommand(const char* command);
Expand Down Expand Up @@ -109,7 +110,8 @@ class FuGPS
// Reads one char (non blocking)
bool read();

byte Hours, Minutes, Seconds;
byte Hours, Minutes;
float Seconds;
byte Days, Months, Years;

// Fix Quality
Expand Down