Robin2:
Look at this version of loop() and your functions. Note how loop() is now empty and all the functions are defined outside of it.Next thing is to figure out the code you need to put into loop() to use your functions. I suggest you first get it to show the data on the Serial Monitor from the code in loop() rather than from the individual functions. Comment out all the printing lines within the functions.
void loop() {
}
GeoTurn checkGPS() {
unsigned long start = millis();
while (millis() - start < GPS_UPDATE_INTERVAL) {
// If we recieved new location then take the coordinates and pack them into a struct
if (feedgps())
return gpsdump();
}
GeoLoc waypointLoc;
waypointLoc.lat = 0.0;
waypointLoc.lon = 0.0;
return waypointLoc;
}
// Get and process GPS data
GeoTurn gpsdump()
{
GeoLoc waypointLoc;
waypointLoc.lat = gps.location.lat();
waypointLoc.lon = gps.location.lng();
Serial.print("Position: ");
//Latitude
Serial.print("Latitude: ");
Serial.print(lat, 7);
Serial.print(",");
//Longitude
Serial.print("Longitude: ");
Serial.println(lon, 7);
return waypointLoc;
}
bool feedgps()
{
while (Serial1.available() > 0) {
if (gps.encode(Serial1.read()))
return true;
}
return false;
}
GeoStop checkGPS()
{
unsigned long start = millis();
while (millis() - start < GPS_UPDATE_INTERVAL) {
// If we recieved new location then take the coordinates and pack them into a struct
if (feedgps())
return gpsdump();
}
GeoLoc destinationLoc;
destinationLoc.lat = 0.0;
destinationLoc.lon = 0.0;
return destinationLoc;
}
GeoStop gpsdump()
{
GeoLoc destinationLoc;
destinationLoc.lat = gps.location.lat();
destinationLoc.lon = gps.location.lng();
Serial.print("Position: ");
//Latitude
Serial.print("Latitude: ");
Serial.print(lat, 7);
Serial.print(",");
//Longitude
Serial.print("Longitude: ");
Serial.println(lon, 7);
return destinationLoc;
}
// Feed data as it becomes available
//connect pin 16 and 17
// Feed data as it becomes available
bool feedgps()
{
while (Serial2.available() > 0) {
if (gps.encode(Serial2.read()))
return true;
}
return false;
}
...R
ive changed to the way you changed the code leaving the loop() empty
i receive an error
[error: ambiguating new declaration of 'GeoStop checkGPS()'
GeoStop checkGPS()
and
note: old declaration 'GeoTurn checkGPS()'
GeoTurn checkGPS() {
]