pud: posavg: make sure to put track, mtrack and magvar in the cumulative
authorFerry Huberts <ferry.huberts@pelagic.nl>
Mon, 16 Jul 2012 16:00:40 +0000 (18:00 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Mon, 16 Jul 2012 16:02:14 +0000 (18:02 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/pud/src/posAvg.c

index 4c9d9ed..fe6c91f 100644 (file)
@@ -540,8 +540,13 @@ static void addOrRemoveEntryToFromCumulativeAverage(
                        : -entry->nmeaInfo.speed;
 
        /* track, mtrack, magvar */
+       cumulative->nmeaInfo.track += add ? entry->nmeaInfo.track : -entry->nmeaInfo.track;
        addAngleComponents(&cumulative->track, &entry->track, add);
+
+       cumulative->nmeaInfo.mtrack += add ? entry->nmeaInfo.mtrack : -entry->nmeaInfo.mtrack;
        addAngleComponents(&cumulative->mtrack, &entry->mtrack, add);
+
+       cumulative->nmeaInfo.magvar += add ? entry->nmeaInfo.magvar : -entry->nmeaInfo.magvar;
        addAngleComponents(&cumulative->magvar, &entry->magvar, add);
 
        /* adjust list count */