Skip to content

Commit e483b11

Browse files
committed
Update ZED_F9P\Example10 - corrects issue #19
1 parent 2ce23fe commit e483b11

File tree

3 files changed

+23
-5
lines changed

3 files changed

+23
-5
lines changed

Diff for: examples/Example16_Nanosecond_MaxOutput/Example16_Nanosecond_MaxOutput.ino

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ void loop()
9999
Serial.print(myGNSS.getMinute());
100100
Serial.print(":");
101101
Serial.print(myGNSS.getSecond());
102-
Serial.print(".");
103-
Serial.print(myGNSS.getNanosecond());
102+
Serial.print(" nanoseconds: ");
103+
Serial.print(myGNSS.getNanosecond()); // Nanoseconds can be negative
104104

105105
myGNSS.flushPVT();
106106

Diff for: examples/Example16_PartialSecond_MaxOutput/Example16_PartialSecond_MaxOutput.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ void loop()
110110
Serial.print("0");
111111
Serial.print(mseconds);
112112

113-
Serial.print(" nanoSeconds: ");
113+
Serial.print(" nanoseconds: ");
114114
Serial.print(myGNSS.getNanosecond());
115115

116116
Serial.println();

Diff for: examples/ZED-F9P/Example10_GetHighPrecisionPositionAndAccuracy/Example10_GetHighPrecisionPositionAndAccuracy.ino

+20-2
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,12 @@ void loop()
115115
Serial.print("Lat (deg): ");
116116
Serial.print(lat_int); // Print the integer part of the latitude
117117
Serial.print(".");
118-
Serial.print(lat_frac); // Print the fractional part of the latitude
118+
printFractional(lat_frac, 9); // Print the fractional part of the latitude with leading zeros
119119
Serial.print(", Lon (deg): ");
120120
Serial.print(lon_int); // Print the integer part of the latitude
121121
Serial.print(".");
122-
Serial.println(lon_frac); // Print the fractional part of the latitude
122+
printFractional(lon_frac, 9); // Print the fractional part of the latitude with leading zeros
123+
Serial.println();
123124

124125
// Now define float storage for the heights and accuracy
125126
float f_ellipsoid;
@@ -152,3 +153,20 @@ void loop()
152153
Serial.println(f_accuracy, 4); // Print the accuracy with 4 decimal places
153154
}
154155
}
156+
157+
// Pretty-print the fractional part with leading zeros - without using printf
158+
// (Only works with positive numbers)
159+
void printFractional(int32_t fractional, uint8_t places)
160+
{
161+
if (places > 1)
162+
{
163+
for (uint8_t place = places - 1; place > 0; place--)
164+
{
165+
if (fractional < pow(10, place))
166+
{
167+
Serial.print("0");
168+
}
169+
}
170+
}
171+
Serial.print(fractional);
172+
}

0 commit comments

Comments
 (0)