@@ -8,7 +8,7 @@ bool configureUbloxModuleRover()
88 int maxWait = 2000 ;
99
1010 // If our settings haven't changed, and this is first config since power on, trust ZED's settings
11- if (updateZEDSettings == false && firstPowerOn == true )
11+ if (updateZEDSettings == false && firstPowerOn == true )
1212 {
1313 firstPowerOn = false ; // Next time user switches modes, new settings will be applied
1414 log_d (" Skipping ZED Rover configuration" );
@@ -267,39 +267,33 @@ void updateAccuracyLEDs()
267267
268268 if (online.gnss == true )
269269 {
270- uint32_t accuracy = i2cGNSS.getHorizontalAccuracy ();
271-
272- if (accuracy > 0 )
270+ if (horizontalAccuracy > 0 )
273271 {
274- // Convert the horizontal accuracy (mm * 10^-1) to a float
275- float f_accuracy = accuracy;
276- f_accuracy = f_accuracy / 10000.0 ; // Convert from mm * 10^-1 to m
277-
278272 Serial.print (F (" Rover Accuracy (m): " ));
279- Serial.print (f_accuracy , 4 ); // Print the accuracy with 4 decimal places
273+ Serial.print (horizontalAccuracy , 4 ); // Print the accuracy with 4 decimal places
280274 Serial.println ();
281275
282276 if (productVariant == RTK_SURVEYOR)
283277 {
284- if (f_accuracy <= 0.02 )
278+ if (horizontalAccuracy <= 0.02 )
285279 {
286280 digitalWrite (pin_positionAccuracyLED_1cm, HIGH);
287281 digitalWrite (pin_positionAccuracyLED_10cm, HIGH);
288282 digitalWrite (pin_positionAccuracyLED_100cm, HIGH);
289283 }
290- else if (f_accuracy <= 0.100 )
284+ else if (horizontalAccuracy <= 0.100 )
291285 {
292286 digitalWrite (pin_positionAccuracyLED_1cm, LOW);
293287 digitalWrite (pin_positionAccuracyLED_10cm, HIGH);
294288 digitalWrite (pin_positionAccuracyLED_100cm, HIGH);
295289 }
296- else if (f_accuracy <= 1.0000 )
290+ else if (horizontalAccuracy <= 1.0000 )
297291 {
298292 digitalWrite (pin_positionAccuracyLED_1cm, LOW);
299293 digitalWrite (pin_positionAccuracyLED_10cm, LOW);
300294 digitalWrite (pin_positionAccuracyLED_100cm, HIGH);
301295 }
302- else if (f_accuracy > 1.0 )
296+ else if (horizontalAccuracy > 1.0 )
303297 {
304298 digitalWrite (pin_positionAccuracyLED_1cm, LOW);
305299 digitalWrite (pin_positionAccuracyLED_10cm, LOW);
@@ -310,12 +304,48 @@ void updateAccuracyLEDs()
310304 else
311305 {
312306 Serial.print (F (" Rover Accuracy: " ));
313- Serial.print (accuracy );
307+ Serial.print (horizontalAccuracy );
314308 Serial.print (" " );
315309 Serial.print (F (" No lock. SIV: " ));
316- Serial.print (i2cGNSS. getSIV () );
310+ Serial.print (numSV );
317311 Serial.println ();
318312 }
319313 } // End GNSS online checking
320314 } // Check every 2000ms
321315}
316+
317+ // These are the callbacks that get regularly called, globals are updated
318+ void storePVTdata (UBX_NAV_PVT_data_t *ubxDataStruct)
319+ {
320+ altitude = ubxDataStruct->height / 1000.0 ;
321+
322+ gnssDay = ubxDataStruct->day ;
323+ gnssMonth = ubxDataStruct->month ;
324+ gnssYear = ubxDataStruct->year ;
325+
326+ gnssHour = ubxDataStruct->hour ;
327+ gnssMinute = ubxDataStruct->min ;
328+ gnssSecond = ubxDataStruct->sec ;
329+ mseconds = ceil ((ubxDataStruct->iTOW % 1000 ) / 10.0 ); // Limit to first two digits
330+
331+ numSV = ubxDataStruct->numSV ;
332+ fixType = ubxDataStruct->fixType ;
333+ carrSoln = ubxDataStruct->flags .bits .carrSoln ;
334+
335+ validDate = ubxDataStruct->valid .bits .validDate ;
336+ validTime = ubxDataStruct->valid .bits .validTime ;
337+ confirmedDate = ubxDataStruct->flags2 .bits .confirmedDate ;
338+ confirmedTime = ubxDataStruct->flags2 .bits .confirmedTime ;
339+
340+ ubloxUpdated = true ;
341+ }
342+
343+ void storeHPdata (UBX_NAV_HPPOSLLH_data_t *ubxDataStruct)
344+ {
345+ horizontalAccuracy = ((float )ubxDataStruct->hAcc ) / 10000.0 ; // Convert hAcc from mm*0.1 to m
346+
347+ latitude = ((double )ubxDataStruct->lat ) / 10000000.0 ;
348+ latitude += ((double )ubxDataStruct->latHp ) / 1000000000.0 ;
349+ longitude = ((double )ubxDataStruct->lon ) / 10000000.0 ;
350+ longitude += ((double )ubxDataStruct->lonHp ) / 1000000000.0 ;
351+ }
0 commit comments