SlashDevin / NeoGPS

NMEA and ublox GPS parser for Arduino, configurable to use as few as 10 bytes of RAM
GNU General Public License v3.0
702 stars 195 forks source link

add up distances? (odometer) #160

Closed pcace closed 1 year ago

pcace commented 2 years ago

Hi there, i am trying to find the problem why this code is not working:

    if (currentFix.valid.location)
    {
      currentLat = currentFix.latitude(), 8;
      currentLon = currentFix.longitude(), 8;
      if ((currentLat != prevLat) && (currentLon != prevLon))
      {
        if (hadFix) //prevent 0 prevFix with current location the first time it has a fix
        {

          distA = distA + currentFix.location.DistanceKm(prevFix.location);
        }
        prevLat = currentLat;
        prevLon = currentLon;
        hadFix = true;
      }

    }
    else
    {
      Debug.println(", no Location currentFix!");
      Serial.println(", no Location currentFix!");
    }

i am getting a number for distA wich is growing, but the weird thing is, that this number is crazy high - it starts at around 500.000 and raises each second for around 10.000. waht is this - a wrong unit? or am a doing sth else strange? prevLat, prevLon, currentLat, currentLon are float values.

If you have any idea what is going on there i would be really happy to hear it ;)

Thank you so much,

pcace

pcace commented 1 year ago

sorry for that issue - it was a wrong usage of datatypes (float/int etc)