If the GPS has a valid date/time, but not a valid location, do you want to use the new date/time with the last valid location?
Yes, i want to use the updated date and time but with the last valid location. (only if the signals aren't there)
have been lurking in the background hoping someone else would ask why is it necessary to update a GPS position 10 times per second? Or even once every 10 seconds? How fast are you moving?
I am making this for my Rugby team, this device comprises of Accelerometer right now, we have planned for implementing IMU later on - So we don't want to miss data of an individual in that second..
Yes, i want to use the updated date and time but with the last valid location. (only if the signals aren't there)
Ok, an extra fix structure can hold all the pieces from the last good fix. You don't want the old date and time, so whenever you get a "good" fix, copy the pieces you want into the extra structure:
void GPSloop()
{
while (gps.available( gps_port) ) {
gps_fix new_fix = gps.read();
// Always use the reported date/time
fix.dateTime = new_fix.dateTime;
fix.valid.date = new_fix.valid.date;
fix.valid.time = new_fix.valid.time;
// Use the last valid location
if (new_fix.valid.location) {
fix.location = new_fix.location;
fix.valid.location = true;
}
doSomeWork();
}
}
When the GPS first starts, it will get a good date/time, and it will be copied into the global fix structure for doSomeWork to use. That routine will not write anything, because it does not have a valid location yet.
When the GPS finally gets a location, it will be copied into the global fix structure. Then doSomeWork will write a record, because it has all three pieces (date, time & location).
If the GPS stops getting locations, but it still has date/time, doSomeWork will write a record with the last valid location.
If the GPS stops getting date/time, doSomeWork will NOT write a record. If it starts getting date/time again, doSomeWork will write a record with the last valid location again.
When the GPS first starts, it will get a good date/time, and it will be copied into the global fix structure for doSomeWork to use. That routine will not write anything, because it does not have a valid location yet.
When the GPS finally gets a location, it will be copied into the global fix structure. Then doSomeWork will write a record, because it has all three pieces (date, time & location).
If the GPS stops getting locations, but it still has date/time, doSomeWork will write a record with the last valid location.
If the GPS stops getting date/time, doSomeWork will NOT write a record. If it starts getting date/time again, doSomeWork will write a record with the last valid location again.
That is exactly what i wanted, I am trying your code now
thank you for help..
Do you mean that each member of the Rugby team will have an Arduino with GPS attached to him?
mudassir9999:
I am making PCBs with custom Arduino on it..
I understand. I didn't really think that you would be tucking an Uno into someone's jock-strap.
My question was really leading on to what is the purpose of equipping each player with an Arduino and GPS.
And a rugby player (in a rugby match) must be one of the harshest environments for an operating micro-processor system - moisture, vibration, severe impacts ... (foul language).