33
33
SFE_UBLOX_GPS myGPS;
34
34
35
35
#include < SerLCD.h> // Click here to get the library: http://librarymanager/All#SparkFun_SerLCD
36
- SerLCD lcd; // Initialize the library with default I2C address 0x72
36
+ SerLCD lcd; // Initialize the library with default I2C address 0x72
37
37
38
38
void setup ()
39
39
{
40
40
Serial.begin (115200 );
41
- while (!Serial); // Wait for user to open terminal
41
+ while (!Serial)
42
+ ; // Wait for user to open terminal
42
43
Serial.println (" Ublox GPS I2C Test" );
43
44
44
45
Wire.begin ();
45
46
46
47
pinMode (STAT_LED, OUTPUT);
47
48
digitalWrite (STAT_LED, LOW);
48
49
49
- lcd.begin (Wire); // Set up the LCD for Serial communication at 9600bps
50
+ lcd.begin (Wire); // Set up the LCD for Serial communication at 9600bps
50
51
lcd.setBacklight (0x4B0082 ); // indigo, a kind of dark purplish blue
51
52
lcd.clear ();
52
53
lcd.print (F (" LCD Ready" ));
@@ -57,7 +58,8 @@ void setup()
57
58
Serial.println (F (" Ublox GPS not detected at default I2C address. Please check wiring. Freezing." ));
58
59
lcd.setCursor (0 , 1 );
59
60
lcd.print (F (" No GPS detected" ));
60
- while (1 );
61
+ while (1 )
62
+ ;
61
63
}
62
64
63
65
Wire.setClock (400000 ); // Increase I2C clock speed to 400kHz
@@ -66,7 +68,7 @@ void setup()
66
68
lcd.print (" GPS Detected" );
67
69
68
70
myGPS.setI2COutput (COM_TYPE_UBX); // Set the I2C port to output UBX only (turn off NMEA noise)
69
- myGPS.saveConfiguration (); // Save the current settings to flash and BBR
71
+ myGPS.saveConfiguration (); // Save the current settings to flash and BBR
70
72
71
73
boolean response = true ;
72
74
response &= myGPS.enableRTCMmessage (UBX_RTCM_1005, COM_PORT_I2C, 1 ); // Enable message 1005 to output through I2C port, message every second
@@ -82,15 +84,17 @@ void setup()
82
84
else
83
85
{
84
86
Serial.println (F (" RTCM failed to enable. Are you sure you have an NEO-M8P?" ));
85
- while (1 ); // Freeze
87
+ while (1 )
88
+ ; // Freeze
86
89
}
87
90
88
91
// Check if Survey is in Progress before initiating one
89
92
response = myGPS.getSurveyStatus (2000 ); // Query module for SVIN status with 2000ms timeout (request can take a long time)
90
93
if (response == false )
91
94
{
92
95
Serial.println (F (" Failed to get Survey In status" ));
93
- while (1 ); // Freeze
96
+ while (1 )
97
+ ; // Freeze
94
98
}
95
99
96
100
if (myGPS.svin .active == true )
@@ -108,12 +112,14 @@ void setup()
108
112
Serial.println (F (" Survey start failed" ));
109
113
lcd.setCursor (0 , 3 );
110
114
lcd.print (F (" Survey start failed" ));
111
- while (1 );
115
+ while (1 )
116
+ ;
112
117
}
113
- Serial.println (F (" Survey started. This will run until 300s has passed and less than 5m accuracy is achieved." ));
118
+ Serial.println (F (" Survey started. This will run until 60s has passed and less than 5m accuracy is achieved." ));
114
119
}
115
120
116
- while (Serial.available ()) Serial.read (); // Clear buffer
121
+ while (Serial.available ())
122
+ Serial.read (); // Clear buffer
117
123
118
124
lcd.clear ();
119
125
lcd.print (F (" Survey in progress" ));
@@ -171,7 +177,7 @@ void loop()
171
177
myGPS.checkUblox (); // See if new data is available. Process bytes as they come in.
172
178
173
179
// Do anything you want. Call checkUblox() every second. NEO-M8P-2 has TX buffer of 4k bytes.
174
-
180
+
175
181
delay (250 ); // Don't pound too hard on the I2C bus
176
182
}
177
183
@@ -181,8 +187,10 @@ void loop()
181
187
void SFE_UBLOX_GPS::processRTCM (uint8_t incoming)
182
188
{
183
189
// Let's just pretty-print the HEX values for now
184
- if (myGPS.rtcmFrameCounter % 16 == 0 ) Serial.println ();
190
+ if (myGPS.rtcmFrameCounter % 16 == 0 )
191
+ Serial.println ();
185
192
Serial.print (" " );
186
- if (incoming < 0x10 ) Serial.print (" 0" );
193
+ if (incoming < 0x10 )
194
+ Serial.print (" 0" );
187
195
Serial.print (incoming, HEX);
188
196
}
0 commit comments