Skip to content

Commit f4b75a3

Browse files
committed
Clean up examples
1 parent e866eb0 commit f4b75a3

File tree

5 files changed

+83
-15
lines changed

5 files changed

+83
-15
lines changed

examples/Example11_FactoryReset/Example11_FactoryReset.ino

+62-5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ UM980 myGNSS;
3030

3131
HardwareSerial SerialGNSS(1); //Use UART1 on the ESP32
3232

33+
unsigned long lastCheck = 0;
34+
3335
void setup()
3436
{
3537
Serial.begin(115200);
@@ -49,9 +51,9 @@ void setup()
4951
}
5052
Serial.println("UM980 detected!");
5153

52-
while(Serial.available()) Serial.read(); //Clear RX buffer
54+
while (Serial.available()) Serial.read(); //Clear RX buffer
5355
Serial.println("Press any key to factory reset the UM980");
54-
while(Serial.available() == 0) delay(1); //Wait for user to press a button
56+
while (Serial.available() == 0) delay(1); //Wait for user to press a button
5557

5658
// Clear saved configurations, satellite ephemerides, position information, and reset baud rate to 115200bps.
5759
if (myGNSS.factoryReset() == true)
@@ -70,7 +72,6 @@ void setup()
7072

7173
Serial.println("UM980 has completed reset");
7274

73-
7475
// Resetting the receiver will clear the satellite ephemerides, position information, satellite
7576
// almanacs, ionosphere parameters and UTC parameters saved in the receiver.
7677
//myGNSS.reset();
@@ -84,5 +85,61 @@ void setup()
8485

8586
void loop()
8687
{
87-
//Do nothing
88-
}
88+
myGNSS.update(); //Regularly call to parse any new data
89+
90+
if (millis() - lastCheck > 1000)
91+
{
92+
lastCheck = millis();
93+
94+
//The get methods are updated whenever new data is parsed with the update() call.
95+
//By default, this data is updated once per second.
96+
97+
Serial.print("Lat/Long/Alt: ");
98+
Serial.print(myGNSS.getLatitude(), 11);
99+
Serial.print("/");
100+
Serial.print(myGNSS.getLongitude(), 11);
101+
Serial.print("/");
102+
Serial.print(myGNSS.getAltitude(), 4);
103+
Serial.println();
104+
105+
Serial.print("Horizontal Speed: ");
106+
Serial.print(myGNSS.getHorizontalSpeed());
107+
Serial.print("m/s Vertical Speed: ");
108+
Serial.print(myGNSS.getVerticalSpeed());
109+
Serial.print("m/s Direction from North: ");
110+
Serial.print(myGNSS.getTrackGround());
111+
Serial.print("(degrees)");
112+
Serial.println();
113+
114+
Serial.print("Date (yyyy/mm/dd): ");
115+
Serial.print(myGNSS.getYear());
116+
Serial.print("/");
117+
if (myGNSS.getMonth() < 10)
118+
Serial.print("0");
119+
Serial.print(myGNSS.getMonth());
120+
Serial.print("/");
121+
if (myGNSS.getDay() < 10)
122+
Serial.print("0");
123+
Serial.print(myGNSS.getDay());
124+
125+
Serial.print(" Time (hh:mm:dd): ");
126+
if (myGNSS.getHour() < 10)
127+
Serial.print("0");
128+
Serial.print(myGNSS.getHour());
129+
Serial.print(":");
130+
if (myGNSS.getMinute() < 10)
131+
Serial.print("0");
132+
Serial.print(myGNSS.getMinute());
133+
Serial.print(":");
134+
if (myGNSS.getSecond() < 10)
135+
Serial.print("0");
136+
Serial.print(myGNSS.getSecond());
137+
Serial.println();
138+
139+
Serial.print("Satellites in view: ");
140+
Serial.print(myGNSS.getSIV());
141+
Serial.println();
142+
143+
Serial.println();
144+
}
145+
}

examples/Example3_EnableNMEA_5Hz/Example3_EnableNMEA_5Hz.ino

+5-1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ void setup()
5151
}
5252
Serial.println("UM980 detected!");
5353

54+
myGNSS.disableOutput(); // Disables all messages on this port
55+
5456
//Set the output rate of NMEA messages. Users can set both the message type and update rate.
5557
//1, 0.5, 0.2, 0.1, 0.05 corresponds to 1Hz, 2Hz, 5Hz, 10Hz, 20Hz respectively.
5658
//1, 2, 5 corresponds to 1Hz, 0.5Hz, 0.2Hz respectively.
@@ -71,11 +73,13 @@ void setup()
7173
myGNSS.setNMEAPortMessage("GPGSV", comName, 1); //Limit GSV to 1Hz
7274

7375
myGNSS.saveConfiguration(); //Save the current configuration into non-volatile memory (NVM)
76+
77+
Serial.println("Wait for UM980 to get fix and output NMEA...");
7478
}
7579

7680
void loop()
7781
{
7882
//Read in NMEA from the UM980
7983
while (SerialGNSS.available())
8084
Serial.write(SerialGNSS.read());
81-
}
85+
}

examples/Example4_EnableRTCM/Example4_EnableRTCM.ino

+7-4
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ void setup()
4949
}
5050
Serial.println("UM980 detected!");
5151

52+
myGNSS.disableOutput(); // Disables all messages on this port
53+
5254
//Configure the port on the UM980 we are currently commuicating with
5355
myGNSS.setRTCMMessage("RTCM1005", 1); //Message type, 1 report per second.
5456

@@ -59,11 +61,12 @@ void setup()
5961
myGNSS.setRTCMPortMessage("RTCM1093", "COM1", 0); //Disable given message on a given port
6062

6163
myGNSS.saveConfiguration(); //Save the current configuration into non-volatile memory (NVM)
64+
65+
Serial.println("RTCM is in binary so printing it will show random characters");
6266
}
6367

6468
void loop()
6569
{
66-
//RTCM is in binary so printing it to the serial terminal will not show anything legible
67-
// while (SerialGNSS.available())
68-
// Serial.write(SerialGNSS.read());
69-
}
70+
while (SerialGNSS.available())
71+
Serial.write(SerialGNSS.read());
72+
}

examples/Example5_AverageBase/Example5_AverageBase.ino

+4-2
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ void setup()
8080

8181
myGNSS.setRTCMMessage("RTCM1033", 0); //Disable a specific message
8282

83-
myGNSS.setRTCMMessage("RTCM1074", "COM1", 1); //Enable message on a specific port
83+
myGNSS.setRTCMPortMessage("RTCM1074", "COM1", 1); //Enable message on a specific port
8484

8585
myGNSS.saveConfiguration(); //Save the current configuration into non-volatile memory (NVM)
86+
87+
Serial.println("Output will be a mix of NMEA and binary RTCM non-visible characters");
8688
}
8789

8890
void loop()
@@ -91,4 +93,4 @@ void loop()
9193
//RTCM is binary and will appear as random characters.
9294
while (SerialGNSS.available())
9395
Serial.write(SerialGNSS.read());
94-
}
96+
}

examples/Example6_FixedBase/Example6_FixedBase.ino

+5-3
Original file line numberDiff line numberDiff line change
@@ -76,16 +76,18 @@ void setup()
7676
myGNSS.setRTCMMessage("RTCM1124", 1);
7777
myGNSS.setRTCMMessage("RTCM1033", 10);
7878

79-
myGNSS.setRTCMMessage("RTCM1033", 0); //Disable a specific message
79+
//myGNSS.setRTCMMessage("RTCM1033", 0); //Disable a specific message
8080

81-
myGNSS.setRTCMMessage("RTCM1074", "COM1", 1); //Enable message on a specific port
81+
//myGNSS.setRTCMPortMessage("RTCM1074", "COM1", 1); //Enable message on a specific port
8282

8383
myGNSS.saveConfiguration(); //Save the current configuration into non-volatile memory (NVM)
84+
85+
Serial.println("Output will be a mix of NMEA and binary RTCM non-visible characters");
8486
}
8587

8688
void loop()
8789
{
8890
//Read in NMEA and RTCM from the UM980
8991
while (SerialGNSS.available())
9092
Serial.write(SerialGNSS.read());
91-
}
93+
}

0 commit comments

Comments
 (0)