Using the #include <TinyGPS++.h> library I did distance traveled as per the below.

```
void fGPS_Parse( void * parameter )
{
TickType_t xDoDistanceExpireTicks;
struct stuTime *pxTime;
// struct stuDate pxDate;
struct stuPosit pxPosit;
struct stuDistance pxDistance;
struct stuSpeed pxSpeed;
float Alti;
float Hdg;
int Sats;
float LatNow;
float LonNow;
float LatPast;
float LonPast;
int DoDistanceTicks = 5000;
////
xDoDistanceExpireTicks = xTaskGetTickCount() + pdMS_TO_TICKS( DoDistanceTicks ); // add DoDistanceTicks mS worth of ticks to current tick count
for (;;)
{
xEventGroupWaitBits (eg, GPS_Parse, pdTRUE, pdTRUE, portMAX_DELAY) ;
//query GPS: has a new complete chunk of data been received?
if ( GPSSerial.available() > 1 )
{
if ( GPS.encode(GPSSerial.read()) )
{
// if (totalGPGSVMessages.isUpdated()) ///????????????????
// {
if ( GPS.location.isValid())
{
//used for distance calculation
LatNow = GPS.location.lat();
LonNow = GPS.location.lng();
// //
if ( xSemaphoreTake( sema_Posit, xSemaphoreTicksToWait ) == pdTRUE )
{
pxPosit.Lat = LatNow; // store data into structure
pxPosit.Lon = LonNow;
xQueueOverwrite( xQ_Posit, (void *) &pxPosit );
if ( xSemaphoreTake( sema_UTM, xSemaphoreTicksToWait ) == pdTRUE ) // place lat lon for utm calculation
{
xUTM_Posit.Lat = pxPosit.Lat;
xUTM_Posit.Lon = pxPosit.Lon;
xSemaphoreGive( sema_UTM );
}
xSemaphoreGive( sema_Posit );
}
} // if ( GPS.location.isValid())
// do distance calculations
if ( xTaskGetTickCount() >= xDoDistanceExpireTicks ) // do only once every xDoDistanceExpireTicks
{
if ( xSemaphoreTake( sema_CalDistance, xSemaphoreTicksToWait ) == pdTRUE ) // has tick count expired
{
if ( LatPast != 0.0 )
{
pxDistance.Distance = (unsigned long)TinyGPSPlus::distanceBetween( LatNow, LonNow, LatPast, LonPast) / 1000; // in Kilometers
xQueueSendToBack( xQ_DistanceMessage, (void *) &pxDistance, xTicksToWait0 );
// unsigned long distanceKmToLondon = (unsigned long)TinyGPSPlus::distanceBetween( gps.location.lat(), gps.location.lng(), LONDON_LAT, LONDON_LON) / 1000;
}
LatPast = LatNow; // update past lat n lon with now lat lon for next calculation
LonPast = LonNow;
xSemaphoreGive( sema_CalDistance );
}
xDoDistanceExpireTicks = xTaskGetTickCount() + pdMS_TO_TICKS( DoDistanceTicks ); // set new time peorid to do distance calculation
} // if ( xTaskGetTickCount() >= xDoDistanceExpireTicks )
if (GPS.speed.isValid())
{
if ( xSemaphoreTake( sema_Speed, xSemaphoreTicksToWait ) == pdTRUE ) // has tick count expired
{
pxSpeed.MPH = GPS.speed.mph();
pxSpeed.KPH = GPS.speed.kmph();
// xSpeed.MPH = GPS.speed.mph();
// xSpeed.KPH = GPS.speed.kmph();
xQueueOverwrite( xQ_Speed, (void *) &pxSpeed );
xSemaphoreGive( sema_Speed );
}
//}
} // if ( GPS.location.isValid())
if (GPS.time.isValid())
{
xTime.iSeconds = GPS.time.second();
xTime.iMinutes = GPS.time.minute();
xTime.iHours = GPS.time.hour();
if ( xSemaphoreTake( sema_Time, xSemaphoreTicksToWait ) == pdTRUE )
{
pxTime = &xTime;
xQueueOverwrite( xQ_Time, (void *) &pxTime );
xSemaphoreGive( sema_Time );
}
} // if (GPS.time.isValid())
if (GPS.date.isValid())
{
if ( xSemaphoreTake( sema_Date, xSemaphoreTicksToWait ) == pdTRUE )
{
xDate.iMonth = GPS.date. month();
xDate.iDay = GPS.date.day();
xDate.iYear = GPS.date.year();
xSemaphoreGive( sema_Date );
}
}
if ( GPS.satellites.isValid() )
{
if ( xSemaphoreTake( sema_Sats, xSemaphoreTicksToWait ) == pdTRUE )
{
Sats = GPS.satellites.value();
xQueueOverwrite( xQ_Sats, ( void * ) &Sats );
xSemaphoreGive( sema_Sats );
}
}
if ( GPS.altitude.isValid() )
{
if ( xSemaphoreTake( sema_Alti, xSemaphoreTicksToWait ) == pdTRUE )
{
Alti = GPS.altitude.meters();
xQueueOverwrite( xQ_Alti, ( void * ) &Alti );
xSemaphoreGive( sema_Alti );
}
} // if ( GPS.altitude.isValid() )
if ( GPS.course.isUpdated() )
{
if ( xSemaphoreTake( sema_Hdg, xSemaphoreTicksToWait ) == pdTRUE )
{
Hdg = GPS.course.deg();
xQueueOverwrite( xQ_Hdg, ( void * ) &Hdg );
xSemaphoreGive( sema_Hdg );
}
} // if ( GPS.course.isUpdated() )
// Serial.print( "fGPS_Parse " );
// Serial.print( " " );
// Serial.print(uxTaskGetStackHighWaterMark( NULL ));
// Serial.println();
// Serial.flush();
} // if ( GPS.encode(GPSSerial.read()))
} // if ( GPSSerial.available() > 0 )
// else
// {
xSemaphoreGive( sema_GPS_Gate ); // see (xSemaphoreTakeFromISR(sema_GPS_Gate, &xHigherPriorityTaskWoken)) in void IRAM_ATTR onTimer()
// }
} // for (;;)
vTaskDelete( NULL );
} // void fGPS_Parse( void *pdata )
```