Reduce sensor sampling frequency
This commit is contained in:
1 parent
bf3321b896
commit
4d00ee3062
5 files changed
+2
-6
No files matched your search
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -2,10 +2,6 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<uses-permission
|
||||
android:name="android.permission.HIGH_SAMPLING_RATE_SENSORS"
|
||||
tools:ignore="HighSamplingRate" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:enableOnBackInvokedCallback="true"
|
||||
|
||||
@@ -49,7 +49,7 @@ class UISensor(context: Context) {
|
||||
val y = event.values[1]
|
||||
val norm = sqrt(x * x + y * y + 9.81f * 9.81f)
|
||||
|
||||
val alpha = 0.025f
|
||||
val alpha = 0.5f
|
||||
gravityAngle = gravityAngle * (1f - alpha) + atan2(y, x) * (180f / PI).toFloat() * alpha
|
||||
gravity = gravity * (1f - alpha) + Offset(x / norm, y / norm) * alpha
|
||||
}
|
||||
@@ -59,7 +59,7 @@ class UISensor(context: Context) {
|
||||
}
|
||||
|
||||
fun start() {
|
||||
sensorManager.registerListener(listener, accelerometer, SensorManager.SENSOR_DELAY_FASTEST)
|
||||
sensorManager.registerListener(listener, accelerometer, SensorManager.SENSOR_DELAY_UI)
|
||||
}
|
||||
|
||||
fun stop() {
|
||||
|
||||
Reference in new issue
Block a user