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

Commit 9627d51

Browse files
author
Nathan Seidle
committed
2 parents 407a5c7 + 8e12630 commit 9627d51

File tree

6 files changed

+423
-173
lines changed

6 files changed

+423
-173
lines changed

Diff for: examples/Example13_PVT/Example2_AutoPVT_ExplicitUpdate/Example2_AutoPVT_ExplicitUpdate.ino

+14-9
Original file line numberDiff line numberDiff line change
@@ -35,25 +35,27 @@ SFE_UBLOX_GPS myGPS;
3535
void setup()
3636
{
3737
Serial.begin(115200);
38-
while (!Serial); //Wait for user to open terminal
38+
while (!Serial)
39+
; //Wait for user to open terminal
3940
Serial.println("SparkFun Ublox Example");
4041

4142
Wire.begin();
4243

4344
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
4445
{
4546
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
46-
while (1);
47+
while (1)
48+
;
4749
}
4850

4951
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
50-
myGPS.setNavigationFrequency(2); //Produce two solutions per second
51-
myGPS.setAutoPVT(true, false); //Tell the GPS to "send" each solution and the lib not to update stale data implicitly
52-
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
52+
myGPS.setNavigationFrequency(2); //Produce two solutions per second
53+
myGPS.setAutoPVT(true, false); //Tell the GPS to "send" each solution and the lib not to update stale data implicitly
54+
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
5355
}
5456

5557
/*
56-
Calling getPVT would return false now (compare to Example 13 where it would return true), so we just use the data provided
58+
Calling getPVT would return false now (compare to previous example where it would return true), so we just use the data provided
5759
If you are using a threaded OS eg. FreeRTOS on an ESP32, the explicit mode of autoPVT allows you to use the data provided on both cores and inside multiple threads
5860
The data update in background creates an inconsistent state, but that should not cause issues for most applications as they usually won't change the GPS location significantly within a 2Hz - 5Hz update rate.
5961
Also you could oversample (10Hz - 20Hz) the data to smooth out such issues...
@@ -62,12 +64,14 @@ void loop()
6264
{
6365
static uint16_t counter = 0;
6466

65-
if (counter % 10 == 0) {
67+
if (counter % 10 == 0)
68+
{
6669
// update your AHRS filter here for a ~100Hz update rate
6770
// GPS data will be quasi static but data from your IMU will be changing
6871
}
6972
// debug output each half second
70-
if (counter % 500 == 0) {
73+
if (counter % 500 == 0)
74+
{
7175
Serial.println();
7276
long latitude = myGPS.getLatitude();
7377
Serial.print(F("Lat: "));
@@ -90,7 +94,8 @@ void loop()
9094
Serial.println();
9195
}
9296
// call checkUblox all 50ms to capture the gps data
93-
if (counter % 50 == 0) {
97+
if (counter % 50 == 0)
98+
{
9499
myGPS.checkUblox();
95100
}
96101
delay(1);

Diff for: examples/Example16_Nanosecond_MaxOutput/Example16_Nanosecond_MaxOutput.ino

+8-7
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,14 @@ long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox m
3333

3434
void setup()
3535
{
36-
Serial.begin(500000); //Increase serial speed to maximize
36+
Serial.begin(500000); //Increase serial speed to maximize
3737
while (!Serial)
3838
; //Wait for user to open terminal
3939
Serial.println("SparkFun Ublox Example");
4040

4141
Wire.begin();
4242
Wire.setClock(400000);
43-
43+
4444
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
4545
{
4646
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
@@ -53,18 +53,16 @@ void setup()
5353

5454
//myGPS.enableDebugging(); //Enable debug messages over Serial (default)
5555

56-
myGPS.setNavigationFrequency(10); //Set output to 10 times a second
56+
myGPS.setNavigationFrequency(10); //Set output to 10 times a second
5757
byte rate = myGPS.getNavigationFrequency(); //Get the update rate of this module
5858
Serial.print("Current update rate:");
5959
Serial.println(rate);
60-
6160
}
6261

6362
void loop()
6463
{
65-
//Query module only every second. Doing it more often will just cause I2C traffic.
66-
//The module only responds when a new position is available
67-
if (millis() - lastTime > 10)
64+
// Calling getPVT returns true if there actually is a fresh navigation solution available.
65+
if (myGPS.getPVT())
6866
{
6967
lastTime = millis(); //Update the timer
7068

@@ -86,6 +84,7 @@ void loop()
8684
Serial.print(F(" SIV: "));
8785
Serial.print(SIV);
8886

87+
Serial.print(" ");
8988
Serial.print(myGPS.getYear());
9089
Serial.print("-");
9190
Serial.print(myGPS.getMonth());
@@ -100,6 +99,8 @@ void loop()
10099
Serial.print(".");
101100
Serial.print(myGPS.getNanosecond());
102101

102+
myGPS.flushPVT();
103+
103104
Serial.println();
104105
}
105106
}

Diff for: examples/Example16_PartialSecond_MaxOutput/Example16_PartialSecond_MaxOutput.ino

+12-10
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,14 @@ long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to Ublox m
3232

3333
void setup()
3434
{
35-
Serial.begin(500000); //Increase serial speed to maximize
35+
Serial.begin(500000); //Increase serial speed to maximize
3636
while (!Serial)
3737
; //Wait for user to open terminal
3838
Serial.println("SparkFun Ublox Example");
3939

4040
Wire.begin();
4141
Wire.setClock(400000);
42-
42+
4343
if (myGPS.begin() == false) //Connect to the Ublox module using Wire port
4444
{
4545
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
@@ -51,21 +51,21 @@ void setup()
5151

5252
//myGPS.enableDebugging(); //Enable debug messages over Serial (default)
5353

54-
myGPS.setNavigationFrequency(10); //Set output to 10 times a second
54+
myGPS.setNavigationFrequency(10); //Set output to 10 times a second
5555
byte rate = myGPS.getNavigationFrequency(); //Get the update rate of this module
5656
Serial.print("Current update rate:");
5757
Serial.println(rate);
58-
59-
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
58+
59+
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
6060

6161
pinMode(2, OUTPUT); //For debug capture
6262
digitalWrite(2, HIGH);
6363
}
6464

6565
void loop()
6666
{
67-
//Query module very often to get max update rate
68-
if (millis() - lastTime > 10)
67+
// Calling getPVT returns true if there actually is a fresh navigation solution available.
68+
if (myGPS.getPVT())
6969
{
7070
lastTime = millis(); //Update the timer
7171

@@ -102,11 +102,13 @@ void loop()
102102
Serial.print(".");
103103
//Pretty print leading zeros
104104
int mseconds = myGPS.getMillisecond();
105-
if(mseconds < 100) Serial.print("0");
106-
if(mseconds < 10) Serial.print("0");
105+
if (mseconds < 100)
106+
Serial.print("0");
107+
if (mseconds < 10)
108+
Serial.print("0");
107109
Serial.print(mseconds);
108110

109-
Serial.print(" nanoSeconds: ");
111+
Serial.print(" nanoSeconds: ");
110112
Serial.print(myGPS.getNanosecond());
111113

112114
Serial.println();

Diff for: keywords.txt

+1
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ debugPrintln KEYWORD2
102102
factoryReset KEYWORD2
103103
setAutoPVT KEYWORD2
104104
assumeAutoPVT KEYWORD2
105+
flushPVT KEYWORD2
105106

106107
getYear KEYWORD2
107108
getMonth KEYWORD2

0 commit comments

Comments
 (0)