提交 0b399738 编写于 作者: H HelloCrease

update docs

Signed-off-by: NHelloCrease <lian15@huawei.com>
上级 fcfa5ea7
# 传感器 # 传感器
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > **说明:**
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
``` ```js
import sensor from '@ohos.sensor'; import sensor from '@ohos.sensor';
``` ```
...@@ -30,7 +30,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;Acceler ...@@ -30,7 +30,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;Acceler
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -59,7 +59,7 @@ on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;Line ...@@ -59,7 +59,7 @@ on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;Line
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -88,7 +88,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback ...@@ -88,7 +88,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -118,7 +118,7 @@ on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityRespons ...@@ -118,7 +118,7 @@ on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityRespons
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -147,7 +147,7 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeRes ...@@ -147,7 +147,7 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeRes
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -176,7 +176,7 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:Callback&lt;G ...@@ -176,7 +176,7 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:Callback&lt;G
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -206,7 +206,7 @@ on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback&lt;Sig ...@@ -206,7 +206,7 @@ on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback&lt;Sig
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(data){
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
}, },
...@@ -233,7 +233,7 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback&lt;Pe ...@@ -233,7 +233,7 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback&lt;Pe
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(data){
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
}, },
...@@ -260,7 +260,7 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerRes ...@@ -260,7 +260,7 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerRes
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,function(data){
console.info('Steps: ' + data.steps); console.info('Steps: ' + data.steps);
}, },
...@@ -285,7 +285,7 @@ on(type:SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:Callback&lt;Ambie ...@@ -285,7 +285,7 @@ on(type:SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:Callback&lt;Ambie
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,function(data){
console.info('Temperature: ' + data.temperature); console.info('Temperature: ' + data.temperature);
}, },
...@@ -310,7 +310,7 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;Magneti ...@@ -310,7 +310,7 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;Magneti
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -337,7 +337,7 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callbac ...@@ -337,7 +337,7 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callbac
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -367,7 +367,7 @@ on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityRes ...@@ -367,7 +367,7 @@ on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityRes
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY,function(data){
console.info('Distance: ' + data.distance); console.info('Distance: ' + data.distance);
}, },
...@@ -392,7 +392,7 @@ on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityRespo ...@@ -392,7 +392,7 @@ on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityRespo
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY,function(data){
console.info('Humidity: ' + data.humidity); console.info('Humidity: ' + data.humidity);
}, },
...@@ -417,7 +417,7 @@ on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerRes ...@@ -417,7 +417,7 @@ on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerRes
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,function(data){
console.info('Atmospheric pressure: ' + data.pressure); console.info('Atmospheric pressure: ' + data.pressure);
}, },
...@@ -442,7 +442,7 @@ on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt;, ...@@ -442,7 +442,7 @@ on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt;,
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL,function(data){
console.info('Status: ' + data.status); console.info('Status: ' + data.status);
}, },
...@@ -467,7 +467,7 @@ on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightRes ...@@ -467,7 +467,7 @@ on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightRes
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,function(data){
console.info(' Illumination: ' + data.intensity); console.info(' Illumination: ' + data.intensity);
}, },
...@@ -492,7 +492,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;Orientatio ...@@ -492,7 +492,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;Orientatio
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,function(data){
console.info('The device rotates at an angle around the X axis: ' + data.beta); console.info('The device rotates at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the Y axis: ' + data.gamma); console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
...@@ -521,7 +521,7 @@ on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRateRe ...@@ -521,7 +521,7 @@ on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRateRe
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE,function(data){
console.info("Heart rate: " + data.heartRate); console.info("Heart rate: " + data.heartRate);
}, },
...@@ -545,7 +545,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback: Callback&lt;Rotatio ...@@ -545,7 +545,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback: Callback&lt;Rotatio
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -573,7 +573,7 @@ on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearDet ...@@ -573,7 +573,7 @@ on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearDet
| options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 | | options | [Options](#options) | 否 | 可选参数列表,设置上报频率,默认值为200000000ns。 |
**示例:** **示例:**
``` ```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(data){ sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(data){
console.info('Wear status: ' + data.value); console.info('Wear status: ' + data.value);
}, },
...@@ -599,7 +599,7 @@ once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;Accele ...@@ -599,7 +599,7 @@ once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;Accele
| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | 是 | 注册一次加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 | | callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | 是 | 注册一次加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){ sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -626,7 +626,7 @@ once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;Li ...@@ -626,7 +626,7 @@ once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;Li
| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | 是 | 注册一次线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 | | callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | 是 | 注册一次线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -681,7 +681,7 @@ once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityRespo ...@@ -681,7 +681,7 @@ once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityRespo
| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | 是 | 注册一次重力传感器的回调函数,上报的数据类型为GravityResponse。 | | callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | 是 | 注册一次重力传感器的回调函数,上报的数据类型为GravityResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -708,7 +708,7 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeR ...@@ -708,7 +708,7 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeR
| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | 是 | 注册一次陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 | | callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | 是 | 注册一次陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -735,7 +735,7 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback: Callback&l ...@@ -735,7 +735,7 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback: Callback&l
| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | 是 | 注册一次未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 | | callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | 是 | 注册一次未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -763,7 +763,7 @@ once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback: Callback&lt;Si ...@@ -763,7 +763,7 @@ once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback: Callback&lt;Si
| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | 是 | 注册一次有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 | | callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | 是 | 注册一次有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(data) {
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
} }
...@@ -788,7 +788,7 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback: Callback&lt;P ...@@ -788,7 +788,7 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback: Callback&lt;P
| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | 是 | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 | | callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | 是 | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(data) {
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
} }
...@@ -813,7 +813,7 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerR ...@@ -813,7 +813,7 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerR
| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | 是 | 注册一次计步传感器的回调函数,上报的数据类型为PedometerResponse。 | | callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | 是 | 注册一次计步传感器的回调函数,上报的数据类型为PedometerResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function(data) {
console.info('Steps: ' + data.steps); console.info('Steps: ' + data.steps);
} }
...@@ -836,7 +836,7 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback: Callback&lt;A ...@@ -836,7 +836,7 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback: Callback&lt;A
| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | 是 | 注册一次环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 | | callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | 是 | 注册一次环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(data) {
console.info('Temperature: ' + data.temperature); console.info('Temperature: ' + data.temperature);
} }
...@@ -859,7 +859,7 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;Magne ...@@ -859,7 +859,7 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;Magne
| callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | 是 | 注册一次磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 | | callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | 是 | 注册一次磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -884,7 +884,7 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callb ...@@ -884,7 +884,7 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callb
| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | 是 | 注册一次未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 | | callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | 是 | 注册一次未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -912,7 +912,7 @@ once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityR ...@@ -912,7 +912,7 @@ once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityR
| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | 是 | 注册一次接近光传感器的回调函数,上报的数据类型为ProximityResponse。 | | callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | 是 | 注册一次接近光传感器的回调函数,上报的数据类型为ProximityResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(error, data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(error, data) {
if (error) { if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message); console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
...@@ -939,7 +939,7 @@ once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityRes ...@@ -939,7 +939,7 @@ once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityRes
| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | 是 | 注册一次湿度传感器的回调函数,上报的数据类型为HumidityResponse。 | | callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | 是 | 注册一次湿度传感器的回调函数,上报的数据类型为HumidityResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function(data) {
console.info('Humidity: ' + data.humidity); console.info('Humidity: ' + data.humidity);
} }
...@@ -962,7 +962,7 @@ once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerR ...@@ -962,7 +962,7 @@ once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerR
| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | 是 | 注册一次气压计传感器的回调函数,上报的数据类型为BarometerResponse。 | | callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | 是 | 注册一次气压计传感器的回调函数,上报的数据类型为BarometerResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) {
console.info('Atmospheric pressure: ' + data.pressure); console.info('Atmospheric pressure: ' + data.pressure);
} }
...@@ -985,7 +985,7 @@ once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt ...@@ -985,7 +985,7 @@ once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt
| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | 是 | 注册一次霍尔传感器的回调函数,上报的数据类型为HallResponse。 | | callback | Callback&lt;[HallResponse](#hallresponse)&gt; | 是 | 注册一次霍尔传感器的回调函数,上报的数据类型为HallResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function(data) {
console.info('Status: ' + data.status); console.info('Status: ' + data.status);
} }
...@@ -1008,7 +1008,7 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightR ...@@ -1008,7 +1008,7 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightR
| callback | Callback&lt;[LightResponse](#lightresponse)&gt; | 是 | 注册一次环境光传感器的回调函数,上报的数据类型为LightResponse。 | | callback | Callback&lt;[LightResponse](#lightresponse)&gt; | 是 | 注册一次环境光传感器的回调函数,上报的数据类型为LightResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function(data) {
console.info(' Illumination: ' + data.intensity); console.info(' Illumination: ' + data.intensity);
} }
...@@ -1031,7 +1031,7 @@ once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;Orientat ...@@ -1031,7 +1031,7 @@ once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;Orientat
| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | 是 | 注册一次方向传感器的回调函数,上报的数据类型为OrientationResponse。 | | callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | 是 | 注册一次方向传感器的回调函数,上报的数据类型为OrientationResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function(data) {
console.info('The device rotates at an angle around the X axis: ' + data.beta); console.info('The device rotates at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the Y axis: ' + data.gamma); console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
...@@ -1056,7 +1056,7 @@ once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback&lt;Rota ...@@ -1056,7 +1056,7 @@ once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback&lt;Rota
| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | 是 | 注册一次旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 | | callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | 是 | 注册一次旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1084,7 +1084,7 @@ once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRate ...@@ -1084,7 +1084,7 @@ once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRate
| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 | | callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | 是 | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, function(data) {
console.info("Heart rate: " + data.heartRate); console.info("Heart rate: " + data.heartRate);
} }
...@@ -1107,7 +1107,7 @@ once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearD ...@@ -1107,7 +1107,7 @@ once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearD
| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | 是 | 注册一次穿戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 | | callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | 是 | 注册一次穿戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 |
**示例:** **示例:**
``` ```js
sensor.once(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function(data) { sensor.once(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function(data) {
console.info("Wear status: "+ data.value); console.info("Wear status: "+ data.value);
} }
...@@ -1133,7 +1133,7 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback&lt;Accele ...@@ -1133,7 +1133,7 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback&lt;Accele
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('x-coordinate component: ' + data.x); console.info('x-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1161,7 +1161,7 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callb ...@@ -1161,7 +1161,7 @@ off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callb
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1190,7 +1190,7 @@ off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback&lt;LightR ...@@ -1190,7 +1190,7 @@ off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback&lt;LightR
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info(' Illumination: ' + data.intensity); console.info(' Illumination: ' + data.intensity);
} }
...@@ -1214,7 +1214,7 @@ off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback&lt; ...@@ -1214,7 +1214,7 @@ off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback&lt;
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('Temperature: ' + data.temperature); console.info('Temperature: ' + data.temperature);
} }
...@@ -1238,7 +1238,7 @@ off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback&lt;BarometerR ...@@ -1238,7 +1238,7 @@ off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback&lt;BarometerR
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('Atmospheric pressure: ' + data.pressure); console.info('Atmospheric pressure: ' + data.pressure);
} }
...@@ -1262,7 +1262,7 @@ off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback&lt;GravityRespo ...@@ -1262,7 +1262,7 @@ off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback&lt;GravityRespo
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1290,7 +1290,7 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback&lt;GyroscopeR ...@@ -1290,7 +1290,7 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback&lt;GyroscopeR
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1318,7 +1318,7 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback& ...@@ -1318,7 +1318,7 @@ off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback&
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1344,7 +1344,7 @@ off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback&lt;HallResponse&gt ...@@ -1344,7 +1344,7 @@ off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback&lt;HallResponse&gt
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('Status: ' + data.status); console.info('Status: ' + data.status);
} }
...@@ -1370,7 +1370,7 @@ off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback&lt;HeartRate ...@@ -1370,7 +1370,7 @@ off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback&lt;HeartRate
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info("Heart rate: " + data.heartRate); console.info("Heart rate: " + data.heartRate);
} }
...@@ -1396,7 +1396,7 @@ off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback&lt;HumidityRes ...@@ -1396,7 +1396,7 @@ off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback&lt;HumidityRes
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('Humidity: ' + data.humidity); console.info('Humidity: ' + data.humidity);
} }
...@@ -1422,7 +1422,7 @@ off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback&lt; ...@@ -1422,7 +1422,7 @@ off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback&lt;
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1450,7 +1450,7 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback); ...@@ -1450,7 +1450,7 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback);
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1476,7 +1476,7 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback); ...@@ -1476,7 +1476,7 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback);
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1505,7 +1505,7 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callbac ...@@ -1505,7 +1505,7 @@ sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callbac
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('The device rotates at an angle around the X axis: ' + data.beta); console.info('The device rotates at an angle around the X axis: ' + data.beta);
console.info('The device rotates at an angle around the Y axis: ' + data.gamma); console.info('The device rotates at an angle around the Y axis: ' + data.gamma);
...@@ -1531,7 +1531,7 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback&lt;PedometerR ...@@ -1531,7 +1531,7 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback&lt;PedometerR
**返回值:** ; **返回值:** ;
``` ```js
function callback(data) { function callback(data) {
console.info('Steps: ' + data.steps); console.info('Steps: ' + data.steps);
} }
...@@ -1557,7 +1557,7 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback&lt; ...@@ -1557,7 +1557,7 @@ off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback&lt;
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
} }
...@@ -1581,7 +1581,7 @@ off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback&lt;ProximityR ...@@ -1581,7 +1581,7 @@ off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback&lt;ProximityR
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('Distance: ' + data.distance); console.info('Distance: ' + data.distance);
} }
...@@ -1605,7 +1605,7 @@ off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback&lt;Rota ...@@ -1605,7 +1605,7 @@ off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback&lt;Rota
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('X-coordinate component: ' + data.x); console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y); console.info('Y-coordinate component: ' + data.y);
...@@ -1632,7 +1632,7 @@ off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback&lt;S ...@@ -1632,7 +1632,7 @@ off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback&lt;S
**示例:** **示例:**
``` ```js
function callback(data) { function callback(data) {
console.info('Scalar data: ' + data.scalar); console.info('Scalar data: ' + data.scalar);
} }
...@@ -1656,7 +1656,7 @@ off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback&lt;WearD ...@@ -1656,7 +1656,7 @@ off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback&lt;WearD
**示例:** **示例:**
``` ```js
function accCallback(data) { function accCallback(data) {
console.info('Wear status: ' + data.value); console.info('Wear status: ' + data.value);
} }
...@@ -1681,13 +1681,13 @@ transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: Co ...@@ -1681,13 +1681,13 @@ transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: Co
**示例:** **示例:**
``` ```js
sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3}, function(err, data) { sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3}, function(err, data) {
if (err) { if (err) {
console.error("Operation failed. Error code: " + err.code + ", message: " + err.message); console.error("Operation failed. Error code: " + err.code + ", message: " + err.message);
return; return;
} }
console.info("Operation successed. Data obtained: " + data.x); console.info("Operation successed. Data obtained: " + data);
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]); console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]);
} }
...@@ -1716,8 +1716,8 @@ transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: Co ...@@ -1716,8 +1716,8 @@ transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: Co
**示例:** **示例:**
``` ```js
const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3}); const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3});
promise.then((data) => { promise.then((data) => {
console.info("Operation successed."); console.info("Operation successed.");
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
...@@ -1744,8 +1744,8 @@ getGeomagneticField(locationOptions: LocationOptions, timeMillis: number, callba ...@@ -1744,8 +1744,8 @@ getGeomagneticField(locationOptions: LocationOptions, timeMillis: number, callba
| callback | AsyncCallback&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 是 | 返回磁场信息。 | | callback | AsyncCallback&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 是 | 返回磁场信息。 |
**示例:** **示例:**
``` ```js
sensor.getGeomagneticField([80, 0, 0], 1580486400000, function(err, data) { sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000, function(err, data) {
if (err) { if (err) {
console.error('Operation failed. Error code: ' + err.code + '; message: ' + err.message); console.error('Operation failed. Error code: ' + err.code + '; message: ' + err.message);
return; return;
...@@ -1775,8 +1775,8 @@ getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promi ...@@ -1775,8 +1775,8 @@ getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promi
| Promise&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 返回磁场信息。 | | Promise&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 返回磁场信息。 |
**返回值:** **返回值:**
``` ```js
const promise = sensor.getGeomagneticField([80, 0, 0], 1580486400000); const promise = sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000);
promise.then((data) => { promise.then((data) => {
console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' + console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' +
data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle + data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle +
...@@ -1804,7 +1804,7 @@ getAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallbac ...@@ -1804,7 +1804,7 @@ getAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallbac
**返回值:** **返回值:**
``` ```js
sensor.getAltitude(0, 200, function(err, data) { sensor.getAltitude(0, 200, function(err, data) {
if (err) { if (err) {
console.error( console.error(
...@@ -1838,7 +1838,7 @@ getAltitude(seaPressure: number, currentPressure: number): Promise&lt;number&gt; ...@@ -1838,7 +1838,7 @@ getAltitude(seaPressure: number, currentPressure: number): Promise&lt;number&gt;
**返回值:** **返回值:**
``` ```js
const promise = sensor.getAltitude(0, 200); const promise = sensor.getAltitude(0, 200);
promise.then((data) => { promise.then((data) => {
console.info(' sensor_getAltitude_Promise success', data); console.info(' sensor_getAltitude_Promise success', data);
...@@ -1865,10 +1865,10 @@ getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;, callback: AsyncCallbac ...@@ -1865,10 +1865,10 @@ getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;, callback: AsyncCallbac
**返回值:** **返回值:**
``` ```js
sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) { sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) {
if (err) { if (err) {
console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message); err.message);
return; return;
} }
...@@ -1898,7 +1898,7 @@ getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;): Promise&lt;number&gt; ...@@ -1898,7 +1898,7 @@ getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;): Promise&lt;number&gt;
**返回值:** **返回值:**
``` ```js
const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]); const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]);
promise.then((data) => { promise.then((data) => {
console.info(' getGeomagneticDip_promise successed', data); console.info(' getGeomagneticDip_promise successed', data);
...@@ -1925,10 +1925,10 @@ getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Ar ...@@ -1925,10 +1925,10 @@ getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Ar
**返回值:** **返回值:**
``` ```js
sensor. getAngleModify([1,0,0,0,1,0,0,0,1], [1, 0, 0, 0, 0.87, -0.50, 0, 0.50, 0.87], function(err, data) { sensor. getAngleModify([1,0,0,0,1,0,0,0,1], [1, 0, 0, 0, 0.87, -0.50, 0, 0.50, 0.87], function(err, data) {
if (err) { if (err) {
console.error(LABEL + 'Failed to register data, error code is: ' + err.code + ', message: ' + console.error('Failed to register data, error code is: ' + err.code + ', message: ' +
err.message); err.message);
return; return;
} }
...@@ -1963,10 +1963,10 @@ getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Ar ...@@ -1963,10 +1963,10 @@ getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Ar
**返回值:** **返回值:**
``` ```js
const promise = sensor.getAngleModify([1,0,0,0,1,0,0,0,1], [1,0,0,0,0.87,-0.50,0,0.50,0.87]); const promise = sensor.getAngleModify([1,0,0,0,1,0,0,0,1], [1,0,0,0,0.87,-0.50,0,0.50,0.87]);
promise.then((data) => { promise.then((data) => {
console.info(LABEL + 'getAngleModifiy_promise success'); console.info('getAngleModifiy_promise success');
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]); console.info(LABEL + "data[" + i + "]: " + data[i]);
} }
...@@ -1993,10 +1993,10 @@ createRotationMatrix(rotationVector: Array&lt;number&gt;, callback: AsyncCallbac ...@@ -1993,10 +1993,10 @@ createRotationMatrix(rotationVector: Array&lt;number&gt;, callback: AsyncCallbac
**返回值:** **返回值:**
``` ```js
sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) { sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) {
if (err) { if (err) {
console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message); err.message);
return; return;
} }
...@@ -2030,10 +2030,10 @@ createRotationMatrix(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;n ...@@ -2030,10 +2030,10 @@ createRotationMatrix(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;n
**返回值:** **返回值:**
``` ```js
const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]); const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]);
promise.then((data) => { promise.then((data) => {
console.info(LABEL + 'createRotationMatrix_promise success'); console.info('createRotationMatrix_promise success');
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]); console.info(LABEL + "data[" + i + "]: " + data[i]);
} }
...@@ -2060,10 +2060,10 @@ createQuaternion(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&lt ...@@ -2060,10 +2060,10 @@ createQuaternion(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&lt
**返回值:** **返回值:**
``` ```js
sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) { sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) {
if (err) { if (err) {
console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message); err.message);
return; return;
} }
...@@ -2097,12 +2097,12 @@ createQuaternion(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;numbe ...@@ -2097,12 +2097,12 @@ createQuaternion(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;numbe
**返回值:** **返回值:**
``` ```js
const promise = sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]); const promise = sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]);
promise.then((data) => { promise.then((data) => {
console.info('createQuaternion_promise successed'); console.info('createQuaternion_promise successed');
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]); console.info("data[" + i + "]: " + data[i]);
} }
}).catch((err) => { }).catch((err) => {
console.info('promise failed'); console.info('promise failed');
...@@ -2127,16 +2127,16 @@ getDirection(rotationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;Arr ...@@ -2127,16 +2127,16 @@ getDirection(rotationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;Arr
**返回值:** **返回值:**
``` ```js
sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) { sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data) {
if (err) { if (err) {
console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message); err.message);
return; return;
} }
console.info(LABEL + "SensorJsAPI--->Successed to get getDirection interface get data: " + data.x); console.info("SensorJsAPI--->Successed to get getDirection interface get data: " + data.x);
for (var i = 1; i < data.length; i++) { for (var i = 1; i < data.length; i++) {
console.info(TAG +"sensor_getDirection_callback" + data[i]); console.info("sensor_getDirection_callback" + data[i]);
} }
}) })
``` ```
...@@ -2164,12 +2164,12 @@ getDirection(rotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt ...@@ -2164,12 +2164,12 @@ getDirection(rotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt
**返回值:** **返回值:**
``` ```js
const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]); const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]);
promise.then((data) => { promise.then((data) => {
console.info(' sensor_getAltitude_Promise success', data.x); console.info('sensor_getAltitude_Promise success', data.x);
for (var i = 1; i < data.length; i++) { for (var i = 1; i < data.length; i++) {
console.info(TAG +"sensor_getDirection_promise" + data[i]); console.info("sensor_getDirection_promise" + data[i]);
} }
}).catch((err) => { }).catch((err) => {
console.info('promise failed'); console.info('promise failed');
...@@ -2195,16 +2195,16 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number& ...@@ -2195,16 +2195,16 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&
**返回值:** **返回值:**
``` ```js
sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(err, data) { sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(err, data) {
if (err) { if (err) {
console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
err.message); err.message);
return; return;
} }
console.info("SensorJsAPI--->Successed to get createRotationMatrix interface get data: " + data.x); console.info("SensorJsAPI--->Successed to get createRotationMatrix interface get data: " + data.x);
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]) console.info("data[" + i + "]: " + data[i])
} }
}) })
``` ```
...@@ -2233,15 +2233,15 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number& ...@@ -2233,15 +2233,15 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&
**返回值:** **返回值:**
``` ```js
const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]); const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]);
promise.then((data) => { promise.then((data) => {
console.info(LABEL + 'createRotationMatrix_promise successed'); console.info('createRotationMatrix_promise successed');
for (var i=0; i < data.length; i++) { for (var i=0; i < data.length; i++) {
console.info(LABEL + "data[" + i + "]: " + data[i]); console.info(LABEL + "data[" + i + "]: " + data[i]);
} }
}).catch((err) => { }).catch((err) => {
console.info(LABEL + 'promise failed'); console.info('promise failed');
}) })
``` ```
...@@ -2356,7 +2356,7 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number& ...@@ -2356,7 +2356,7 @@ createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&
| 名称 | 参数类型 | 可读 | 可写 | 说明 | | 名称 | 参数类型 | 可读 | 可写 | 说明 |
| ----- | ------ | ---- | ---- | ------------------------ | | ----- | ------ | ---- | ---- | ----------------- |
| alpha | number | 是 | 是 | 设备围绕Z轴的旋转角度,单位:度。 | | alpha | number | 是 | 是 | 设备围绕Z轴的旋转角度,单位:度。 |
| beta | number | 是 | 是 | 设备围绕X轴的旋转角度,单位:度。 | | beta | number | 是 | 是 | 设备围绕X轴的旋转角度,单位:度。 |
| gamma | number | 是 | 是 | 设备围绕Y轴的旋转角度,单位:度。 | | gamma | number | 是 | 是 | 设备围绕Y轴的旋转角度,单位:度。 |
......
# 振动 # 振动
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:** > **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。 > 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块 ## 导入模块
``` ```js
import vibrator from '@ohos.vibrator'; import vibrator from '@ohos.vibrator';
``` ```
...@@ -34,7 +35,7 @@ vibrate(duration: number): Promise&lt;void&gt; ...@@ -34,7 +35,7 @@ vibrate(duration: number): Promise&lt;void&gt;
**示例:** **示例:**
``` ```js
vibrator.vibrate(1000).then(()=>{ vibrator.vibrate(1000).then(()=>{
console.log("Promise returned to indicate a successful vibration."); console.log("Promise returned to indicate a successful vibration.");
}, (error)=>{ }, (error)=>{
...@@ -60,7 +61,7 @@ vibrate(duration: number, callback?: AsyncCallback&lt;void&gt;): void ...@@ -60,7 +61,7 @@ vibrate(duration: number, callback?: AsyncCallback&lt;void&gt;): void
| callback | AsyncCallback&lt;void&gt; | 否 | 马达执行振动的回调函数,指示触发振动是否成功。 | | callback | AsyncCallback&lt;void&gt; | 否 | 马达执行振动的回调函数,指示触发振动是否成功。 |
**示例:** **示例:**
``` ```js
vibrator.vibrate(1000,function(error){ vibrator.vibrate(1000,function(error){
if(error){ if(error){
console.log("error.code"+error.code+"error.message"+error.message); console.log("error.code"+error.code+"error.message"+error.message);
...@@ -92,7 +93,7 @@ vibrate(effectId: EffectId): Promise&lt;void&gt; ...@@ -92,7 +93,7 @@ vibrate(effectId: EffectId): Promise&lt;void&gt;
| Promise&lt;void&gt; | 指示触发振动是否成功。 | | Promise&lt;void&gt; | 指示触发振动是否成功。 |
**示例:** **示例:**
``` ```js
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(()=>{ vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(()=>{
console.log("Promise returned to indicate a successful vibration."); console.log("Promise returned to indicate a successful vibration.");
}, (error)=>{ }, (error)=>{
...@@ -118,7 +119,7 @@ vibrate(effectId: EffectId, callback?: AsyncCallback&lt;void&gt;): void ...@@ -118,7 +119,7 @@ vibrate(effectId: EffectId, callback?: AsyncCallback&lt;void&gt;): void
| callback | AsyncCallback&lt;void&gt; | 否 | 马达执行振动的回调函数,指示触发振动是否成功。 | | callback | AsyncCallback&lt;void&gt; | 否 | 马达执行振动的回调函数,指示触发振动是否成功。 |
**示例:** **示例:**
``` ```js
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function(error){ vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER, function(error){
if(error){ if(error){
console.log("error.code"+error.code+"error.message"+error.message); console.log("error.code"+error.code+"error.message"+error.message);
...@@ -150,7 +151,7 @@ stop(stopMode: VibratorStopMode): Promise&lt;void&gt; ...@@ -150,7 +151,7 @@ stop(stopMode: VibratorStopMode): Promise&lt;void&gt;
| Promise&lt;void&gt; | 指示停止振动是否成功。 | | Promise&lt;void&gt; | 指示停止振动是否成功。 |
**示例:** **示例:**
``` ```js
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{ vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{
console.log("Promise returned to indicate a successful vibration."); console.log("Promise returned to indicate a successful vibration.");
}, (error)=>{ }, (error)=>{
...@@ -176,7 +177,7 @@ stop(stopMode: VibratorStopMode, callback?: AsyncCallback&lt;void&gt;): void; ...@@ -176,7 +177,7 @@ stop(stopMode: VibratorStopMode, callback?: AsyncCallback&lt;void&gt;): void;
| callback | AsyncCallback&lt;void&gt; | 否 | 马达停止振动的回调函数,指示停止振动是否成功。 | | callback | AsyncCallback&lt;void&gt; | 否 | 马达停止振动的回调函数,指示停止振动是否成功。 |
**示例:** **示例:**
``` ```js
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error){ vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET, function(error){
if(error){ if(error){
console.log("error.code"+error.code+"error.message"+error.message); console.log("error.code"+error.code+"error.message"+error.message);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册