PUD: clear speed and direction when stationary
authorFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 27 Jun 2012 12:49:18 +0000 (14:49 +0200)
committerFerry Huberts <ferry.huberts@pelagic.nl>
Wed, 27 Jun 2012 12:56:04 +0000 (14:56 +0200)
Signed-off-by: Ferry Huberts <ferry.huberts@pelagic.nl>
lib/pud/src/receiver.c

index 3b28ada..8762e11 100644 (file)
@@ -728,6 +728,17 @@ bool receiverUpdateGpsInformation(unsigned char * rxBuffer, size_t rxCount) {
        if ((externalState == MOVEMENT_STATE_MOVING) || updateTransmitGpsInformation) {
                transmitGpsInformation.txPosition.nmeaInfo = posAvgEntry->nmeaInfo;
                transmitGpsInformation.positionUpdated = true;
+
+               /*
+                * When we're stationary:
+                * - the direction is not reliable or even invalid, so we must clear it.
+                * - to avoid confusion in consumers of the data, we must clear the speed
+                *   because it is possible to have a very low speed while moving.
+                */
+               if (externalState == MOVEMENT_STATE_STATIONARY) {
+                       transmitGpsInformation.txPosition.nmeaInfo.speed = (double)0.0;
+                       transmitGpsInformation.txPosition.nmeaInfo.direction = (double)0.0;
+               }
        }
 
        if (externalStateChange) {