public void CheckMotionState(Coordinates lastLocation) { MotionState state = currentMotionState; if (lastLocations.Count > 0 && lastLocation.Equals(lastLocations[lastLocations.Count - 1])) { state = MotionState.Idle; } else { lastLocations.Add(lastLocation); int max = 10; if (lastLocations.Count == max + 1) { lastLocations.RemoveAt(0); } //Speed is returned in m/s currentSpeed = GPSSpeedUtils.GetSpeedFromCoordinatesList(lastLocations); if (currentSpeed < 0.5f) { state = MotionState.Idle; } else if (currentSpeed < 3f) { state = MotionState.Walk; } else { state = MotionState.Run; } } if (state != currentMotionState) { currentMotionState = state; if (OnMotionStateChanged != null) { OnMotionStateChanged.Invoke(currentMotionState); } } }