diff --git a/docs/pages/versions/unversioned/sdk/devicemotion.md b/docs/pages/versions/unversioned/sdk/devicemotion.md
index 60a2265bf7e7f..35b23592cd77e 100644
--- a/docs/pages/versions/unversioned/sdk/devicemotion.md
+++ b/docs/pages/versions/unversioned/sdk/devicemotion.md
@@ -47,13 +47,19 @@ Subscribe for updates to DeviceMotion.
DeviceMotion update is available. When invoked, the listener is
provided a single argument that is an object containing following fields:
+ - **interval (_number_)** -- Interval at which data is obtained from the native platform. Expressed in **milliseconds**.
+
- **acceleration (_object_)** -- Device acceleration on the three axis as an object with x, y, z keys. Expressed in m/s2.
- **accelerationIncludingGravity (_object_)** -- Device acceleration with the effect of gravity on the three axis as an object with x, y, z keys. Expressed in m/s2.
- **rotation (_object_)** -- Device's orientation in space as an object with alpha, beta, gamma keys where alpha is for rotation around Z axis, beta for X axis rotation and gamma for Y axis rotation.
- - **rotationRate (_object_)** -- Rotation rates of the device around each of its axes as an object with alpha, beta, gamma keys where alpha is around Z axis, beta for X axis and gamma for Y axis.
+ - **rotationRate (_object_)** -- Device's rate of rotation in space expressed in degrees per second (deg/s).
+
+ - **alpha (_number_)**: X axis rotation.
+ - **beta (_number_)**: Y axis rotation.
+ - **gamma (_number_)**: Z axis rotation.
- **orientation (_number_)** -- Device orientation based on screen rotation. Value is on of `0` (portrait), `90` (right landscape), `180` (upside down), `-90` (left landscape).
diff --git a/packages/expo-sensors/CHANGELOG.md b/packages/expo-sensors/CHANGELOG.md
index 6a294c6841ff4..8d9a7a9ce3046 100644
--- a/packages/expo-sensors/CHANGELOG.md
+++ b/packages/expo-sensors/CHANGELOG.md
@@ -4,6 +4,13 @@
### 🛠 Breaking changes
+- `DeviceMotion.addListener` emits events with `rotationRate` in degrees instead of radians on all platforms. ([#7876](https://github.com/expo/expo/pull/7876) by [@evanbacon](https://github.com/evanbacon))
+- `DeviceMotion.addListener` emits events with `rotationRate` in the form of alpha = x, beta = y, gamma = z on all platforms. ([#7876](https://github.com/expo/expo/pull/7876) by [@evanbacon](https://github.com/evanbacon))
+
### 🎉 New features
+- `DeviceMotion.addListener` emits events with `interval` property. ([#7876](https://github.com/expo/expo/pull/7876) by [@evanbacon](https://github.com/evanbacon))
+
### 🐛 Bug fixes
+
+- All sensors use more precise gravity `9.80665` instead of `9.8`. ([#7876](https://github.com/expo/expo/pull/7876) by [@evanbacon](https://github.com/evanbacon))
diff --git a/packages/expo-sensors/android/src/main/java/expo/modules/sensors/modules/DeviceMotionModule.java b/packages/expo-sensors/android/src/main/java/expo/modules/sensors/modules/DeviceMotionModule.java
index 724180dbaf69a..ab0825d8bf912 100644
--- a/packages/expo-sensors/android/src/main/java/expo/modules/sensors/modules/DeviceMotionModule.java
+++ b/packages/expo-sensors/android/src/main/java/expo/modules/sensors/modules/DeviceMotionModule.java
@@ -16,6 +16,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.lang.Math;
import org.unimodules.core.ExportedModule;
import org.unimodules.core.ModuleRegistry;
@@ -33,7 +34,7 @@
public class DeviceMotionModule extends ExportedModule implements SensorEventListener2 {
private long mLastUpdate = 0;
- private int mUpdateInterval = 100;
+ private float mUpdateInterval = 1.0f / 60.0f;
private float[] mRotationMatrix = new float[9];
private float[] mRotationResult = new float[3];
@@ -61,7 +62,8 @@ public String getName() {
public Map getConstants() {
return Collections.unmodifiableMap(new HashMap() {
{
- put("Gravity", 9.81);
+ // Gravity on the planet this module supports (currently just Earth) represented as m/s^2.
+ put("Gravity", 9.80665);
}
});
}
@@ -231,13 +233,13 @@ private Bundle eventsToMap() {
Bundle accelerationIncludingGravity = new Bundle();
Bundle rotation = new Bundle();
Bundle rotationRate = new Bundle();
-
+ double interval = 0;
if (mAccelerationEvent != null) {
acceleration.putDouble("x", mAccelerationEvent.values[0]);
acceleration.putDouble("y", mAccelerationEvent.values[1]);
acceleration.putDouble("z", mAccelerationEvent.values[2]);
map.putBundle("acceleration", acceleration);
-
+ interval = mAccelerationEvent.timestamp;
}
if (mAccelerationIncludingGravityEvent != null && mGravityEvent != null) {
@@ -245,13 +247,15 @@ private Bundle eventsToMap() {
accelerationIncludingGravity.putDouble("y", mAccelerationIncludingGravityEvent.values[1] - 2 * mGravityEvent.values[1]);
accelerationIncludingGravity.putDouble("z", mAccelerationIncludingGravityEvent.values[2] - 2 * mGravityEvent.values[2]);
map.putBundle("accelerationIncludingGravity", accelerationIncludingGravity);
+ interval = mAccelerationIncludingGravityEvent.timestamp;
}
if (mRotationRateEvent != null) {
- rotationRate.putDouble("alpha", mRotationRateEvent.values[2]);
- rotationRate.putDouble("beta", mRotationRateEvent.values[0]);
- rotationRate.putDouble("gamma", mRotationRateEvent.values[1]);
+ rotationRate.putDouble("alpha", Math.toDegrees(mRotationRateEvent.values[0]));
+ rotationRate.putDouble("beta", Math.toDegrees(mRotationRateEvent.values[1]));
+ rotationRate.putDouble("gamma", Math.toDegrees(mRotationRateEvent.values[2]));
map.putBundle("rotationRate", rotationRate);
+ interval = mRotationRateEvent.timestamp;
}
if (mRotationEvent != null) {
@@ -261,8 +265,10 @@ private Bundle eventsToMap() {
rotation.putDouble("beta", -mRotationResult[1]);
rotation.putDouble("gamma", mRotationResult[2]);
map.putBundle("rotation", rotation);
+ interval = mRotationEvent.timestamp;
}
+ map.putDouble("interval", interval);
map.putInt("orientation", getOrientation());
return map;
diff --git a/packages/expo-sensors/build/DeviceMotion.d.ts b/packages/expo-sensors/build/DeviceMotion.d.ts
index 604450c9e41b5..51b4627b35f4e 100644
--- a/packages/expo-sensors/build/DeviceMotion.d.ts
+++ b/packages/expo-sensors/build/DeviceMotion.d.ts
@@ -1,6 +1,6 @@
import DeviceSensor from './DeviceSensor';
export interface DeviceMotionMeasurement {
- acceleration: {
+ acceleration: null | {
x: number;
y: number;
z: number;
@@ -15,11 +15,27 @@ export interface DeviceMotionMeasurement {
beta: number;
gamma: number;
};
- rotationRate: {
+ /**
+ * Device's rate of rotation in space expressed in degrees per second (deg/s).
+ */
+ rotationRate: null | {
+ /**
+ * x axis rotation.
+ */
alpha: number;
+ /**
+ * y axis rotation.
+ */
beta: number;
+ /**
+ * z axis rotation.
+ */
gamma: number;
};
+ /**
+ * Interval at which data is obtained from the native platform. Expressed in **milliseconds**.
+ */
+ interval: number;
orientation: number;
}
declare class DeviceMotionSensor extends DeviceSensor {
diff --git a/packages/expo-sensors/build/DeviceMotion.js.map b/packages/expo-sensors/build/DeviceMotion.js.map
index bb030b72a6298..e6c7b2d5cf50b 100644
--- a/packages/expo-sensors/build/DeviceMotion.js.map
+++ b/packages/expo-sensors/build/DeviceMotion.js.map
@@ -1 +1 @@
-{"version":3,"file":"DeviceMotion.js","sourceRoot":"","sources":["../src/DeviceMotion.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AA0B1D,MAAM,kBAAmB,SAAQ,YAAqC;IAAtE;;QACE,YAAO,GAAG,oBAAoB,CAAC,OAAO,CAAC;IACzC,CAAC;CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,oBAAoB,CAAC,OAAO,CAAC;AAEpD,eAAe,IAAI,kBAAkB,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["import DeviceSensor from './DeviceSensor';\nimport ExponentDeviceMotion from './ExponentDeviceMotion';\n\nexport interface DeviceMotionMeasurement {\n acceleration: {\n x: number;\n y: number;\n z: number;\n };\n accelerationIncludingGravity: {\n x: number;\n y: number;\n z: number;\n };\n rotation: {\n alpha: number;\n beta: number;\n gamma: number;\n };\n rotationRate: {\n alpha: number;\n beta: number;\n gamma: number;\n };\n orientation: number;\n}\n\nclass DeviceMotionSensor extends DeviceSensor {\n Gravity = ExponentDeviceMotion.Gravity;\n}\n\nexport const Gravity = ExponentDeviceMotion.Gravity;\n\nexport default new DeviceMotionSensor(ExponentDeviceMotion, 'deviceMotionDidUpdate');\n"]}
\ No newline at end of file
+{"version":3,"file":"DeviceMotion.js","sourceRoot":"","sources":["../src/DeviceMotion.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,gBAAgB,CAAC;AAC1C,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AA0C1D,MAAM,kBAAmB,SAAQ,YAAqC;IAAtE;;QACE,YAAO,GAAG,oBAAoB,CAAC,OAAO,CAAC;IACzC,CAAC;CAAA;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,oBAAoB,CAAC,OAAO,CAAC;AAEpD,eAAe,IAAI,kBAAkB,CAAC,oBAAoB,EAAE,uBAAuB,CAAC,CAAC","sourcesContent":["import DeviceSensor from './DeviceSensor';\nimport ExponentDeviceMotion from './ExponentDeviceMotion';\n\nexport interface DeviceMotionMeasurement {\n acceleration: null | {\n x: number;\n y: number;\n z: number;\n };\n accelerationIncludingGravity: {\n x: number;\n y: number;\n z: number;\n };\n rotation: {\n alpha: number;\n beta: number;\n gamma: number;\n };\n /**\n * Device's rate of rotation in space expressed in degrees per second (deg/s).\n */\n rotationRate: null | {\n /**\n * x axis rotation.\n */\n alpha: number;\n /**\n * y axis rotation.\n */\n beta: number;\n /**\n * z axis rotation.\n */\n gamma: number;\n };\n /**\n * Interval at which data is obtained from the native platform. Expressed in **milliseconds**.\n */\n interval: number;\n orientation: number;\n}\n\nclass DeviceMotionSensor extends DeviceSensor {\n Gravity = ExponentDeviceMotion.Gravity;\n}\n\nexport const Gravity = ExponentDeviceMotion.Gravity;\n\nexport default new DeviceMotionSensor(ExponentDeviceMotion, 'deviceMotionDidUpdate');\n"]}
\ No newline at end of file
diff --git a/packages/expo-sensors/build/ExponentDeviceMotion.web.d.ts b/packages/expo-sensors/build/ExponentDeviceMotion.web.d.ts
index e7f2e3e07ad64..7b0c681615951 100644
--- a/packages/expo-sensors/build/ExponentDeviceMotion.web.d.ts
+++ b/packages/expo-sensors/build/ExponentDeviceMotion.web.d.ts
@@ -1,5 +1,8 @@
declare const _default: {
readonly name: string;
+ /**
+ * Gravity on the planet this module supports (currently just Earth) represented as m/s^2.
+ */
readonly Gravity: number;
isAvailableAsync(): Promise;
_handleMotion(motion: any): void;
diff --git a/packages/expo-sensors/build/ExponentDeviceMotion.web.js b/packages/expo-sensors/build/ExponentDeviceMotion.web.js
index c29645f941e68..252c556563e82 100644
--- a/packages/expo-sensors/build/ExponentDeviceMotion.web.js
+++ b/packages/expo-sensors/build/ExponentDeviceMotion.web.js
@@ -5,8 +5,11 @@ export default {
get name() {
return 'ExponentDeviceMotion';
},
+ /**
+ * Gravity on the planet this module supports (currently just Earth) represented as m/s^2.
+ */
get Gravity() {
- return 9.81;
+ return 9.80665;
},
async isAvailableAsync() {
if (typeof DeviceMotionEvent === 'undefined') {
diff --git a/packages/expo-sensors/build/ExponentDeviceMotion.web.js.map b/packages/expo-sensors/build/ExponentDeviceMotion.web.js.map
index ee203aab42016..62d146a9da8fd 100644
--- a/packages/expo-sensors/build/ExponentDeviceMotion.web.js.map
+++ b/packages/expo-sensors/build/ExponentDeviceMotion.web.js.map
@@ -1 +1 @@
-{"version":3,"file":"ExponentDeviceMotion.web.js","sourceRoot":"","sources":["../src/ExponentDeviceMotion.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAExE,MAAM,SAAS,GAAG,cAAc,CAAC;AAEjC,eAAe;IACb,IAAI,IAAI;QACN,OAAO,sBAAsB,CAAC;IAChC,CAAC;IACD,IAAI,OAAO;QACT,OAAO,IAAI,CAAC;IACd,CAAC;IACD,KAAK,CAAC,gBAAgB;QACpB,IAAI,OAAO,iBAAiB,KAAK,WAAW,EAAE;YAC5C,OAAO,KAAK,CAAC;SACd;QACD,OAAO,MAAM,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;IACD,aAAa,CAAC,MAAM;QAClB,2CAA2C;QAC3C,wBAAwB,CAAC,IAAI,CAAC,uBAAuB,EAAE;YACrD,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,4BAA4B,EAAE,MAAM,CAAC,4BAA4B;YACjE,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC,CAAC,CAAC;IACL,CAAC;IACD,cAAc;QACZ,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzD,CAAC;IACD,aAAa;QACX,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAC5D,CAAC;CACF,CAAC","sourcesContent":["import { SyntheticPlatformEmitter } from '@unimodules/core';\n\nimport { isSensorEnabledAsync } from './utils/isSensorEnabledAsync.web';\n\nconst eventName = 'devicemotion';\n\nexport default {\n get name(): string {\n return 'ExponentDeviceMotion';\n },\n get Gravity(): number {\n return 9.81;\n },\n async isAvailableAsync(): Promise {\n if (typeof DeviceMotionEvent === 'undefined') {\n return false;\n }\n return await isSensorEnabledAsync(eventName);\n },\n _handleMotion(motion) {\n // TODO: Bacon: Can rotation be calculated?\n SyntheticPlatformEmitter.emit('deviceMotionDidUpdate', {\n acceleration: motion.acceleration,\n accelerationIncludingGravity: motion.accelerationIncludingGravity,\n interval: motion.interval,\n rotationRate: motion.rotationRate,\n orientation: window.orientation,\n });\n },\n startObserving() {\n window.addEventListener(eventName, this._handleMotion);\n },\n stopObserving() {\n window.removeEventListener(eventName, this._handleMotion);\n },\n};\n"]}
\ No newline at end of file
+{"version":3,"file":"ExponentDeviceMotion.web.js","sourceRoot":"","sources":["../src/ExponentDeviceMotion.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAE5D,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AAExE,MAAM,SAAS,GAAG,cAAc,CAAC;AAEjC,eAAe;IACb,IAAI,IAAI;QACN,OAAO,sBAAsB,CAAC;IAChC,CAAC;IACD;;OAEG;IACH,IAAI,OAAO;QACT,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,KAAK,CAAC,gBAAgB;QACpB,IAAI,OAAO,iBAAiB,KAAK,WAAW,EAAE;YAC5C,OAAO,KAAK,CAAC;SACd;QACD,OAAO,MAAM,oBAAoB,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;IACD,aAAa,CAAC,MAAM;QAClB,2CAA2C;QAC3C,wBAAwB,CAAC,IAAI,CAAC,uBAAuB,EAAE;YACrD,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,4BAA4B,EAAE,MAAM,CAAC,4BAA4B;YACjE,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC,CAAC,CAAC;IACL,CAAC;IACD,cAAc;QACZ,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IACzD,CAAC;IACD,aAAa;QACX,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;IAC5D,CAAC;CACF,CAAC","sourcesContent":["import { SyntheticPlatformEmitter } from '@unimodules/core';\n\nimport { isSensorEnabledAsync } from './utils/isSensorEnabledAsync.web';\n\nconst eventName = 'devicemotion';\n\nexport default {\n get name(): string {\n return 'ExponentDeviceMotion';\n },\n /**\n * Gravity on the planet this module supports (currently just Earth) represented as m/s^2.\n */\n get Gravity(): number {\n return 9.80665;\n },\n async isAvailableAsync(): Promise {\n if (typeof DeviceMotionEvent === 'undefined') {\n return false;\n }\n return await isSensorEnabledAsync(eventName);\n },\n _handleMotion(motion) {\n // TODO: Bacon: Can rotation be calculated?\n SyntheticPlatformEmitter.emit('deviceMotionDidUpdate', {\n acceleration: motion.acceleration,\n accelerationIncludingGravity: motion.accelerationIncludingGravity,\n interval: motion.interval,\n rotationRate: motion.rotationRate,\n orientation: window.orientation,\n });\n },\n startObserving() {\n window.addEventListener(eventName, this._handleMotion);\n },\n stopObserving() {\n window.removeEventListener(eventName, this._handleMotion);\n },\n};\n"]}
\ No newline at end of file
diff --git a/packages/expo-sensors/ios/EXSensors/EXSensorsManager.h b/packages/expo-sensors/ios/EXSensors/EXSensorsManager.h
index 12c92d1ffcf36..191175cf56552 100644
--- a/packages/expo-sensors/ios/EXSensors/EXSensorsManager.h
+++ b/packages/expo-sensors/ios/EXSensors/EXSensorsManager.h
@@ -8,7 +8,8 @@
#import
#import
-static const float EXGravity = 9.81;
+// Gravity on the planet this module supports (currently just Earth) represented as m/s^2.
+static const float EXGravity = 9.80665;
@interface EXSensorsManager : NSObject
diff --git a/packages/expo-sensors/ios/EXSensors/EXSensorsManager.m b/packages/expo-sensors/ios/EXSensors/EXSensorsManager.m
index 32022c1957a55..706e7057794c6 100644
--- a/packages/expo-sensors/ios/EXSensors/EXSensorsManager.m
+++ b/packages/expo-sensors/ios/EXSensors/EXSensorsManager.m
@@ -291,9 +291,16 @@ - (float)getGravity
return EXGravity;
}
+- (float)radiansToDegrees:(double)radians
+{
+ return radians * 180 / M_PI;
+}
+
+// Match https://www.w3.org/TR/orientation-event/
- (void)activateDeviceMotionUpdates
{
- [[self manager] setDeviceMotionUpdateInterval:0.1f];
+ float interval = 1.0f / 60.0f;
+ [[self manager] setDeviceMotionUpdateInterval:interval];
__weak EXSensorsManager *weakSelf = self;
[[self manager] startDeviceMotionUpdatesUsingReferenceFrame:CMAttitudeReferenceFrameXArbitraryCorrectedZVertical toQueue:[NSOperationQueue mainQueue] withHandler:^(CMDeviceMotion *data, NSError *error) {
__strong EXSensorsManager *strongSelf = weakSelf;
@@ -320,12 +327,8 @@ - (void)activateDeviceMotionUpdates
break;
}
- NSDictionary *result = @{
- @"acceleration": @{
- @"x": @(data.userAcceleration.x * EXGravity),
- @"y": @(data.userAcceleration.y * EXGravity),
- @"z": @(data.userAcceleration.z * EXGravity)
- },
+ NSMutableDictionary *result = [NSMutableDictionary dictionaryWithDictionary:@{
+ @"acceleration": [NSNull null],
@"accelerationIncludingGravity": @{
@"x": @((data.userAcceleration.x + data.gravity.x) * EXGravity),
@"y": @((data.userAcceleration.y + data.gravity.y) * EXGravity),
@@ -336,14 +339,25 @@ - (void)activateDeviceMotionUpdates
@"beta": @(data.attitude.pitch),
@"gamma": @(data.attitude.roll),
},
- @"rotationRate" :@{
- @"alpha": @(data.rotationRate.z),
- @"beta": @(data.rotationRate.y),
- @"gamma": @(data.rotationRate.x)
- },
- @"orientation": @(orientationDegrees)
- };
+ @"rotationRate": [NSNull null],
+ @"orientation": @(orientationDegrees),
+ @"interval": @(interval),
+ }];
+ if ([[strongSelf manager] isGyroAvailable]) {
+ result[@"acceleration"] = @{
+ @"x": @(data.userAcceleration.x * EXGravity),
+ @"y": @(data.userAcceleration.y * EXGravity),
+ @"z": @(data.userAcceleration.z * EXGravity)
+ };
+ // Rate of rotation of the hosting device in space expressed in degrees per second.
+ result[@"rotationRate"] = @{
+ @"alpha": @([strongSelf radiansToDegrees:data.rotationRate.x]),
+ @"beta": @([strongSelf radiansToDegrees:data.rotationRate.y]),
+ @"gamma": @([strongSelf radiansToDegrees:data.rotationRate.z])
+ };
+ }
+
// DeviceMotionUpdates handle DeviceMotion data as well as magnetic field
for (void (^handler)(NSDictionary *) in strongSelf.deviceMotionHandlers.allValues) {
handler(result);
diff --git a/packages/expo-sensors/src/DeviceMotion.ts b/packages/expo-sensors/src/DeviceMotion.ts
index f200b9a2d3067..fd919ab887208 100644
--- a/packages/expo-sensors/src/DeviceMotion.ts
+++ b/packages/expo-sensors/src/DeviceMotion.ts
@@ -2,7 +2,7 @@ import DeviceSensor from './DeviceSensor';
import ExponentDeviceMotion from './ExponentDeviceMotion';
export interface DeviceMotionMeasurement {
- acceleration: {
+ acceleration: null | {
x: number;
y: number;
z: number;
@@ -17,11 +17,27 @@ export interface DeviceMotionMeasurement {
beta: number;
gamma: number;
};
- rotationRate: {
+ /**
+ * Device's rate of rotation in space expressed in degrees per second (deg/s).
+ */
+ rotationRate: null | {
+ /**
+ * x axis rotation.
+ */
alpha: number;
+ /**
+ * y axis rotation.
+ */
beta: number;
+ /**
+ * z axis rotation.
+ */
gamma: number;
};
+ /**
+ * Interval at which data is obtained from the native platform. Expressed in **milliseconds**.
+ */
+ interval: number;
orientation: number;
}
diff --git a/packages/expo-sensors/src/ExponentDeviceMotion.web.ts b/packages/expo-sensors/src/ExponentDeviceMotion.web.ts
index 8048a73f89559..3665f2bb12565 100644
--- a/packages/expo-sensors/src/ExponentDeviceMotion.web.ts
+++ b/packages/expo-sensors/src/ExponentDeviceMotion.web.ts
@@ -8,8 +8,11 @@ export default {
get name(): string {
return 'ExponentDeviceMotion';
},
+ /**
+ * Gravity on the planet this module supports (currently just Earth) represented as m/s^2.
+ */
get Gravity(): number {
- return 9.81;
+ return 9.80665;
},
async isAvailableAsync(): Promise {
if (typeof DeviceMotionEvent === 'undefined') {
diff --git a/packages/jest-expo/src/preset/expoModules.js b/packages/jest-expo/src/preset/expoModules.js
index 07e21e5f0bba5..cb5195b82e910 100644
--- a/packages/jest-expo/src/preset/expoModules.js
+++ b/packages/jest-expo/src/preset/expoModules.js
@@ -829,7 +829,7 @@ module.exports = {
systemFonts: { type: 'array' },
},
ExponentDeviceMotion: {
- Gravity: { type: 'number', mock: 9.8100004196167 },
+ Gravity: { type: 'number', mock: 9.80665 },
addListener: { type: 'function' },
isAvailableAsync: { type: 'function' },
removeListeners: { type: 'function' },