From a1787d92abf9e210a9de7d770a0d9b0fc15e7703 Mon Sep 17 00:00:00 2001 From: Chandra-Mauli-Sharma Date: Fri, 7 Apr 2023 22:40:20 +0530 Subject: [PATCH 01/17] [WIP]Support for Gyroscope Limited Axes sensor --- README.md | 2 +- .../GyroscopeLimitedAxisSensorState.kt | 81 +++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 composesensors/src/main/java/com/mutualmobile/composesensors/GyroscopeLimitedAxisSensorState.kt diff --git a/README.md b/README.md index e4c92b0..ae12a53 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ Accelerometer (Uncalibrated) | ⚠️ | WIP Hinge Angle | ⚠️ | WIP Head Tracker | — | N/A Accelerometer Limited Axes | — | N/A -Gyroscope Limited Axes | — | N/A +Gyroscope Limited Axes | ⚠️ | WIP Accelerometer Limited Axes (Uncalibrated) | — | N/A Gyroscope Limited Axes (Uncalibrated) | — | N/A Heading | ⚠️ | WIP diff --git a/composesensors/src/main/java/com/mutualmobile/composesensors/GyroscopeLimitedAxisSensorState.kt b/composesensors/src/main/java/com/mutualmobile/composesensors/GyroscopeLimitedAxisSensorState.kt new file mode 100644 index 0000000..001f7a0 --- /dev/null +++ b/composesensors/src/main/java/com/mutualmobile/composesensors/GyroscopeLimitedAxisSensorState.kt @@ -0,0 +1,81 @@ +package com.mutualmobile.composesensors + +import androidx.compose.runtime.* + +@Immutable +class GyroscopeLimitedAxisSensorState internal constructor( + val xAxisSupported: Float = 0f, + val yAxisSupported: Float = 0f, + val zAxisSupported: Float = 0f, + val xRotation: Float = 0f, + val yRotation: Float = 0f, + val zRotation: Float = 0f, + val isAvailable: Boolean = false, + val accuracy: Int = 0, +) { + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as GyroscopeLimitedAxisSensorState + + if (xAxisSupported != other.xAxisSupported) return false + if (yAxisSupported != other.yAxisSupported) return false + if (zAxisSupported != other.zAxisSupported) return false + if (xRotation != other.xRotation) return false + if (yRotation != other.yRotation) return false + if (zRotation != other.zRotation) return false + if (isAvailable != other.isAvailable) return false + return accuracy == other.accuracy + } + + override fun hashCode(): Int { + var result = xAxisSupported.hashCode() + result = 31 * result + yAxisSupported.hashCode() + result = 31 * result + zAxisSupported.hashCode() + result = 31 * result + xRotation.hashCode() + result = 31 * result + yRotation.hashCode() + result = 31 * result + zRotation.hashCode() + result = 31 * result + isAvailable.hashCode() + result = 31 * result + accuracy + return result + } + + override fun toString(): String { + return "GyroscopeLimitedAxisSensorState(xAxisSupported=$xAxisSupported, yAxisSupported=$yAxisSupported, zAxisSupported=$zAxisSupported, xRotation=$xRotation, yRotation=$yRotation, zRotation=$zRotation, isAvailable=$isAvailable, accuracy=$accuracy)" + } + +} + +@Composable +fun rememberGyroscopeLimitedAxisSensorState( + sensorDelay: SensorDelay = SensorDelay.Normal, + onError: (throwable: Throwable) -> Unit = {}, +): GyroscopeLimitedAxisSensorState { + val sensorState = rememberSensorState( + sensorType = SensorType.GyroscopeLimitedAxes, + sensorDelay = sensorDelay, + onError = onError + ) + + val gyroscopeLimitedAxisSensor = remember { mutableStateOf(GyroscopeLimitedAxisSensorState()) } + + LaunchedEffect(key1 = sensorState, block = { + val sensorStateValues = sensorState.data + if (sensorStateValues.isNotEmpty()) { + gyroscopeLimitedAxisSensor.value = GyroscopeLimitedAxisSensorState( + xAxisSupported = sensorStateValues[0], + yAxisSupported = sensorStateValues[1], + zAxisSupported = sensorStateValues[2], + xRotation = sensorStateValues[3], + yRotation = sensorStateValues[4], + zRotation = sensorStateValues[5], + isAvailable = sensorState.isAvailable, + accuracy = sensorState.accuracy + ) + } + }) + + return gyroscopeLimitedAxisSensor.value +} \ No newline at end of file From 2275818da9e9b9e605da65f129d4fa10a876ec59 Mon Sep 17 00:00:00 2001 From: Chandra-Mauli-Sharma Date: Fri, 7 Apr 2023 22:48:34 +0530 Subject: [PATCH 02/17] Minor typo --- ...State.kt => GyroscopeLimitedAxesSensorState.kt} | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) rename composesensors/src/main/java/com/mutualmobile/composesensors/{GyroscopeLimitedAxisSensorState.kt => GyroscopeLimitedAxesSensorState.kt} (86%) diff --git a/composesensors/src/main/java/com/mutualmobile/composesensors/GyroscopeLimitedAxisSensorState.kt b/composesensors/src/main/java/com/mutualmobile/composesensors/GyroscopeLimitedAxesSensorState.kt similarity index 86% rename from composesensors/src/main/java/com/mutualmobile/composesensors/GyroscopeLimitedAxisSensorState.kt rename to composesensors/src/main/java/com/mutualmobile/composesensors/GyroscopeLimitedAxesSensorState.kt index 001f7a0..8ef994c 100644 --- a/composesensors/src/main/java/com/mutualmobile/composesensors/GyroscopeLimitedAxisSensorState.kt +++ b/composesensors/src/main/java/com/mutualmobile/composesensors/GyroscopeLimitedAxesSensorState.kt @@ -3,7 +3,7 @@ package com.mutualmobile.composesensors import androidx.compose.runtime.* @Immutable -class GyroscopeLimitedAxisSensorState internal constructor( +class GyroscopeLimitedAxesSensorState internal constructor( val xAxisSupported: Float = 0f, val yAxisSupported: Float = 0f, val zAxisSupported: Float = 0f, @@ -18,7 +18,7 @@ class GyroscopeLimitedAxisSensorState internal constructor( if (this === other) return true if (javaClass != other?.javaClass) return false - other as GyroscopeLimitedAxisSensorState + other as GyroscopeLimitedAxesSensorState if (xAxisSupported != other.xAxisSupported) return false if (yAxisSupported != other.yAxisSupported) return false @@ -49,22 +49,22 @@ class GyroscopeLimitedAxisSensorState internal constructor( } @Composable -fun rememberGyroscopeLimitedAxisSensorState( +fun rememberGyroscopeLimitedAxesSensorState( sensorDelay: SensorDelay = SensorDelay.Normal, onError: (throwable: Throwable) -> Unit = {}, -): GyroscopeLimitedAxisSensorState { +): GyroscopeLimitedAxesSensorState { val sensorState = rememberSensorState( sensorType = SensorType.GyroscopeLimitedAxes, sensorDelay = sensorDelay, onError = onError ) - val gyroscopeLimitedAxisSensor = remember { mutableStateOf(GyroscopeLimitedAxisSensorState()) } + val gyroscopeLimitedAxesSensor = remember { mutableStateOf(GyroscopeLimitedAxesSensorState()) } LaunchedEffect(key1 = sensorState, block = { val sensorStateValues = sensorState.data if (sensorStateValues.isNotEmpty()) { - gyroscopeLimitedAxisSensor.value = GyroscopeLimitedAxisSensorState( + gyroscopeLimitedAxesSensor.value = GyroscopeLimitedAxesSensorState( xAxisSupported = sensorStateValues[0], yAxisSupported = sensorStateValues[1], zAxisSupported = sensorStateValues[2], @@ -77,5 +77,5 @@ fun rememberGyroscopeLimitedAxisSensorState( } }) - return gyroscopeLimitedAxisSensor.value + return gyroscopeLimitedAxesSensor.value } \ No newline at end of file From 90b486b482d57b4cfb309bd13c2696e3eabfe8b9 Mon Sep 17 00:00:00 2001 From: Chandra-Mauli-Sharma Date: Fri, 7 Apr 2023 23:01:53 +0530 Subject: [PATCH 03/17] toString() Changed --- .../composesensors/GyroscopeLimitedAxesSensorState.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composesensors/src/main/java/com/mutualmobile/composesensors/GyroscopeLimitedAxesSensorState.kt b/composesensors/src/main/java/com/mutualmobile/composesensors/GyroscopeLimitedAxesSensorState.kt index 8ef994c..f43b944 100644 --- a/composesensors/src/main/java/com/mutualmobile/composesensors/GyroscopeLimitedAxesSensorState.kt +++ b/composesensors/src/main/java/com/mutualmobile/composesensors/GyroscopeLimitedAxesSensorState.kt @@ -43,7 +43,7 @@ class GyroscopeLimitedAxesSensorState internal constructor( } override fun toString(): String { - return "GyroscopeLimitedAxisSensorState(xAxisSupported=$xAxisSupported, yAxisSupported=$yAxisSupported, zAxisSupported=$zAxisSupported, xRotation=$xRotation, yRotation=$yRotation, zRotation=$zRotation, isAvailable=$isAvailable, accuracy=$accuracy)" + return "GyroscopeLimitedAxesSensorState(xAxisSupported=$xAxisSupported, yAxisSupported=$yAxisSupported, zAxisSupported=$zAxisSupported, xRotation=$xRotation, yRotation=$yRotation, zRotation=$zRotation, isAvailable=$isAvailable, accuracy=$accuracy)" } } From 3df85faf5a1cd6f440f8ea6545c3448b529a264e Mon Sep 17 00:00:00 2001 From: Shubham Singh Date: Wed, 12 Apr 2023 15:12:21 +0530 Subject: [PATCH 04/17] Implement HingeSensorState --- .../composesensors/HingeSensorState.kt | 80 +++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 composesensors/src/main/java/com/mutualmobile/composesensors/HingeSensorState.kt diff --git a/composesensors/src/main/java/com/mutualmobile/composesensors/HingeSensorState.kt b/composesensors/src/main/java/com/mutualmobile/composesensors/HingeSensorState.kt new file mode 100644 index 0000000..964102e --- /dev/null +++ b/composesensors/src/main/java/com/mutualmobile/composesensors/HingeSensorState.kt @@ -0,0 +1,80 @@ +package com.mutualmobile.composesensors + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.Immutable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember + +/** + * A hinge angle sensor measures the angle, in degrees, between two integral parts of the device. + * Movement of a hinge measured by this sensor type is expected to alter the ways in which the user + * can interact with the device, for example, by unfolding or revealing a display. + * @param angle Angle between two integral parts of the device (in degrees) + * @param isAvailable Whether the current device has a HingeAngle sensor. Defaults to false. + * @param accuracy Accuracy factor of the HingeAngle sensor. Defaults to 0. + * @see [rememberHingeAngleSensorState] + */ +@Immutable +class HingeAngleSensorState internal constructor( + val angle: Float = 0f, + val isAvailable: Boolean = false, + val accuracy: Int = 0, +) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is HingeAngleSensorState) return false + + if (angle != other.angle) return false + if (isAvailable != other.isAvailable) return false + if (accuracy != other.accuracy) return false + + return true + } + + override fun hashCode(): Int { + var result = angle.hashCode() + result = 31 * result + isAvailable.hashCode() + result = 31 * result + accuracy.hashCode() + return result + } + + override fun toString(): String { + return "HingeAngleSensorState(angle=$angle, isAvailable=$isAvailable, accuracy=$accuracy)" + } +} + +/** + * Creates and [remember]s an instance of [HingeAngleSensorState]. + * @param sensorDelay The rate at which the raw sensor data should be received. + * Defaults to [SensorDelay.Normal]. + * @param onError Callback invoked on every error state. + */ +@Composable +fun rememberHingeAngleSensorState( + sensorDelay: SensorDelay = SensorDelay.Normal, + onError: (throwable: Throwable) -> Unit = {}, +): HingeAngleSensorState { + val sensorState = rememberSensorState( + sensorType = SensorType.HingeAngle, + sensorDelay = sensorDelay, + onError = onError, + ) + val hingeAngleSensorState = remember { mutableStateOf(HingeAngleSensorState()) } + + LaunchedEffect( + key1 = sensorState, + block = { + val sensorStateValues = sensorState.data + if (sensorStateValues.isNotEmpty()) { + hingeAngleSensorState.value = HingeAngleSensorState( + angle = sensorStateValues[0], + isAvailable = sensorState.isAvailable, + accuracy = sensorState.accuracy + ) + } + } + ) + + return hingeAngleSensorState.value +} From 43b1764ccf285294a0bf674f070e196e39e9358e Mon Sep 17 00:00:00 2001 From: Shubham Singh Date: Wed, 12 Apr 2023 15:18:30 +0530 Subject: [PATCH 05/17] Rename HingeSensorState.kt to HingeAngleSensorState.kt --- .../{HingeSensorState.kt => HingeAngleSensorState.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename composesensors/src/main/java/com/mutualmobile/composesensors/{HingeSensorState.kt => HingeAngleSensorState.kt} (100%) diff --git a/composesensors/src/main/java/com/mutualmobile/composesensors/HingeSensorState.kt b/composesensors/src/main/java/com/mutualmobile/composesensors/HingeAngleSensorState.kt similarity index 100% rename from composesensors/src/main/java/com/mutualmobile/composesensors/HingeSensorState.kt rename to composesensors/src/main/java/com/mutualmobile/composesensors/HingeAngleSensorState.kt From 9c6229f4837fab6aaabf4879177805588bd0e539 Mon Sep 17 00:00:00 2001 From: Shubham Singh Date: Wed, 12 Apr 2023 15:20:06 +0530 Subject: [PATCH 06/17] Mention `rememberHingeAngleSensorState` in README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e4c92b0..0086b34 100644 --- a/README.md +++ b/README.md @@ -101,7 +101,7 @@ Motion Detect | — | N/A Heart Beat | — | N/A Low Latency Off-Body Detect | — | N/A Accelerometer (Uncalibrated) | ⚠️ | WIP -Hinge Angle | ⚠️ | WIP +Hinge Angle | ✅️ | rememberHingeAngleSensorState() Head Tracker | — | N/A Accelerometer Limited Axes | — | N/A Gyroscope Limited Axes | — | N/A From 159b59126c5e5b7e58647751808ab0cdc629389a Mon Sep 17 00:00:00 2001 From: Shubham Singh Date: Wed, 12 Apr 2023 15:22:43 +0530 Subject: [PATCH 07/17] Fix ktlint issues in HingeAngleSensorState.kt --- .../mutualmobile/composesensors/HingeAngleSensorState.kt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/composesensors/src/main/java/com/mutualmobile/composesensors/HingeAngleSensorState.kt b/composesensors/src/main/java/com/mutualmobile/composesensors/HingeAngleSensorState.kt index 964102e..e4b2bfc 100644 --- a/composesensors/src/main/java/com/mutualmobile/composesensors/HingeAngleSensorState.kt +++ b/composesensors/src/main/java/com/mutualmobile/composesensors/HingeAngleSensorState.kt @@ -19,7 +19,7 @@ import androidx.compose.runtime.remember class HingeAngleSensorState internal constructor( val angle: Float = 0f, val isAvailable: Boolean = false, - val accuracy: Int = 0, + val accuracy: Int = 0 ) { override fun equals(other: Any?): Boolean { if (this === other) return true @@ -53,12 +53,12 @@ class HingeAngleSensorState internal constructor( @Composable fun rememberHingeAngleSensorState( sensorDelay: SensorDelay = SensorDelay.Normal, - onError: (throwable: Throwable) -> Unit = {}, + onError: (throwable: Throwable) -> Unit = {} ): HingeAngleSensorState { val sensorState = rememberSensorState( sensorType = SensorType.HingeAngle, sensorDelay = sensorDelay, - onError = onError, + onError = onError ) val hingeAngleSensorState = remember { mutableStateOf(HingeAngleSensorState()) } From 1fffa0286ac6400e2a359dda33f3fe748078a0fe Mon Sep 17 00:00:00 2001 From: Swapnil Musale Date: Wed, 12 Apr 2023 23:09:59 +0530 Subject: [PATCH 08/17] Support for Magnetic Field Uncalibrated Sensor --- README.md | 2 +- .../MagneticFieldUncalibratedSensorState.kt | 106 ++++++++++++++++++ 2 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 composesensors/src/main/java/com/mutualmobile/composesensors/MagneticFieldUncalibratedSensorState.kt diff --git a/README.md b/README.md index 0086b34..1b6e73e 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ Linear Acceleration | ✅️ | rememberLinearAccelerationSensorState() Rotation Vector | ✅️️ | rememberRotationVectorSensorState() Relative Humidity | ⚠️ | WIP Ambient Temperature | ✅️ | rememberAmbientTemperatureSensorState() -Magnetic Field (Uncalibrated) | — | N/A +Magnetic Field (Uncalibrated) | ✅️️ | rememberMagneticFieldUncalibratedSensorState() GameRotation Vector | ✅️ | rememberGameRotationVectorSensorState() Gyroscope (Uncalibrated) | ⚠️ | WIP Significant Motion | — | N/A diff --git a/composesensors/src/main/java/com/mutualmobile/composesensors/MagneticFieldUncalibratedSensorState.kt b/composesensors/src/main/java/com/mutualmobile/composesensors/MagneticFieldUncalibratedSensorState.kt new file mode 100644 index 0000000..c427186 --- /dev/null +++ b/composesensors/src/main/java/com/mutualmobile/composesensors/MagneticFieldUncalibratedSensorState.kt @@ -0,0 +1,106 @@ +package com.mutualmobile.composesensors + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.Immutable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember + +/** + * An Magnetic Field Uncalibrated sensor is similar to Sensor.TYPE_MAGNETIC_FIELD here the hard iron calibration is reported separately instead of being included in the measurement. + * Factory calibration and temperature compensation will still be applied to the "uncalibrated" measurement. + * Assumptions that the magnetic field is due to the Earth's poles is avoided + * @param xUncalib Magnetic field in x axes (Including Soft Iron and temperature calibration) measured in micro tesla (uT). + * @param yUncalib Magnetic field in y axes (Including soft iron and temperature calibration) measured in micro tesla (uT). + * @param zUncalib Magnetic field in z axes (Including soft iron and temperature calibration) measured in micro tesla (uT). + * @param xBias Magnetic field in x axes (Including Hard iron calibration) measured in micro tesla (uT). + * @param yBias Magnetic field in y axes (Including Hard iron calibration) measured in micro tesla (uT). + * @param zBias Magnetic field in z axes (Including Hard iron calibration) measured in micro tesla (uT). + * @param isAvailable Whether the current device has an accelerometer sensor. Defaults to false. + * @param accuracy Accuracy factor of the accelerometer sensor. Defaults to 0. + */ +@Immutable +class MagneticFieldUncalibratedSensorState internal constructor( + val xUncalib: Float = 0f, + val yUncalib: Float = 0f, + val zUncalib: Float = 0f, + val xBias: Float = 0f, + val yBias: Float = 0f, + val zBias: Float = 0f, + val isAvailable: Boolean = false, + val accuracy: Int = 0, +) { + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (other !is MagneticFieldUncalibratedSensorState) return false + + if (xUncalib != other.xUncalib) return false + if (yUncalib != other.yUncalib) return false + if (zUncalib != other.zUncalib) return false + if (xBias != other.xBias) return false + if (yBias != other.yBias) return false + if (zBias != other.zBias) return false + if (isAvailable != other.isAvailable) return false + if (accuracy != other.accuracy) return false + + return true + } + + override fun hashCode(): Int { + var result = xUncalib.hashCode() + result = 31 * result + yUncalib.hashCode() + result = 31 * result + zUncalib.hashCode() + result = 31 * result + xBias.hashCode() + result = 31 * result + yBias.hashCode() + result = 31 * result + zBias.hashCode() + result = 31 * result + accuracy.hashCode() + return result + } + + override fun toString(): String { + return "MagneticFieldUncalibratedSensorState(xUncalib=$xUncalib, yUncalib=$yUncalib, zUncalib=$zUncalib, " + + "xBias=$xBias, yBias=$yBias, zBias=$zBias, " + + "isAvailable=$isAvailable, accuracy=$accuracy)" + } +} + +/** + * Creates and [remember]s an instance of [MagneticFieldUncalibratedSensorState]. + * @param sensorDelay The rate at which the raw sensor data should be received. + * Defaults to [SensorDelay.Normal]. + * @param onError Callback invoked on every error state. + */ +@Composable +fun rememberMagneticFieldUncalibratedSensorState( + sensorDelay: SensorDelay = SensorDelay.Normal, + onError: (throwable: Throwable) -> Unit = {}, +): MagneticFieldUncalibratedSensorState { + val sensorState = rememberSensorState( + sensorType = SensorType.MagneticFieldUncalibrated, + sensorDelay = sensorDelay, + onError = onError, + ) + val magneticFieldUncalibratedSensorState = + remember { mutableStateOf(MagneticFieldUncalibratedSensorState()) } + + LaunchedEffect( + key1 = sensorState, + block = { + val sensorStateValues = sensorState.data + if (sensorStateValues.isNotEmpty()) { + magneticFieldUncalibratedSensorState.value = MagneticFieldUncalibratedSensorState( + xUncalib = sensorStateValues[0], + yUncalib = sensorStateValues[1], + zUncalib = sensorStateValues[2], + xBias = sensorStateValues[3], + yBias = sensorStateValues[4], + zBias = sensorStateValues[5], + isAvailable = sensorState.isAvailable, + accuracy = sensorState.accuracy, + ) + } + }, + ) + + return magneticFieldUncalibratedSensorState.value +} From e6b4d26059d25aff1a0b85c9af8ab578a53cf5f4 Mon Sep 17 00:00:00 2001 From: Swapnil Musale Date: Thu, 13 Apr 2023 16:41:55 +0530 Subject: [PATCH 09/17] KtLink formatting issue --- .../MagneticFieldUncalibratedSensorState.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/composesensors/src/main/java/com/mutualmobile/composesensors/MagneticFieldUncalibratedSensorState.kt b/composesensors/src/main/java/com/mutualmobile/composesensors/MagneticFieldUncalibratedSensorState.kt index c427186..a4e5236 100644 --- a/composesensors/src/main/java/com/mutualmobile/composesensors/MagneticFieldUncalibratedSensorState.kt +++ b/composesensors/src/main/java/com/mutualmobile/composesensors/MagneticFieldUncalibratedSensorState.kt @@ -28,7 +28,7 @@ class MagneticFieldUncalibratedSensorState internal constructor( val yBias: Float = 0f, val zBias: Float = 0f, val isAvailable: Boolean = false, - val accuracy: Int = 0, + val accuracy: Int = 0 ) { override fun equals(other: Any?): Boolean { if (this === other) return true @@ -73,12 +73,12 @@ class MagneticFieldUncalibratedSensorState internal constructor( @Composable fun rememberMagneticFieldUncalibratedSensorState( sensorDelay: SensorDelay = SensorDelay.Normal, - onError: (throwable: Throwable) -> Unit = {}, + onError: (throwable: Throwable) -> Unit = {} ): MagneticFieldUncalibratedSensorState { val sensorState = rememberSensorState( sensorType = SensorType.MagneticFieldUncalibrated, sensorDelay = sensorDelay, - onError = onError, + onError = onError ) val magneticFieldUncalibratedSensorState = remember { mutableStateOf(MagneticFieldUncalibratedSensorState()) } @@ -96,10 +96,10 @@ fun rememberMagneticFieldUncalibratedSensorState( yBias = sensorStateValues[4], zBias = sensorStateValues[5], isAvailable = sensorState.isAvailable, - accuracy = sensorState.accuracy, + accuracy = sensorState.accuracy ) } - }, + } ) return magneticFieldUncalibratedSensorState.value From 223a9f0bb275ede221131b5867bb5a5b35bca2a4 Mon Sep 17 00:00:00 2001 From: Swapnil Musale Date: Thu, 13 Apr 2023 17:41:32 +0530 Subject: [PATCH 10/17] hashcode implementation --- .../composesensors/MagneticFieldUncalibratedSensorState.kt | 1 + 1 file changed, 1 insertion(+) diff --git a/composesensors/src/main/java/com/mutualmobile/composesensors/MagneticFieldUncalibratedSensorState.kt b/composesensors/src/main/java/com/mutualmobile/composesensors/MagneticFieldUncalibratedSensorState.kt index a4e5236..faae64d 100644 --- a/composesensors/src/main/java/com/mutualmobile/composesensors/MagneticFieldUncalibratedSensorState.kt +++ b/composesensors/src/main/java/com/mutualmobile/composesensors/MagneticFieldUncalibratedSensorState.kt @@ -54,6 +54,7 @@ class MagneticFieldUncalibratedSensorState internal constructor( result = 31 * result + yBias.hashCode() result = 31 * result + zBias.hashCode() result = 31 * result + accuracy.hashCode() + result = 31 * result + isAvailable.hashCode() return result } From d1a7fb001ace859ddb3bc38dddc796abd790b368 Mon Sep 17 00:00:00 2001 From: Swapnil Musale Date: Thu, 13 Apr 2023 22:57:38 +0530 Subject: [PATCH 11/17] Changes as per PR Suggestions --- README.md | 2 +- .../MagneticFieldUncalibratedSensorState.kt | 58 +++++++++---------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 1b6e73e..df14b26 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ Linear Acceleration | ✅️ | rememberLinearAccelerationSensorState() Rotation Vector | ✅️️ | rememberRotationVectorSensorState() Relative Humidity | ⚠️ | WIP Ambient Temperature | ✅️ | rememberAmbientTemperatureSensorState() -Magnetic Field (Uncalibrated) | ✅️️ | rememberMagneticFieldUncalibratedSensorState() +Magnetic Field (Uncalibrated) | ✅️️ | rememberUncalibratedMagneticFieldSensorState() GameRotation Vector | ✅️ | rememberGameRotationVectorSensorState() Gyroscope (Uncalibrated) | ⚠️ | WIP Significant Motion | — | N/A diff --git a/composesensors/src/main/java/com/mutualmobile/composesensors/MagneticFieldUncalibratedSensorState.kt b/composesensors/src/main/java/com/mutualmobile/composesensors/MagneticFieldUncalibratedSensorState.kt index faae64d..0bd1817 100644 --- a/composesensors/src/main/java/com/mutualmobile/composesensors/MagneticFieldUncalibratedSensorState.kt +++ b/composesensors/src/main/java/com/mutualmobile/composesensors/MagneticFieldUncalibratedSensorState.kt @@ -7,23 +7,23 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember /** - * An Magnetic Field Uncalibrated sensor is similar to Sensor.TYPE_MAGNETIC_FIELD here the hard iron calibration is reported separately instead of being included in the measurement. + * An Uncalibrated Magnetic Field sensor is similar to [SensorType.MagneticField] but the hard iron calibration is reported separately instead of being included in the measurement. * Factory calibration and temperature compensation will still be applied to the "uncalibrated" measurement. - * Assumptions that the magnetic field is due to the Earth's poles is avoided - * @param xUncalib Magnetic field in x axes (Including Soft Iron and temperature calibration) measured in micro tesla (uT). - * @param yUncalib Magnetic field in y axes (Including soft iron and temperature calibration) measured in micro tesla (uT). - * @param zUncalib Magnetic field in z axes (Including soft iron and temperature calibration) measured in micro tesla (uT). + * Assumptions are that the magnetic field is due to the Earth's poles being avoided. + * @param xStrength Magnetic field in x axes (Including Soft Iron and temperature calibration) measured in micro tesla (uT). + * @param yStrength Magnetic field in y axes (Including soft iron and temperature calibration) measured in micro tesla (uT). + * @param zStrength Magnetic field in z axes (Including soft iron and temperature calibration) measured in micro tesla (uT). * @param xBias Magnetic field in x axes (Including Hard iron calibration) measured in micro tesla (uT). * @param yBias Magnetic field in y axes (Including Hard iron calibration) measured in micro tesla (uT). * @param zBias Magnetic field in z axes (Including Hard iron calibration) measured in micro tesla (uT). - * @param isAvailable Whether the current device has an accelerometer sensor. Defaults to false. - * @param accuracy Accuracy factor of the accelerometer sensor. Defaults to 0. + * @param isAvailable Whether the current device has an uncalibrated magnetic field sensor. Defaults to false. + * @param accuracy Accuracy factor of the uncalibrated magnetic field sensor. Defaults to 0. */ @Immutable -class MagneticFieldUncalibratedSensorState internal constructor( - val xUncalib: Float = 0f, - val yUncalib: Float = 0f, - val zUncalib: Float = 0f, +class UncalibratedMagneticFieldSensorState internal constructor( + val xStrength: Float = 0f, + val yStrength: Float = 0f, + val zStrength: Float = 0f, val xBias: Float = 0f, val yBias: Float = 0f, val zBias: Float = 0f, @@ -32,11 +32,11 @@ class MagneticFieldUncalibratedSensorState internal constructor( ) { override fun equals(other: Any?): Boolean { if (this === other) return true - if (other !is MagneticFieldUncalibratedSensorState) return false + if (other !is UncalibratedMagneticFieldSensorState) return false - if (xUncalib != other.xUncalib) return false - if (yUncalib != other.yUncalib) return false - if (zUncalib != other.zUncalib) return false + if (xStrength != other.xStrength) return false + if (yStrength != other.yStrength) return false + if (zStrength != other.zStrength) return false if (xBias != other.xBias) return false if (yBias != other.yBias) return false if (zBias != other.zBias) return false @@ -47,9 +47,9 @@ class MagneticFieldUncalibratedSensorState internal constructor( } override fun hashCode(): Int { - var result = xUncalib.hashCode() - result = 31 * result + yUncalib.hashCode() - result = 31 * result + zUncalib.hashCode() + var result = xStrength.hashCode() + result = 31 * result + yStrength.hashCode() + result = 31 * result + zStrength.hashCode() result = 31 * result + xBias.hashCode() result = 31 * result + yBias.hashCode() result = 31 * result + zBias.hashCode() @@ -59,40 +59,40 @@ class MagneticFieldUncalibratedSensorState internal constructor( } override fun toString(): String { - return "MagneticFieldUncalibratedSensorState(xUncalib=$xUncalib, yUncalib=$yUncalib, zUncalib=$zUncalib, " + + return "UncalibratedMagneticFieldSensorState(xStrength=$xStrength, yStrength=$yStrength, zStrength=$zStrength, " + "xBias=$xBias, yBias=$yBias, zBias=$zBias, " + "isAvailable=$isAvailable, accuracy=$accuracy)" } } /** - * Creates and [remember]s an instance of [MagneticFieldUncalibratedSensorState]. + * Creates and [remember]s an instance of [UncalibratedMagneticFieldSensorState]. * @param sensorDelay The rate at which the raw sensor data should be received. * Defaults to [SensorDelay.Normal]. * @param onError Callback invoked on every error state. */ @Composable -fun rememberMagneticFieldUncalibratedSensorState( +fun rememberUncalibratedMagneticFieldSensorState( sensorDelay: SensorDelay = SensorDelay.Normal, onError: (throwable: Throwable) -> Unit = {} -): MagneticFieldUncalibratedSensorState { +): UncalibratedMagneticFieldSensorState { val sensorState = rememberSensorState( sensorType = SensorType.MagneticFieldUncalibrated, sensorDelay = sensorDelay, onError = onError ) - val magneticFieldUncalibratedSensorState = - remember { mutableStateOf(MagneticFieldUncalibratedSensorState()) } + val uncalibratedMagneticFieldSensorState = + remember { mutableStateOf(UncalibratedMagneticFieldSensorState()) } LaunchedEffect( key1 = sensorState, block = { val sensorStateValues = sensorState.data if (sensorStateValues.isNotEmpty()) { - magneticFieldUncalibratedSensorState.value = MagneticFieldUncalibratedSensorState( - xUncalib = sensorStateValues[0], - yUncalib = sensorStateValues[1], - zUncalib = sensorStateValues[2], + uncalibratedMagneticFieldSensorState.value = UncalibratedMagneticFieldSensorState( + xStrength = sensorStateValues[0], + yStrength = sensorStateValues[1], + zStrength = sensorStateValues[2], xBias = sensorStateValues[3], yBias = sensorStateValues[4], zBias = sensorStateValues[5], @@ -103,5 +103,5 @@ fun rememberMagneticFieldUncalibratedSensorState( } ) - return magneticFieldUncalibratedSensorState.value + return uncalibratedMagneticFieldSensorState.value } From 078f1c957fc56b0785f1c3d73e4f05918cde7922 Mon Sep 17 00:00:00 2001 From: Swapnil Musale Date: Thu, 13 Apr 2023 23:00:34 +0530 Subject: [PATCH 12/17] Changes as per PR Suggestions --- ...atedSensorState.kt => UncalibratedMagneticFieldSensorState.kt} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename composesensors/src/main/java/com/mutualmobile/composesensors/{MagneticFieldUncalibratedSensorState.kt => UncalibratedMagneticFieldSensorState.kt} (100%) diff --git a/composesensors/src/main/java/com/mutualmobile/composesensors/MagneticFieldUncalibratedSensorState.kt b/composesensors/src/main/java/com/mutualmobile/composesensors/UncalibratedMagneticFieldSensorState.kt similarity index 100% rename from composesensors/src/main/java/com/mutualmobile/composesensors/MagneticFieldUncalibratedSensorState.kt rename to composesensors/src/main/java/com/mutualmobile/composesensors/UncalibratedMagneticFieldSensorState.kt From 0387e5ecef5681627417bf6724176c9b5ca07dd5 Mon Sep 17 00:00:00 2001 From: Swapnil Musale Date: Fri, 14 Apr 2023 10:29:57 +0530 Subject: [PATCH 13/17] Changes as per PR Suggestions --- .../UncalibratedMagneticFieldSensorState.kt | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/composesensors/src/main/java/com/mutualmobile/composesensors/UncalibratedMagneticFieldSensorState.kt b/composesensors/src/main/java/com/mutualmobile/composesensors/UncalibratedMagneticFieldSensorState.kt index 0bd1817..81f56c4 100644 --- a/composesensors/src/main/java/com/mutualmobile/composesensors/UncalibratedMagneticFieldSensorState.kt +++ b/composesensors/src/main/java/com/mutualmobile/composesensors/UncalibratedMagneticFieldSensorState.kt @@ -7,15 +7,15 @@ import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.remember /** - * An Uncalibrated Magnetic Field sensor is similar to [SensorType.MagneticField] but the hard iron calibration is reported separately instead of being included in the measurement. - * Factory calibration and temperature compensation will still be applied to the "uncalibrated" measurement. - * Assumptions are that the magnetic field is due to the Earth's poles being avoided. - * @param xStrength Magnetic field in x axes (Including Soft Iron and temperature calibration) measured in micro tesla (uT). - * @param yStrength Magnetic field in y axes (Including soft iron and temperature calibration) measured in micro tesla (uT). - * @param zStrength Magnetic field in z axes (Including soft iron and temperature calibration) measured in micro tesla (uT). - * @param xBias Magnetic field in x axes (Including Hard iron calibration) measured in micro tesla (uT). - * @param yBias Magnetic field in y axes (Including Hard iron calibration) measured in micro tesla (uT). - * @param zBias Magnetic field in z axes (Including Hard iron calibration) measured in micro tesla (uT). + * An Uncalibrated Magnetic Field sensor is similar to [SensorType.MagneticField] but the hard iron calibration is reported separately instead of being included in the measurement. Factory calibration and temperature compensation will still be applied to the "uncalibrated" measurement. Assumptions are that the magnetic field is due to the Earth's poles being avoided. + * Hard iron - These distortions arise due to the magnetized iron, steel or permanent magnets on the device. + * Soft iron - These distortions arise due to the interaction with the earth's magnetic field. + * @param xStrength The measured magnetic field in X-axis. Soft iron and temperature calibrations are applied. But the hard iron calibration is not applied. The value is calculated in micro-Tesla (uT). + * @param yStrength The measured magnetic field in Y-axis. Soft iron and temperature calibrations are applied. But the hard iron calibration is not applied. The value is calculated in micro-Tesla (uT). + * @param zStrength The measured magnetic field in Z-axis. Soft iron and temperature calibrations are applied. But the hard iron calibration is not applied. The value is calculated in micro-Tesla (uT). + * @param xBias The iron bias estimated in X-axis. It is a component of the estimated hard iron calibration. The value is calculated in micro-Tesla (uT). + * @param yBias The iron bias estimated in Y-axis. It is a component of the estimated hard iron calibration. The value is calculated in micro-Tesla (uT). + * @param zBias The iron bias estimated in Z-axis. It is a component of the estimated hard iron calibration. The value is calculated in micro-Tesla (uT). * @param isAvailable Whether the current device has an uncalibrated magnetic field sensor. Defaults to false. * @param accuracy Accuracy factor of the uncalibrated magnetic field sensor. Defaults to 0. */ From dd22b699d9d8f8ff5413d14d9afd17dd57544aaf Mon Sep 17 00:00:00 2001 From: Chandra-Mauli-Sharma Date: Thu, 20 Apr 2023 13:26:38 +0530 Subject: [PATCH 14/17] Changes made for Support for Gyroscope Limited Axes sensor #43 --- README.md | 2 +- .../GyroscopeLimitedAxesSensorState.kt | 81 -------------- .../LimitedAxesGyroscopeSensorState.kt | 105 ++++++++++++++++++ 3 files changed, 106 insertions(+), 82 deletions(-) delete mode 100644 composesensors/src/main/java/com/mutualmobile/composesensors/GyroscopeLimitedAxesSensorState.kt create mode 100644 composesensors/src/main/java/com/mutualmobile/composesensors/LimitedAxesGyroscopeSensorState.kt diff --git a/README.md b/README.md index ae12a53..e005e54 100644 --- a/README.md +++ b/README.md @@ -104,7 +104,7 @@ Accelerometer (Uncalibrated) | ⚠️ | WIP Hinge Angle | ⚠️ | WIP Head Tracker | — | N/A Accelerometer Limited Axes | — | N/A -Gyroscope Limited Axes | ⚠️ | WIP +Gyroscope Limited Axes | ✅️️ | rememberLimitedAxesGyroscopeSensorState() Accelerometer Limited Axes (Uncalibrated) | — | N/A Gyroscope Limited Axes (Uncalibrated) | — | N/A Heading | ⚠️ | WIP diff --git a/composesensors/src/main/java/com/mutualmobile/composesensors/GyroscopeLimitedAxesSensorState.kt b/composesensors/src/main/java/com/mutualmobile/composesensors/GyroscopeLimitedAxesSensorState.kt deleted file mode 100644 index f43b944..0000000 --- a/composesensors/src/main/java/com/mutualmobile/composesensors/GyroscopeLimitedAxesSensorState.kt +++ /dev/null @@ -1,81 +0,0 @@ -package com.mutualmobile.composesensors - -import androidx.compose.runtime.* - -@Immutable -class GyroscopeLimitedAxesSensorState internal constructor( - val xAxisSupported: Float = 0f, - val yAxisSupported: Float = 0f, - val zAxisSupported: Float = 0f, - val xRotation: Float = 0f, - val yRotation: Float = 0f, - val zRotation: Float = 0f, - val isAvailable: Boolean = false, - val accuracy: Int = 0, -) { - - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (javaClass != other?.javaClass) return false - - other as GyroscopeLimitedAxesSensorState - - if (xAxisSupported != other.xAxisSupported) return false - if (yAxisSupported != other.yAxisSupported) return false - if (zAxisSupported != other.zAxisSupported) return false - if (xRotation != other.xRotation) return false - if (yRotation != other.yRotation) return false - if (zRotation != other.zRotation) return false - if (isAvailable != other.isAvailable) return false - return accuracy == other.accuracy - } - - override fun hashCode(): Int { - var result = xAxisSupported.hashCode() - result = 31 * result + yAxisSupported.hashCode() - result = 31 * result + zAxisSupported.hashCode() - result = 31 * result + xRotation.hashCode() - result = 31 * result + yRotation.hashCode() - result = 31 * result + zRotation.hashCode() - result = 31 * result + isAvailable.hashCode() - result = 31 * result + accuracy - return result - } - - override fun toString(): String { - return "GyroscopeLimitedAxesSensorState(xAxisSupported=$xAxisSupported, yAxisSupported=$yAxisSupported, zAxisSupported=$zAxisSupported, xRotation=$xRotation, yRotation=$yRotation, zRotation=$zRotation, isAvailable=$isAvailable, accuracy=$accuracy)" - } - -} - -@Composable -fun rememberGyroscopeLimitedAxesSensorState( - sensorDelay: SensorDelay = SensorDelay.Normal, - onError: (throwable: Throwable) -> Unit = {}, -): GyroscopeLimitedAxesSensorState { - val sensorState = rememberSensorState( - sensorType = SensorType.GyroscopeLimitedAxes, - sensorDelay = sensorDelay, - onError = onError - ) - - val gyroscopeLimitedAxesSensor = remember { mutableStateOf(GyroscopeLimitedAxesSensorState()) } - - LaunchedEffect(key1 = sensorState, block = { - val sensorStateValues = sensorState.data - if (sensorStateValues.isNotEmpty()) { - gyroscopeLimitedAxesSensor.value = GyroscopeLimitedAxesSensorState( - xAxisSupported = sensorStateValues[0], - yAxisSupported = sensorStateValues[1], - zAxisSupported = sensorStateValues[2], - xRotation = sensorStateValues[3], - yRotation = sensorStateValues[4], - zRotation = sensorStateValues[5], - isAvailable = sensorState.isAvailable, - accuracy = sensorState.accuracy - ) - } - }) - - return gyroscopeLimitedAxesSensor.value -} \ No newline at end of file diff --git a/composesensors/src/main/java/com/mutualmobile/composesensors/LimitedAxesGyroscopeSensorState.kt b/composesensors/src/main/java/com/mutualmobile/composesensors/LimitedAxesGyroscopeSensorState.kt new file mode 100644 index 0000000..4d5a65e --- /dev/null +++ b/composesensors/src/main/java/com/mutualmobile/composesensors/LimitedAxesGyroscopeSensorState.kt @@ -0,0 +1,105 @@ +package com.mutualmobile.composesensors + +import androidx.compose.runtime.Composable +import androidx.compose.runtime.Immutable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember + +/** + * Equivalent to Gyroscope Sensor but supporting cases where one or two axes are not supported. + * @param xRotation Angular speed around the x-axis (if supported). Defaults to 0f. + * @param yRotation Angular speed around the y-axis (if supported). Defaults to 0f. + * @param zRotation Angular speed around the z-axis (if supported). Defaults to 0f. + * @param xAxisSupported Angular speed supported for x-axis. Defaults to 0f. + * @param yAxisSupported Angular speed supported for y-axis. Defaults to 0f. + * @param zAxisSupported Angular speed supported for z-axis. Defaults to 0f. + * @param isAvailable Whether the current device has a gyroscope sensor. Defaults to false. + * @param accuracy Accuracy factor of the gyroscope sensor. Defaults to 0. + */ +@Immutable +class LimitedAxesGyroscopeSensorState internal constructor( + val xRotation: Float = 0f, + val yRotation: Float = 0f, + val zRotation: Float = 0f, + val xAxisSupported: Float = 0f, + val yAxisSupported: Float = 0f, + val zAxisSupported: Float = 0f, + val isAvailable: Boolean = false, + val accuracy: Int = 0, +) { + + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + + other as LimitedAxesGyroscopeSensorState + + if (xRotation != other.xRotation) return false + if (yRotation != other.yRotation) return false + if (zRotation != other.zRotation) return false + if (xAxisSupported != other.xAxisSupported) return false + if (yAxisSupported != other.yAxisSupported) return false + if (zAxisSupported != other.zAxisSupported) return false + if (isAvailable != other.isAvailable) return false + if (accuracy != other.accuracy) return false + + return true + } + + override fun hashCode(): Int { + var result = xRotation.hashCode() + result = 31 * result + yRotation.hashCode() + result = 31 * result + zRotation.hashCode() + result = 31 * result + xAxisSupported.hashCode() + result = 31 * result + yAxisSupported.hashCode() + result = 31 * result + zAxisSupported.hashCode() + result = 31 * result + isAvailable.hashCode() + result = 31 * result + accuracy + return result + } + + override fun toString(): String { + return "LimitedAxesGyroscopeSensorState(xRotation=$xRotation, yRotation=$yRotation, zRotation=$zRotation, xAxisSupported=$xAxisSupported, yAxisSupported=$yAxisSupported, zAxisSupported=$zAxisSupported, isAvailable=$isAvailable, accuracy=$accuracy)" + } + +} + +/** + * Creates and [remember]s an instance of [LimitedAxesGyroscopeSensorState]. + * @param sensorDelay The rate at which the raw sensor data should be received. + * Defaults to [SensorDelay.Normal]. + * @param onError Callback invoked on every error state. + */ + +@Composable +fun rememberLimitedAxesGyroscopeSensorState( + sensorDelay: SensorDelay = SensorDelay.Normal, + onError: (throwable: Throwable) -> Unit = {}, +): LimitedAxesGyroscopeSensorState { + val sensorState = rememberSensorState( + sensorType = SensorType.GyroscopeLimitedAxes, + sensorDelay = sensorDelay, + onError = onError + ) + + val gyroscopeLimitedAxesSensor = remember { mutableStateOf(LimitedAxesGyroscopeSensorState()) } + + LaunchedEffect(key1 = sensorState, block = { + val sensorStateValues = sensorState.data + if (sensorStateValues.isNotEmpty()) { + gyroscopeLimitedAxesSensor.value = LimitedAxesGyroscopeSensorState( + xRotation = sensorStateValues[0], + yRotation = sensorStateValues[1], + zRotation = sensorStateValues[2], + xAxisSupported = sensorStateValues[3], + yAxisSupported = sensorStateValues[4], + zAxisSupported = sensorStateValues[5], + isAvailable = sensorState.isAvailable, + accuracy = sensorState.accuracy + ) + } + }) + + return gyroscopeLimitedAxesSensor.value +} \ No newline at end of file From d2d44cb71141ce083419b3fdc137d2c634926752 Mon Sep 17 00:00:00 2001 From: Chandra-Mauli-Sharma Date: Thu, 20 Apr 2023 18:21:08 +0530 Subject: [PATCH 15/17] kLint Fixes --- .../composesensors/LimitedAxesGyroscopeSensorState.kt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/composesensors/src/main/java/com/mutualmobile/composesensors/LimitedAxesGyroscopeSensorState.kt b/composesensors/src/main/java/com/mutualmobile/composesensors/LimitedAxesGyroscopeSensorState.kt index 4d5a65e..059dd8f 100644 --- a/composesensors/src/main/java/com/mutualmobile/composesensors/LimitedAxesGyroscopeSensorState.kt +++ b/composesensors/src/main/java/com/mutualmobile/composesensors/LimitedAxesGyroscopeSensorState.kt @@ -26,7 +26,7 @@ class LimitedAxesGyroscopeSensorState internal constructor( val yAxisSupported: Float = 0f, val zAxisSupported: Float = 0f, val isAvailable: Boolean = false, - val accuracy: Int = 0, + val accuracy: Int = 0 ) { override fun equals(other: Any?): Boolean { @@ -62,7 +62,6 @@ class LimitedAxesGyroscopeSensorState internal constructor( override fun toString(): String { return "LimitedAxesGyroscopeSensorState(xRotation=$xRotation, yRotation=$yRotation, zRotation=$zRotation, xAxisSupported=$xAxisSupported, yAxisSupported=$yAxisSupported, zAxisSupported=$zAxisSupported, isAvailable=$isAvailable, accuracy=$accuracy)" } - } /** @@ -75,7 +74,7 @@ class LimitedAxesGyroscopeSensorState internal constructor( @Composable fun rememberLimitedAxesGyroscopeSensorState( sensorDelay: SensorDelay = SensorDelay.Normal, - onError: (throwable: Throwable) -> Unit = {}, + onError: (throwable: Throwable) -> Unit = {} ): LimitedAxesGyroscopeSensorState { val sensorState = rememberSensorState( sensorType = SensorType.GyroscopeLimitedAxes, @@ -102,4 +101,4 @@ fun rememberLimitedAxesGyroscopeSensorState( }) return gyroscopeLimitedAxesSensor.value -} \ No newline at end of file +} From 6c9f46bb4896d96084c76b737ecf67769c808656 Mon Sep 17 00:00:00 2001 From: Shubham Singh Date: Thu, 20 Apr 2023 19:16:02 +0530 Subject: [PATCH 16/17] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a3df227..c90b30b 100644 --- a/README.md +++ b/README.md @@ -96,16 +96,16 @@ Step Counter | ✅️ | rememberStepCounterSensorState() Geomagnetic Rotation Vector | ✅️️ | rememberGeomagneticRotationVectorSensorState() Heart Rate | ✅️ | rememberHeartRateSensorState() Pose6DOF | — | N/A -Stationary Detect | — | N/A -Motion Detect | — | N/A +Stationary Detect | ⚠️ | WIP +Motion Detect | ⚠️ | WIP Heart Beat | — | N/A Low Latency Off-Body Detect | — | N/A Accelerometer (Uncalibrated) | ⚠️ | WIP Hinge Angle | ✅️ | rememberHingeAngleSensorState() Head Tracker | — | N/A -Accelerometer Limited Axes | — | N/A +Accelerometer Limited Axes | ⚠️ | WIP Gyroscope Limited Axes | ✅️️ | rememberLimitedAxesGyroscopeSensorState() -Accelerometer Limited Axes (Uncalibrated) | — | N/A +Accelerometer Limited Axes (Uncalibrated) | ⚠️ | WIP Gyroscope Limited Axes (Uncalibrated) | — | N/A Heading | ⚠️ | WIP All | — | N/A From 56c0c8f94335558eef59cd86e185a99525c082f2 Mon Sep 17 00:00:00 2001 From: Shubham Singh Date: Thu, 20 Apr 2023 19:20:24 +0530 Subject: [PATCH 17/17] Fix toString function's indentation of LimitedAxesGyroscopeSensorState --- .../composesensors/LimitedAxesGyroscopeSensorState.kt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/composesensors/src/main/java/com/mutualmobile/composesensors/LimitedAxesGyroscopeSensorState.kt b/composesensors/src/main/java/com/mutualmobile/composesensors/LimitedAxesGyroscopeSensorState.kt index 059dd8f..edc2e6c 100644 --- a/composesensors/src/main/java/com/mutualmobile/composesensors/LimitedAxesGyroscopeSensorState.kt +++ b/composesensors/src/main/java/com/mutualmobile/composesensors/LimitedAxesGyroscopeSensorState.kt @@ -60,7 +60,10 @@ class LimitedAxesGyroscopeSensorState internal constructor( } override fun toString(): String { - return "LimitedAxesGyroscopeSensorState(xRotation=$xRotation, yRotation=$yRotation, zRotation=$zRotation, xAxisSupported=$xAxisSupported, yAxisSupported=$yAxisSupported, zAxisSupported=$zAxisSupported, isAvailable=$isAvailable, accuracy=$accuracy)" + return "LimitedAxesGyroscopeSensorState(xRotation=$xRotation, yRotation=$yRotation, " + + "zRotation=$zRotation, xAxisSupported=$xAxisSupported, " + + "yAxisSupported=$yAxisSupported, zAxisSupported=$zAxisSupported, " + + "isAvailable=$isAvailable, accuracy=$accuracy)" } }