From 83984a1f4c9565299db394150d669a867988d545 Mon Sep 17 00:00:00 2001 From: Victor Shcherb Date: Wed, 22 May 2013 01:31:18 +0200 Subject: [PATCH] Add settings for kalman filter --- OsmAnd/res/values/strings.xml | 5 ++++- OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java | 4 +++- OsmAnd/src/net/osmand/plus/OsmandSettings.java | 1 + .../net/osmand/plus/activities/SettingsGeneralActivity.java | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml index 10ca12a4f2..ea12fd865a 100644 --- a/OsmAnd/res/values/strings.xml +++ b/OsmAnd/res/values/strings.xml @@ -9,9 +9,12 @@ 3. All your modified/created strings are in the top of the file (to make easier find what\'s translated). PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy --> + + Use Kalman filter to avoid compass aberrations + Use Kalman filter Accessibility mode : please select destination first Use magnetic sensor to determine compass value instead of orientation sensor - Use magnetic sensor (compass) + Use magnetic sensor Other %1$d files left Available %1$d files to download diff --git a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java index 96905d8092..96cd134cdc 100644 --- a/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java +++ b/OsmAnd/src/net/osmand/plus/OsmAndLocationProvider.java @@ -92,12 +92,14 @@ public class OsmAndLocationProvider implements SensorEventListener { private Listener gpsStatusListener; private float[] mRotationM = new float[9]; private OsmandPreference USE_MAGNETIC_FIELD_SENSOR_COMPASS; + private OsmandPreference uSE_FILTER_FOR_COMPASS; public OsmAndLocationProvider(OsmandApplication app) { this.app = app; navigationInfo = new NavigationInfo(app); settings = app.getSettings(); USE_MAGNETIC_FIELD_SENSOR_COMPASS = settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS; + uSE_FILTER_FOR_COMPASS = settings.USE_KALMAN_FILTER_FOR_COMPASS; currentPositionHelper = new CurrentPositionHelper(app); locationSimulation = new OsmAndLocationSimulation(app, this); } @@ -307,7 +309,7 @@ public class OsmAndLocationProvider implements SensorEventListener { lastValSin = (float) Math.sin(valRad); lastValCos = (float) Math.cos(valRad); // lastHeadingCalcTime = System.currentTimeMillis(); - boolean filter = true; //USE_MAGNETIC_FIELD_SENSOR_COMPASS.get(); + boolean filter = uSE_FILTER_FOR_COMPASS.get(); //USE_MAGNETIC_FIELD_SENSOR_COMPASS.get(); if (filter) { filterCompassValue(); } else { diff --git a/OsmAnd/src/net/osmand/plus/OsmandSettings.java b/OsmAnd/src/net/osmand/plus/OsmandSettings.java index 476a815cb9..ec789e5f96 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandSettings.java +++ b/OsmAnd/src/net/osmand/plus/OsmandSettings.java @@ -604,6 +604,7 @@ public class OsmandSettings { public final OsmandPreference USE_HIGH_RES_MAPS = new BooleanPreference("use_high_res_maps", true).makeGlobal().cache(); public final OsmandPreference USE_MAGNETIC_FIELD_SENSOR_COMPASS = new BooleanPreference("use_magnetic_field_sensor_compass", true).makeGlobal().cache(); + public final OsmandPreference USE_KALMAN_FILTER_FOR_COMPASS = new BooleanPreference("use_kalman_filter_compass", true).makeGlobal().cache(); // this value string is synchronized with settings_pref.xml preference name public final OsmandPreference MAP_TEXT_SIZE = new FloatPreference("map_text_size", 1.0f).makeProfile().cache(); diff --git a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java index 182e620bbf..335db59b41 100644 --- a/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java +++ b/OsmAnd/src/net/osmand/plus/activities/SettingsGeneralActivity.java @@ -23,6 +23,7 @@ import android.content.DialogInterface.OnClickListener; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.res.Configuration; +import android.hardware.SensorManager; import android.media.AudioManager; import android.os.AsyncTask; import android.os.Bundle; @@ -114,6 +115,7 @@ public class SettingsGeneralActivity extends SettingsBaseActivity { } screen.addPreference(createCheckBoxPreference(settings.USE_MAGNETIC_FIELD_SENSOR_COMPASS, R.string.use_magnetic_sensor, R.string.use_magnetic_sensor_descr)); + screen.addPreference(createCheckBoxPreference(settings.USE_KALMAN_FILTER_FOR_COMPASS, R.string.use_kalman_filter_compass, R.string.use_kalman_filter_compass_descr)); registerBooleanPreference(settings.USE_ENGLISH_NAMES, screen); registerBooleanPreference(settings.LEFT_SIDE_NAVIGATION, screen);