startGyroscope

Requires:
BaseKit≥2.3.2@ray-js/ray≥0.3.23
Platforms:
iOSAndroid
import { startGyroscope } from '@ray-js/ray';

// Promise usage
try {
  const res = await startGyroscope({ ...params });
  console.log(res);
} catch (err) {
  console.log(err.errorMsg);
}

Method signature
startGyroscope(params: )
Minimum SDK versions
iOSThingSmartBaseKitBizBundle
≥ 5.2.1
Androidcom.thingclips.smart:thingsmart-bizbundle-basekit
≥ 5.2.0

Description

Start listening to gyroscope data

Parameters

PropertyTypeRequiredDefaultDescriptionMinimum SDK versions
interval"game" | "ui" | "normal"No'normal'Frequency of the gyroscope data callback—
complete() => voidNo-Completion callback (executed on both success and failure)—
success() => voidNo-Callback on successful API call—
fail(params: Object) => voidNo-Failure callback—
fail callback parameters
PropertyTypeDescription
errorMsgstringError message
errorCodestring | numberError code
Error extension

Return Value

None

Valid Values

interval
ValueDescriptionBaseKit Since
gameCallback frequency for game updates, about 20 ms per callback-
uiCallback frequency for UI updates, about 60 ms per callback-
normalNormal callback frequency, about 200 ms per callback-

Examples

import { startGyroscope } from '@ray-js/ray'

// Start listening to the gyroscope; interval is the callback frequency: game(~20ms) / ui(~60ms) / normal(~200ms)
startGyroscope({
  interval: "normal",
  success: () => console.log("Started listening to the gyroscope"),
  fail: error => console.error(error),
});