Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 5b019f9

Browse files
committedJan 9, 2019
Gating debug statements
1 parent df7da25 commit 5b019f9

File tree

3 files changed

+18
-13
lines changed

3 files changed

+18
-13
lines changed
 

‎examples/Example3_GetPosition/Example3_GetPosition.ino

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
License: MIT. See license file for more information but you can
77
basically do whatever you want with this code.
88
9-
This example shows how to query a Ublox module for its lat/long/altitude.
9+
This example shows how to query a Ublox module for its lat/long/altitude. We also
10+
turn off the NMEA output on the I2C port. This decreases the amount of I2C traffic
11+
dramatically.
1012
1113
Note: Long/lat are large numbers because they are * 10^7. To convert lat/long
1214
to something google maps understands simply divide the numbers by 10,000,000. We
@@ -46,6 +48,9 @@ void setup()
4648
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
4749
while (1);
4850
}
51+
52+
myGPS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
53+
myGPS.saveConfiguration(); //Save the current settings to flash and BBR
4954
}
5055

5156
void loop()

‎src/SparkFun_Ublox_Arduino_Library.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,9 @@ boolean SFE_UBLOX_GPS::checkUbloxI2C()
114114

115115
if (bytesAvailable == 0)
116116
{
117-
Serial.println("No bytes available");
117+
#ifdef DEBUG
118+
debug.println("No bytes available");
119+
#endif
118120
lastCheck = millis(); //Put off checking to avoid I2C bus traffic
119121
}
120122

@@ -659,9 +661,9 @@ uint8_t SFE_UBLOX_GPS::getVal(uint16_t group, uint16_t id, uint8_t size, uint8_t
659661
key |= (uint32_t)size << 28;
660662

661663
#ifdef DEBUG
662-
Serial.print("key: 0x");
663-
Serial.print(key, HEX);
664-
Serial.println();
664+
debug.print("key: 0x");
665+
debug.print(key, HEX);
666+
debug.println();
665667
#endif
666668

667669
//Load key into outgoing payload
@@ -694,7 +696,6 @@ boolean SFE_UBLOX_GPS::setSurveyMode(uint8_t mode, uint16_t observationTime, flo
694696
{
695697
if (getSurveyMode() == false) //Ask module for the current TimeMode3 settings. Loads into payloadCfg.
696698
return (false);
697-
//Serial.println("Current settings obtained");
698699

699700
packetCfg.cls = UBX_CLASS_CFG;
700701
packetCfg.id = UBX_CFG_TMODE3;
@@ -716,7 +717,6 @@ boolean SFE_UBLOX_GPS::setSurveyMode(uint8_t mode, uint16_t observationTime, flo
716717
payloadCfg[29] = svinAccLimit >> 8;
717718
payloadCfg[30] = svinAccLimit >> 16;
718719

719-
//Serial.println("Sending new settings");
720720
return ( sendCommand(packetCfg, maxWait) ); //Wait for ack
721721
}
722722

@@ -1141,15 +1141,15 @@ boolean SFE_UBLOX_GPS::getProtocolVersion(uint16_t maxWait)
11411141
return(false); //If command send fails then bail
11421142

11431143
#ifdef DEBUG
1144-
Serial.print("Extension ");
1145-
Serial.print(extensionNumber);
1146-
Serial.print(": ");
1144+
debug.print("Extension ");
1145+
debug.print(extensionNumber);
1146+
debug.print(": ");
11471147
for(int location = 0 ; location < MAX_PAYLOAD_SIZE ; location++)
11481148
{
11491149
if(payloadCfg[location] == '\0') break;
1150-
Serial.write(payloadCfg[location]);
1150+
debug.write(payloadCfg[location]);
11511151
}
1152-
Serial.println();
1152+
debug.println();
11531153
#endif
11541154

11551155
//Now we need to find "PROTVER=18.00" in the incoming byte stream

‎src/SparkFun_Ublox_Arduino_Library.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939

4040
//Uncomment the following line to enable a variety of debug statements
4141
//This will increase the codeword and RAM footprint of the library
42-
#define DEBUG
42+
//#define DEBUG
4343

4444
#ifdef DEBUG
4545
#define debug Serial //Point debug statements to print to Serial port

0 commit comments

Comments
 (0)
This repository has been archived.