Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit e2a8883

Browse files
committed
Add millisecond support
1 parent 1b0fa3f commit e2a8883

File tree

3 files changed

+36
-22
lines changed

3 files changed

+36
-22
lines changed

keywords.txt

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ getDay KEYWORD2
9595
getHour KEYWORD2
9696
getMinute KEYWORD2
9797
getSecond KEYWORD2
98+
getMillisecond KEYWORD2
9899
getNanosecond KEYWORD2
99100

100101
getHPPOSLLH KEYWORD2

src/SparkFun_Ublox_Arduino_Library.cpp

+12-2
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,8 @@ void SFE_UBLOX_GPS::processUBXpacket(ubxPacket *msg)
535535
gpsHour = extractByte(8);
536536
gpsMinute = extractByte(9);
537537
gpsSecond = extractByte(10);
538-
gpsNanosecond = extractLong(16);
538+
gpsMillisecond = extractLong(0) % 1000; //Get last three digits of iTOW
539+
gpsNanosecond = extractLong(16); //Includes milliseconds
539540

540541
fixType = extractByte(20 - startingSpot);
541542
carrierSolution = extractByte(21 - startingSpot) >> 6; //Get 6th&7th bits of this byte
@@ -1345,7 +1346,16 @@ uint8_t SFE_UBLOX_GPS::getSecond(uint16_t maxWait)
13451346
return (gpsSecond);
13461347
}
13471348

1348-
//Get the current nanosecond
1349+
//Get the current millisecond
1350+
uint16_t SFE_UBLOX_GPS::getMillisecond(uint16_t maxWait)
1351+
{
1352+
if (moduleQueried.gpsiTOW == false)
1353+
getPVT();
1354+
moduleQueried.gpsiTOW = false; //Since we are about to give this to user, mark this data as stale
1355+
return (gpsMillisecond);
1356+
}
1357+
1358+
//Get the current nanoseconds - includes milliseconds
13491359
int32_t SFE_UBLOX_GPS::getNanosecond(uint16_t maxWait)
13501360
{
13511361
if (moduleQueried.gpsNanosecond == false)

src/SparkFun_Ublox_Arduino_Library.h

+23-20
Original file line numberDiff line numberDiff line change
@@ -252,6 +252,7 @@ class SFE_UBLOX_GPS
252252
uint8_t getHour(uint16_t maxWait = 250);
253253
uint8_t getMinute(uint16_t maxWait = 250);
254254
uint8_t getSecond(uint16_t maxWait = 250);
255+
uint16_t getMillisecond(uint16_t maxWait = 250);
255256
int32_t getNanosecond(uint16_t maxWait = 250);
256257

257258
uint32_t getTimeOfWeek(uint16_t maxWait = 250);
@@ -348,6 +349,7 @@ class SFE_UBLOX_GPS
348349
uint8_t gpsHour;
349350
uint8_t gpsMinute;
350351
uint8_t gpsSecond;
352+
uint16_t gpsMillisecond;
351353
int32_t gpsNanosecond;
352354

353355
int32_t latitude; //Degrees * 10^-7 (more accurate than floats)
@@ -439,26 +441,27 @@ class SFE_UBLOX_GPS
439441
//depending on update rate
440442
struct
441443
{
442-
uint16_t gpsYear : 1;
443-
uint16_t gpsMonth : 1;
444-
uint16_t gpsDay : 1;
445-
uint16_t gpsHour : 1;
446-
uint16_t gpsMinute : 1;
447-
uint16_t gpsSecond : 1;
448-
uint16_t gpsNanosecond : 1;
449-
450-
uint16_t all : 1;
451-
uint16_t longitude : 1;
452-
uint16_t latitude : 1;
453-
uint16_t altitude : 1;
454-
uint16_t altitudeMSL : 1;
455-
uint16_t SIV : 1;
456-
uint16_t fixType : 1;
457-
uint16_t carrierSolution : 1;
458-
uint16_t groundSpeed : 1;
459-
uint16_t headingOfMotion : 1;
460-
uint16_t pDOP : 1;
461-
uint16_t versionNumber : 1;
444+
uint32_t gpsiTOW : 1;
445+
uint32_t gpsYear : 1;
446+
uint32_t gpsMonth : 1;
447+
uint32_t gpsDay : 1;
448+
uint32_t gpsHour : 1;
449+
uint32_t gpsMinute : 1;
450+
uint32_t gpsSecond : 1;
451+
uint32_t gpsNanosecond : 1;
452+
453+
uint32_t all : 1;
454+
uint32_t longitude : 1;
455+
uint32_t latitude : 1;
456+
uint32_t altitude : 1;
457+
uint32_t altitudeMSL : 1;
458+
uint32_t SIV : 1;
459+
uint32_t fixType : 1;
460+
uint32_t carrierSolution : 1;
461+
uint32_t groundSpeed : 1;
462+
uint32_t headingOfMotion : 1;
463+
uint32_t pDOP : 1;
464+
uint32_t versionNumber : 1;
462465
} moduleQueried;
463466

464467
struct

0 commit comments

Comments
 (0)