Skip to content

Commit 2ce23fe

Browse files
committed
Correct #20. Add .end. Add getFileBufferSize. Add Example26
1 parent 6ccf229 commit 2ce23fe

File tree

4 files changed

+439
-31
lines changed

4 files changed

+439
-31
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
Demonstrating how to use "end"
3+
By: Paul Clark
4+
SparkFun Electronics
5+
Date: April 1st, 2021
6+
License: MIT. See license file for more information but you can
7+
basically do whatever you want with this code.
8+
9+
This example shows how to use the end function.
10+
End will stop all automatic message processing and free (nearly) all used RAM.
11+
The file buffer is deleted (if it exists).
12+
13+
Feel like supporting open source hardware?
14+
Buy a board from SparkFun!
15+
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
16+
NEO-M8P RTK: https://www.sparkfun.com/products/15005
17+
SAM-M8Q: https://www.sparkfun.com/products/15106
18+
19+
Hardware Connections:
20+
Plug a Qwiic cable into the GNSS and a BlackBoard
21+
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
22+
Open the serial monitor at 115200 baud to see the output
23+
*/
24+
25+
#include <Wire.h> //Needed for I2C to GNSS
26+
27+
#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
28+
SFE_UBLOX_GNSS myGNSS;
29+
30+
void setup()
31+
{
32+
Serial.begin(115200);
33+
while (!Serial); //Wait for user to open terminal
34+
Serial.println("SparkFun u-blox Example");
35+
36+
Wire.begin();
37+
38+
//myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
39+
40+
if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
41+
{
42+
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
43+
while (1);
44+
}
45+
46+
myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
47+
//myGNSS.saveConfiguration(); //Optional: Save the current settings to flash and BBR
48+
49+
myGNSS.end(); // Call end now just because we can - it won't do much as we haven't used any automatic messages
50+
}
51+
52+
void loop()
53+
{
54+
// Allocate 128 bytes for file storage - this checks that issue #20 has been resolved
55+
// Allocating only 128 bytes will let this code run on the ATmega328P
56+
// If your processor has plenty of RAM, you can increase this to something useful like 16KB
57+
myGNSS.setFileBufferSize(128);
58+
59+
if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
60+
{
61+
Serial.println(F("u-blox GNSS not detected. Freezing."));
62+
while (1);
63+
}
64+
65+
Serial.print(F("The file buffer size is: "));
66+
Serial.println(myGNSS.getFileBufferSize());
67+
68+
// Request Position, Velocity, Time
69+
// RAM will be allocated for PVT message processing
70+
// getPVT will return true is fresh PVT data was received and processed
71+
if (myGNSS.getPVT())
72+
{
73+
long latitude = myGNSS.getLatitude();
74+
Serial.print(F("Lat: "));
75+
Serial.print(latitude);
76+
77+
long longitude = myGNSS.getLongitude();
78+
Serial.print(F(" Long: "));
79+
Serial.print(longitude);
80+
Serial.print(F(" (degrees * 10^-7)"));
81+
82+
long altitude = myGNSS.getAltitude();
83+
Serial.print(F(" Alt: "));
84+
Serial.print(altitude);
85+
Serial.println(F(" (mm)"));
86+
}
87+
88+
// Calling end will free the RAM allocated for file storage and PVT processing
89+
// Calling end is optional. You can comment the next line if you want to.
90+
myGNSS.end();
91+
}

keywords.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ UBX_HNR_INS_data_t KEYWORD1
5050

5151
setPacketCfgPayloadSize KEYWORD2
5252
begin KEYWORD2
53+
end KEYWORD2
5354
setI2CpollingWait KEYWORD2
5455
setI2CTransactionSize KEYWORD2
5556
getI2CTransactionSize KEYWORD2
@@ -81,6 +82,7 @@ checkCallbacks KEYWORD2
8182
pushRawData KEYWORD2
8283

8384
setFileBufferSize KEYWORD2
85+
getFileBufferSize KEYWORD2
8486
extractFileBufferData KEYWORD2
8587
fileBufferAvailable KEYWORD2
8688
getMaxFileBufferAvail KEYWORD2

0 commit comments

Comments
 (0)