diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2012-05-31 14:45:12 +0200 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2012-05-31 14:50:10 +0200 |
| commit | 3e2d0a118596ab44857bec60d761fc2bfdeeb0be (patch) | |
| tree | e8511b558cd991367828011766a048ba864245ac /main/src/cgeo/geocaching/ui/CompassView.java | |
| parent | b3114d061ee3053bb9f1c200aabcc6387a9dfb35 (diff) | |
| download | cgeo-3e2d0a118596ab44857bec60d761fc2bfdeeb0be.zip cgeo-3e2d0a118596ab44857bec60d761fc2bfdeeb0be.tar.gz cgeo-3e2d0a118596ab44857bec60d761fc2bfdeeb0be.tar.bz2 | |
Add a function to compute a normalized angle difference
Diffstat (limited to 'main/src/cgeo/geocaching/ui/CompassView.java')
| -rw-r--r-- | main/src/cgeo/geocaching/ui/CompassView.java | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/main/src/cgeo/geocaching/ui/CompassView.java b/main/src/cgeo/geocaching/ui/CompassView.java index 6f5b8b9..56cba9d 100644 --- a/main/src/cgeo/geocaching/ui/CompassView.java +++ b/main/src/cgeo/geocaching/ui/CompassView.java @@ -1,5 +1,6 @@ package cgeo.geocaching.ui; +import cgeo.geocaching.DirectionProvider; import cgeo.geocaching.R; import cgeo.geocaching.utils.PeriodicHandler; @@ -153,7 +154,8 @@ public class CompassView extends View { public void act() { final double newAzimuthShown = smoothUpdate(northMeasured, azimuthShown); final double newCacheHeadingShown = smoothUpdate(cacheHeadingMeasured, cacheHeadingShown); - if (Math.abs(newAzimuthShown - azimuthShown) >= 2 || Math.abs(newCacheHeadingShown - cacheHeadingShown) >= 2) { + if (Math.abs(DirectionProvider.difference(azimuthShown, newAzimuthShown)) >= 2 || + Math.abs(DirectionProvider.difference(cacheHeadingShown, newCacheHeadingShown)) >= 2) { synchronized(CompassView.this) { azimuthShown = newAzimuthShown; cacheHeadingShown = newCacheHeadingShown; |
