js-apis-sensor.md 233.3 KB
Newer Older
Z
zengyawen 已提交
1
# 传感器
Z
zengyawen 已提交
2

C
cff-gite 已提交
3 4 5 6 7 8 9 10 11 12 13
sensor模块提供订阅传感器数据基本能力,包括订阅、取消订阅传感器数据,获取传感器列表,以及通用的传感器算法接口如通过气压值计算海拔高度、通过旋转矩阵计算设备方向等。

传感器是指用于侦测环境中所发生事件或变化,并将此消息发送至其他电子设备(如中央处理器)的设备,通常由敏感组件和转换组件组成。传感器是实现物联网智能化的重要基石,为实现全场景智慧化战略,支撑“1+8+N”产品需求,需要构筑统一的传感器管理框架,达到为各产品/业务提供低时延、低功耗的感知数据的目的。根据用途可分为以下六大类:

- 运动类:加速度、陀螺仪、重力、线性加速度传感器等
- 姿态类:旋转矢量、方向传感器等
- 环境类:磁力计、气压、湿度传感器等
- 光线类:环境光、接近光、色温传感器等
- 健康类:心率、心跳传感器等
- 其它:霍尔传感器、手握传感器等

H
HelloCrease 已提交
14
> **说明:**
Z
zengyawen 已提交
15
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
Z
zengyawen 已提交
16

Z
zengyawen 已提交
17 18

## 导入模块
Z
zengyawen 已提交
19

H
HelloCrease 已提交
20
```js
Z
zengyawen 已提交
21 22 23
import sensor from '@ohos.sensor';
```

C
cff-gite 已提交
24
## sensor.on<sup>9+</sup>
Z
zengyawen 已提交
25

C
cff-gite 已提交
26
### ACCELEROMETER<sup>9+</sup>
C
cff-gite 已提交
27 28 29 30 31 32 33 34 35 36 37 38 39

on(type: SensorId.ACCELEROMETER, callback: Callback&lt;AccelerometerResponse&gt;,options?: Options): void

订阅加速度计传感器数据。

**需要权限**:ohos.permission.ACCELEROMETER 

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
40
| type     | [SensorId](#sensorid9)                                       | 是   | 要订阅的加速度传感器类型为 ACCELEROMETER。                   |
C
cff-gite 已提交
41 42 43 44 45 46
| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | 是   | 注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 |
| options  | [Options](#options)                                          | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。            |

**示例:** 

```js
C
cff-gite 已提交
47 48 49 50 51 52 53 54 55
try {
    sensor.on(sensor.SensorId.ACCELEROMETER,function(data){
        console.info('X-coordinate component: ' + data.x);
        console.info('Y-coordinate component: ' + data.y);
        console.info('Z-coordinate component: ' + data.z);
    }, {interval: 10000000} );
} catch(err) {
        console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
56 57
```

C
cff-gite 已提交
58
### ACCELEROMETER_UNCALIBRATED<sup>9+</sup>
C
cff-gite 已提交
59 60 61 62 63 64 65 66 67 68 69 70 71

on(type: SensorId.ACCELEROMETER_UNCALIBRATED, callback:Callback&lt;AccelerometerUncalibratedResponse&gt;,options?: Options): void

订阅未校准的加速度计传感器数据。

**需要权限**:ohos.permission.ACCELEROMETER 

**系统能力**:SystemCapability.Sensors.Sensor 

**参数:** 

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
72
| type     | [SensorId](#sensorid9)                                       | 是   | 要订阅的未校准加速度传感器类型为ACCELEROMETER_UNCALIBRATED。 |
C
cff-gite 已提交
73 74 75 76 77 78
| callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | 是   | 注册未校准加速度计传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 |
| options  | [Options](#options)                                          | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。            |

**示例:** 

```js
C
cff-gite 已提交
79 80 81 82 83 84 85 86 87 88 89 90
try {
    sensor.on(sensor.SensorId.ACCELEROMETER_UNCALIBRATED,function(data){
        console.info('X-coordinate component: ' + data.x);
        console.info('Y-coordinate component: ' + data.y);
        console.info('Z-coordinate component: ' + data.z);
        console.info('X-coordinate bias: ' + data.biasX);
        console.info('Y-coordinate bias: ' + data.biasY);
        console.info('Z-coordinate bias: ' + data.biasZ);
      }, {interval: 10000000} );
} catch(err) {
      console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
91 92
```

C
cff-gite 已提交
93
### AMBIENT_LIGHT<sup>9+</sup>
C
cff-gite 已提交
94 95 96 97 98 99 100 101 102 103 104

on(type: SensorId.AMBIENT_LIGHT, callback: Callback&lt;LightResponse&gt;, options?: Options): void

订阅环境光传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名   | 类型                                            | 必填 | 说明                                                        |
| -------- | ----------------------------------------------- | ---- | ----------------------------------------------------------- |
C
cff-gite 已提交
105
| type     | [SensorId](#sensorid9)                          | 是   | 要订阅的环境光传感器类型为AMBIENT_LIGHT。                   |
C
cff-gite 已提交
106 107 108 109 110 111
| callback | Callback&lt;[LightResponse](#lightresponse)&gt; | 是   | 注册环境光传感器的回调函数,上报的数据类型为LightResponse。 |
| options  | [Options](#options)                             | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。           |

**示例:** 

```js
C
cff-gite 已提交
112
try {
C
cff-gite 已提交
113 114
  sensor.on(sensor.SensorId.AMBIENT_LIGHT,function(data){
      console.info('Illumination: ' + data.intensity);
C
cff-gite 已提交
115 116 117 118
  }, {interval: 10000000} );
} catch(err) {
      console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
119 120
```

C
cff-gite 已提交
121
###  AMBIENT_TEMPERATURE<sup>9+</sup>
C
cff-gite 已提交
122 123 124 125 126 127 128 129 130 131 132

on(type: SensorId.AMBIENT_TEMPERATURE, callback: Callback&lt;AmbientTemperatureResponse&gt;,options?: Options): void

订阅环境温度传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
133
| type     | [SensorId](#sensorid9)                                       | 是   | 要订阅的环境温度传感器类型为AMBIENT_TEMPERATURE。            |
C
cff-gite 已提交
134 135 136 137 138 139
| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | 是   | 注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 |
| options  | [Options](#options)                                          | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。            |

**示例:**

```js
C
cff-gite 已提交
140
try {
C
cff-gite 已提交
141 142
  sensor.on(sensor.SensorId.AMBIENT_TEMPERATURE,function(data){
      console.info('Temperature: ' + data.temperature);
C
cff-gite 已提交
143 144 145 146
  }, {interval: 10000000} );
} catch(err) {
      console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
147 148
```

C
cff-gite 已提交
149
### BAROMETER<sup>9+</sup>
C
cff-gite 已提交
150 151 152 153 154 155 156 157 158 159 160

on(type: SensorId.BAROMETER, callback: Callback&lt;BarometerResponse&gt;, options?: Options): void

订阅气压计传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                    | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
161
| type     | [SensorId](#sensorid9)                                  | 是   | 要订阅的气压计传感器类型为BAROMETER。                        |
C
cff-gite 已提交
162 163 164 165 166 167
| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | 是   | 注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 |
| options  | [Options](#options)                                     | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。            |

**示例:**

```js
C
cff-gite 已提交
168
try {
C
cff-gite 已提交
169 170
  sensor.on(sensor.SensorId.BAROMETER,function(data){
      console.info('Atmospheric pressure: ' + data.pressure);
C
cff-gite 已提交
171 172 173 174
  }, {interval: 10000000} );
} catch(err) {
      console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
175 176
```

C
cff-gite 已提交
177
###  GRAVITY<sup>9+</sup>
C
cff-gite 已提交
178 179 180 181 182 183 184 185 186 187 188

on(type: SensorId.GRAVITY, callback: Callback&lt;GravityResponse&gt;,options?: Options): void

订阅重力传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名   | 类型                                                | 必填 | 说明                                                        |
| -------- | --------------------------------------------------- | ---- | ----------------------------------------------------------- |
C
cff-gite 已提交
189
| type     | [SensorId](#sensorid9)                              | 是   | 要订阅的重力传感器类型为GRAVITY。                           |
C
cff-gite 已提交
190 191 192 193 194 195
| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | 是   | 注册重力传感器的回调函数,上报的数据类型为GravityResponse。 |
| options  | [Options](#options)                                 | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。           |

**示例:**

```js
C
cff-gite 已提交
196
try {
C
cff-gite 已提交
197 198 199 200
  sensor.on(sensor.SensorId.GRAVITY,function(data){
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
C
cff-gite 已提交
201 202 203 204
  }, {interval: 10000000} );
} catch(err) {
      console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
205 206
```

C
cff-gite 已提交
207
###  GYROSCOPE<sup>9+</sup>
C
cff-gite 已提交
208 209 210 211 212 213 214 215 216 217 218 219 220

on(type: SensorId.GYROSCOPE, callback: Callback&lt;GyroscopeResponse&gt;,options?: Options): void

订阅校准的陀螺仪传感器数据。

**需要权限**: ohos.permission.GYROSCOPE 

**系统能力**:SystemCapability.Sensors.Sensor 

**参数:** 

| 参数名   | 类型                                                    | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
221
| type     | [SensorId](#sensorid9)                                  | 是   | 要订阅的陀螺仪传感器类型为GYROSCOPE。                        |
C
cff-gite 已提交
222 223 224 225 226 227
| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | 是   | 返回注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 |
| options  | [Options](#options)                                     | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。            |

**示例:**

```js
C
cff-gite 已提交
228
try {
C
cff-gite 已提交
229 230 231 232
  sensor.on(sensor.SensorId.GYROSCOPE,function(data){
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
C
cff-gite 已提交
233 234 235 236
  }, {interval: 10000000} );
} catch(err) {
      console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
237 238
```

C
cff-gite 已提交
239
###  GYROSCOPE_UNCALIBRATED<sup>9+</sup>
C
cff-gite 已提交
240 241 242 243 244 245 246 247 248 249 250 251 252 253

on(type: SensorId.GYROSCOPE_UNCALIBRATED, callback: Callback&lt;GyroscopeUncalibratedResponse&gt;,
      options?: Options): void

订阅未经校准的陀螺仪传感器数据

**需要权限**: ohos.permission.GYROSCOPE 

**系统能力**:SystemCapability.Sensors.Sensor  

**参数:** 

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
254
| type     | [SensorId](#sensorid9)                                       | 是   | 要订阅的未校准陀螺仪传感器类型为GYROSCOPE_UNCALIBRATED。     |
C
cff-gite 已提交
255 256 257 258 259 260
| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | 是   | 注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 |
| options  | [Options](#options)                                          | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。            |

**示例:**

```js
C
cff-gite 已提交
261
try {
C
cff-gite 已提交
262 263 264 265 266 267 268
  sensor.on(sensor.SensorId.GYROSCOPE_UNCALIBRATED,function(data){
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
      console.info('X-coordinate bias: ' + data.biasX);
      console.info('Y-coordinate bias: ' + data.biasY);
      console.info('Z-coordinate bias: ' + data.biasZ);
C
cff-gite 已提交
269 270 271 272
  }, {interval: 10000000} );
} catch(err) {
      console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
273 274
```

C
cff-gite 已提交
275
###  HALL<sup>9+</sup>
C
cff-gite 已提交
276 277 278 279 280 281 282 283 284 285 286

on(type: SensorId.HALL, callback: Callback&lt;HallResponse&gt;, options?: Options): void

订阅心率传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名   | 类型                                          | 必填 | 说明                                                         |
| -------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
287
| type     | [SensorId](#sensorid9)                        | 是   | 要订阅的霍尔传感器类型为HALL。                               |
C
cff-gite 已提交
288 289 290 291 292 293
| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | 是   | 注册霍尔传感器的回调函数,上报的数据类型为&nbsp;HallResponse。 |
| options  | [Options](#options)                           | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。            |

**示例:**

```js
C
cff-gite 已提交
294
try {
C
cff-gite 已提交
295 296
  sensor.on(sensor.SensorId.HALL,function(data){
      console.info('Status: ' + data.status);
C
cff-gite 已提交
297 298 299 300
  }, {interval: 10000000} );
} catch(err) {
      console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
301 302
```

C
cff-gite 已提交
303
###   HEART_RATE<sup>9+</sup>
C
cff-gite 已提交
304 305 306 307 308 309 310 311 312 313 314 315 316

on(type: SensorId.HEART_RATE, callback: Callback&lt;HeartRateResponse&gt;,options?: Options): void

订阅心率传感器数据。

**需要权限**:ohos.permission.READ_HEALTH_DATA 

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名   | 类型                                                    | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
317
| type     | [SensorId](#sensorid9)                                  | 是   | 要订阅的心率传感器类型为HEART_RATE。                         |
C
cff-gite 已提交
318 319 320 321 322 323
| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | 是   | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 |
| options  | [Options](#options)                                     | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。            |

**示例:**

```js
C
cff-gite 已提交
324
try {
C
cff-gite 已提交
325 326
sensor.on(sensor.SensorId.HEART_RATE,function(data){
    console.info('Heart rate: ' + data.heartRate);
C
cff-gite 已提交
327 328 329 330
}, {interval: 10000000} );
} catch(err) {
      console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
331 332
```

C
cff-gite 已提交
333
###  HUMIDITY<sup>9+</sup>
C
cff-gite 已提交
334 335 336 337 338 339 340 341 342 343 344

on(type: SensorId.HUMIDITY, callback: Callback&lt;HumidityResponse&gt;,options?: Options): void

订阅湿度传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名   | 类型                                                  | 必填 | 说明                                                         |
| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
345
| type     | [SensorId](#sensorid9)                                | 是   | 要订阅的湿度传感器类型为HUMIDITY。                           |
C
cff-gite 已提交
346 347 348 349 350 351
| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | 是   | 注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 |
| options  | [Options](#options)                                   | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。            |

**示例:**

```js
C
cff-gite 已提交
352
try {
C
cff-gite 已提交
353 354
  sensor.on(sensor.SensorId.HUMIDITY,function(data){
      console.info('Humidity: ' + data.humidity);
C
cff-gite 已提交
355 356 357 358
  }, {interval: 10000000} );
} catch(err) {
      console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
359 360 361 362
```

###  LINEAR_ACCELERATION<sup>9+</sup>

C
cff-gite 已提交
363
on(type: SensorId.LINEAR_ACCELEROMETER, callback: Callback&lt;LinearAccelerometerResponse&gt;,
C
cff-gite 已提交
364 365
        options?: Options): void

C
cff-gite 已提交
366
订阅线性加速度传感器数据。
C
cff-gite 已提交
367 368 369 370 371 372 373 374 375

**需要权限**:ohos.permission.ACCELEROMETER 

**系统能力**:SystemCapability.Sensors.Sensor 

**参数:** 

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
376
| type     | [SensorId](#sensorid9)                                       | 是   | 要订阅的线性加速度传感器类型为LINEAR_ACCELEROMETER。         |
C
cff-gite 已提交
377 378 379 380 381 382
| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | 是   | 注册线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 |
| options  | [Options](#options)                                          | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。            |

**示例:**

```js
C
cff-gite 已提交
383
try {
C
cff-gite 已提交
384 385 386 387
  sensor.on(sensor.SensorId.LINEAR_ACCELEROMETER, function(data) {
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
C
cff-gite 已提交
388 389 390 391
    }, {interval: 10000000} );
} catch(err) {
      console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
392 393
```

C
cff-gite 已提交
394
###  MAGNETIC_FIELD<sup>9+</sup>
C
cff-gite 已提交
395 396 397 398 399 400 401 402 403 404 405

on(type: SensorId.MAGNETIC_FIELD, callback: Callback&lt;MagneticFieldResponse&gt;,options?: Options): void

订阅磁场传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor 

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
406
| type     | [SensorId](#sensorid9)                                       | 是   | 要订阅的磁场传感器类型为MAGNETIC_FIELD。                     |
C
cff-gite 已提交
407 408 409 410 411 412
| callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | 是   | 注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 |
| options  | [Options](#options)                                          | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。            |

**示例:**

```js
C
cff-gite 已提交
413
try {
C
cff-gite 已提交
414 415 416 417
  sensor.on(sensor.SensorId.MAGNETIC_FIELD,function(data){
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
C
cff-gite 已提交
418 419 420 421
  }, {interval: 10000000} );
} catch(err) {
      console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
422 423
```

C
cff-gite 已提交
424
### MAGNETIC_FIELD_UNCALIBRATED<sup>9+</sup>
C
cff-gite 已提交
425 426 427 428 429 430 431 432 433 434 435 436

on(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED,callback:Callback&lt;MagneticFieldUncalibratedResponse&gt;,
        options?: Options): void

订阅未校准的磁场传感器数据

**系统能力**:SystemCapability.Sensors.Sensor 

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
437
| type     | [SensorId](#sensorid9)                                       | 是   | 要订阅的未校准磁场传感器类型为MAGNETIC_FIELD_UNCALIBRATED。  |
C
cff-gite 已提交
438 439 440 441 442 443
| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | 是   | 注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 |
| options  | [Options](#options)                                          | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。            |

**示例:**

```js
C
cff-gite 已提交
444
try {
C
cff-gite 已提交
445 446 447 448 449 450 451
  sensor.on(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED,function(data){
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
      console.info('X-coordinate bias: ' + data.biasX);
      console.info('Y-coordinate bias: ' + data.biasY);
      console.info('Z-coordinate bias: ' + data.biasZ);
C
cff-gite 已提交
452 453 454 455
  }, {interval: 10000000} );
} catch(err) {
      console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
456 457
```

C
cff-gite 已提交
458
### ORIENTATION<sup>9+</sup>
C
cff-gite 已提交
459 460 461 462 463 464 465 466 467 468 469

on(type: SensorId.ORIENTATION, callback: Callback&lt;OrientationResponse&gt;,options?: Options): void

订阅定向传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor 

**参数:**

| 参数名   | 类型                                                        | 必填 | 说明                                                         |
| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
470
| type     | [SensorId](#sensorid9)                                      | 是   | 要订阅的方向传感器类型为ORIENTATION。                        |
C
cff-gite 已提交
471 472 473 474 475 476
| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | 是   | 注册方向传感器的回调函数,上报的数据类型为OrientationResponse。 |
| options  | [Options](#options)                                         | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。            |

**示例:**

```js
C
cff-gite 已提交
477
try {
C
cff-gite 已提交
478 479 480 481
  sensor.on(sensor.SensorId.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 Y axis: ' + data.gamma);
      console.info('The device rotates at an angle around the Z axis: ' + data.alpha);
C
cff-gite 已提交
482 483 484 485
  }, {interval: 10000000} );
} catch(err) {
      console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
486 487
```

C
cff-gite 已提交
488
### PEDOMETER<sup>9+</sup>
C
cff-gite 已提交
489 490 491 492 493 494 495 496 497 498 499 500 501

on(type: SensorId.PEDOMETER, callback: Callback&lt;PedometerResponse&gt;, options?: Options): void

订阅计步器传感器数据。

**需要权限**:ohos.permission.ACTIVITY_MOTION 

**系统能力**:SystemCapability.Sensors.Sensor 

**参数:**

| 参数名   | 类型                                                    | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
502
| type     | [SensorId](#sensorid9)                                  | 是   | 要订阅的计步传感器类型为PEDOMETER。                          |
C
cff-gite 已提交
503 504 505 506 507 508
| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | 是   | 注册计步传感器的回调函数,上报的数据类型为PedometerResponse。 |
| options  | [Options](#options)                                     | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。            |

**示例:**

```js
C
cff-gite 已提交
509
try {
C
cff-gite 已提交
510 511
  sensor.on(sensor.SensorId.PEDOMETER,function(data){
      console.info('Steps: ' + data.steps);
C
cff-gite 已提交
512 513 514 515
  }, {interval: 10000000} );
} catch(err) {
      console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
516 517
```

C
cff-gite 已提交
518
### PEDOMETER_DETECTION<sup>9+</sup>
C
cff-gite 已提交
519 520 521 522 523 524 525 526 527 528 529 530 531 532

on(type: SensorId.PEDOMETER_DETECTION, callback: Callback&lt;PedometerDetectionResponse&gt;,
        options?: Options): void

订阅计步器检测传感器数据。

**需要权限**:ohos.permission.ACTIVITY_MOTION 

**系统能力**:SystemCapability.Sensors.Sensor 

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
533
| type     | [SensorId](#sensorid9)                                       | 是   | 要订阅的计步检测传感器类型为PEDOMETER_DETECTION。            |
C
cff-gite 已提交
534 535 536 537 538 539
| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | 是   | 注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 |
| options  | [Options](#options)                                          | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。            |

**示例:**

```js
C
cff-gite 已提交
540
try {
C
cff-gite 已提交
541 542
  sensor.on(sensor.SensorId.PEDOMETER_DETECTION,function(data){
      console.info('Scalar data: ' + data.scalar);
C
cff-gite 已提交
543 544 545 546
  }, {interval: 10000000} );
} catch(err) {
      console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
547 548
```

C
cff-gite 已提交
549
### PROXIMITY<sup>9+</sup>
C
cff-gite 已提交
550 551 552 553 554 555 556 557 558 559 560

on(type: SensorId.PROXIMITY, callback: Callback&lt;ProximityResponse&gt;, options?: Options): void

订阅接近传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor 

**参数:**

| 参数名   | 类型                                                    | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
561
| type     | [SensorId](#sensorid9)                                  | 是   | 要订阅的接近光传感器类型为PROXIMITY。                        |
C
cff-gite 已提交
562 563 564 565 566 567
| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | 是   | 注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 |
| options  | [Options](#options)                                     | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。            |

**示例:** 

```js
C
cff-gite 已提交
568
try {
C
cff-gite 已提交
569 570
  sensor.on(sensor.SensorId.PROXIMITY,function(data){
      console.info('Distance: ' + data.distance);
C
cff-gite 已提交
571 572 573 574
  }, {interval: 10000000} );
} catch(err) {
      console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
575 576
```

C
cff-gite 已提交
577
### ROTATION_VECTOR<sup>9+</sup>
C
cff-gite 已提交
578 579 580 581 582 583 584 585 586 587 588 589

on(type: SensorId.ROTATION_VECTOR, callback: Callback&lt;RotationVectorResponse&gt;,
        options?: Options): void

订阅旋转矢量传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor 

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
590
| type     | [SensorId](#sensorid9)                                       | 是   | 要订阅的旋转矢量传感器类型为ROTATION_VECTOR。                |
C
cff-gite 已提交
591 592 593 594 595 596
| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | 是   | 注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 |
| options  | [Options](#options)                                          | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。            |

**示例:** 

```js
C
cff-gite 已提交
597
try {
C
cff-gite 已提交
598 599 600 601 602
  sensor.on(sensor.SensorId.ROTATION_VECTOR,function(data){
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
      console.info('Scalar quantity: ' + data.w);
C
cff-gite 已提交
603 604 605 606
  }, {interval: 10000000} );
} catch(err) {
      console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
607 608
```

C
cff-gite 已提交
609
### SIGNIFICANT_MOTION<sup>9+</sup>
C
cff-gite 已提交
610 611 612 613 614 615 616 617 618 619 620 621

on(type: SensorId.SIGNIFICANT_MOTION, callback: Callback&lt;SignificantMotionResponse&gt;,
        options?: Options): void

订阅重要的运动传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
622
| type     | [SensorId](#sensorid9)                                       | 是   | 要订阅的大幅动作传感器类型为SIGNIFICANT_MOTION。             |
C
cff-gite 已提交
623 624 625 626 627 628
| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | 是   | 注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 |
| options  | [Options](#options)                                          | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。            |

**示例:** 

```js
C
cff-gite 已提交
629
try {
C
cff-gite 已提交
630 631
  sensor.on(sensor.SensorId.SIGNIFICANT_MOTION,function(data){
      console.info('Scalar data: ' + data.scalar);
C
cff-gite 已提交
632 633 634 635
  }, {interval: 10000000} );
} catch(err) {
      console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
636 637
```

C
cff-gite 已提交
638
###  WEAR_DETECTION<sup>9+</sup>
C
cff-gite 已提交
639 640 641 642 643 644 645 646 647 648 649 650

on(type: SensorId.WEAR_DETECTION, callback: Callback&lt;WearDetectionResponse&gt;,
        options?: Options): void

订阅磨损检测传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
651
| type     | [SensorId](#sensorid9)                                       | 是   | 要订阅的佩戴检测传感器类型为WEAR_DETECTION。                 |
C
cff-gite 已提交
652 653 654 655 656 657
| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | 是   | 注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 |
| options  | [Options](#options)                                          | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。            |

**示例:** 

```js
C
cff-gite 已提交
658
try {
C
cff-gite 已提交
659 660
  sensor.on(sensor.SensorId.WEAR_DETECTION,function(data){
      console.info('Wear status: ' + data.value);
C
cff-gite 已提交
661 662 663 664
  }, {interval: 10000000} );
} catch(err) {
      console.info('on fail, errCode: ' + err.code + ' ,msg: ' + err.message);
}
C
cff-gite 已提交
665 666
```

C
cff-gite 已提交
667
## sensor.once<sup>9+</sup>
C
cff-gite 已提交
668

C
cff-gite 已提交
669
### ACCELEROMETER<sup>9+</sup>
C
cff-gite 已提交
670 671 672 673 674 675 676 677 678 679 680 681 682

once(type: SensorId.ACCELEROMETER, callback: Callback&lt;AccelerometerResponse&gt;): void

订阅一次加速度计传感器数据。

**需要权限**:ohos.permission.ACCELEROMETER 

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
683
| type     | [SensorId](#sensorid9)                                       | 是   | 加速度传感器类型为ACCELEROMETER。                            |
C
cff-gite 已提交
684 685 686 687 688
| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | 是   | 注册一次加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 |

**示例:** 

```js
C
cff-gite 已提交
689
try {
C
cff-gite 已提交
690 691 692 693 694 695
  sensor.once(sensor.SensorId.ACCELEROMETER,function(data){
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
    }
  );
C
cff-gite 已提交
696
} catch(err) {
C
cff-gite 已提交
697
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
698
}
C
cff-gite 已提交
699 700
```

C
cff-gite 已提交
701
### ACCELEROMETER_UNCALIBRATED<sup>9+</sup>
C
cff-gite 已提交
702 703 704 705 706 707 708 709 710 711 712 713 714

once(type: SensorId.ACCELEROMETER_UNCALIBRATED,callback:Callback&lt;AccelerometerUncalibratedResponse&gt;): void

订阅一次未校准的加速度计传感器数据。

**需要权限**:ohos.permission.ACCELEROMETER 

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
715
| type     | [SensorId](#sensorid9)                                       | 是   | 未校准加速度传感器类型为ACCELEROMETER_UNCALIBRATED。         |
C
cff-gite 已提交
716 717 718 719 720
| callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | 是   | 注册一次未校准加速度传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 |

**示例:** 

```js
C
cff-gite 已提交
721
try {
C
cff-gite 已提交
722 723 724 725 726 727 728 729 730
  sensor.once(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, function(data) {
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
      console.info('X-coordinate bias: ' + data.biasX);
      console.info('Y-coordinate bias: ' + data.biasY);
      console.info('Z-coordinate bias: ' + data.biasZ);
    }
  );
C
cff-gite 已提交
731
} catch(err) {
C
cff-gite 已提交
732
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
733
}
C
cff-gite 已提交
734 735
```

C
cff-gite 已提交
736
### AMBIENT_LIGHT<sup>9+</sup>
C
cff-gite 已提交
737 738 739 740 741 742 743 744 745 746 747

once(type: SensorId.AMBIENT_LIGHT, callback: Callback&lt;LightResponse&gt;): void

订阅环境光传感器数据一次。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名   | 类型                                            | 必填 | 说明                                                         |
| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
748
| type     | [SensorId](#sensorid9)                          | 是   | 环境光传感器类型为AMBIENT_LIGHT。                            |
C
cff-gite 已提交
749 750 751 752 753
| callback | Callback&lt;[LightResponse](#lightresponse)&gt; | 是   | 注册一次环境光传感器的回调函数,上报的数据类型为LightResponse。 |

**示例:** 

```js
C
cff-gite 已提交
754 755 756 757 758 759
try {
   sensor.once(sensor.SensorId.AMBIENT_LIGHT, function(data) {
       console.info('Illumination: ' + data.intensity);
     }
   );
} catch(err) {
C
cff-gite 已提交
760
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
761
}
C
cff-gite 已提交
762 763
```

C
cff-gite 已提交
764
### AMBIENT_TEMPERATURE<sup>9+</sup>
C
cff-gite 已提交
765 766 767 768 769 770 771 772 773 774

once(type: SensorId.AMBIENT_TEMPERATURE, callback: Callback&lt;AmbientTemperatureResponse&gt;): void

一次订阅环境温度传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor
**参数:** 

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
775
| type     | [SensorId](#sensorid9)                                       | 是   | 环境温度传感器类型为AMBIENT_TEMPERATURE。                    |
C
cff-gite 已提交
776 777 778 779 780
| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | 是   | 注册一次环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 |

**示例:** 

```js
C
cff-gite 已提交
781 782 783 784 785 786
try {
   sensor.once(sensor.SensorId.AMBIENT_TEMPERATURE, function(data) {
       console.info('Temperature: ' + data.temperature);
     }
   );
} catch(err) {
C
cff-gite 已提交
787
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
788
}
C
cff-gite 已提交
789 790
```

C
cff-gite 已提交
791
### BAROMETER<sup>9+</sup>
C
cff-gite 已提交
792 793 794 795 796 797 798 799 800 801

once(type: SensorId.BAROMETER, callback: Callback&lt;BarometerResponse&gt;): void

订阅一次气压计传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor
**参数:**

| 参数名   | 类型                                                    | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
802
| type     | [SensorId](#sensorid9)                                  | 是   | 气压计传感器类型为BAROMETER。                                |
C
cff-gite 已提交
803 804 805 806 807
| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | 是   | 注册一次气压计传感器的回调函数,上报的数据类型为BarometerResponse。 |

**示例:** 

```js
C
cff-gite 已提交
808 809 810 811 812 813
try {
   sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) {
       console.info('Atmospheric pressure: ' + data.pressure);
     }
   );
} catch(err) {
C
cff-gite 已提交
814
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
815
}
C
cff-gite 已提交
816 817
```

C
cff-gite 已提交
818
### GRAVITY<sup>9+</sup>
C
cff-gite 已提交
819 820 821 822 823 824 825 826 827 828 829

once(type: SensorId.GRAVITY, callback: Callback&lt;GravityResponse&gt;): void

订阅一次重力传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                | 必填 | 说明                                                         |
| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
830
| type     | [SensorId](#sensorid9)                              | 是   | 重力传感器类型为GRAVITY。                                    |
C
cff-gite 已提交
831 832 833 834 835
| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | 是   | 注册一次重力传感器的回调函数,上报的数据类型为GravityResponse。 |

**示例:**

```js
C
cff-gite 已提交
836 837 838 839 840 841 842 843
try {
   sensor.once(sensor.SensorId.GRAVITY, function(data) {
       console.info('X-coordinate component: ' + data.x);
       console.info('Y-coordinate component: ' + data.y);
       console.info('Z-coordinate component: ' + data.z);
     }
   );
} catch(err) {
C
cff-gite 已提交
844
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
845
}
C
cff-gite 已提交
846 847
```

C
cff-gite 已提交
848
### GYROSCOPE<sup>9+</sup>
C
cff-gite 已提交
849 850 851 852 853 854 855 856 857 858 859 860 861

once(type: SensorId.GYROSCOPE, callback: Callback&lt;GyroscopeResponse&gt;): void

订阅一次陀螺仪传感器数据。

**需要权限**:ohos.permission.GYROSCOPE 

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名   | 类型                                                    | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
862
| type     | [SensorId](#sensorid9)                                  | 是   | 陀螺仪传感器类型为GYROSCOPE。                                |
C
cff-gite 已提交
863 864 865 866 867
| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | 是   | 注册一次陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 |

**示例:**

```js
C
cff-gite 已提交
868 869 870 871 872 873 874 875
try {
   sensor.once(sensor.SensorId.GYROSCOPE, function(data) {
       console.info('X-coordinate component: ' + data.x);
       console.info('Y-coordinate component: ' + data.y);
       console.info('Z-coordinate component: ' + data.z);
     }
   );
} catch(err) {
C
cff-gite 已提交
876
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
877
}
C
cff-gite 已提交
878 879
```

C
cff-gite 已提交
880
### GYROSCOPE_UNCALIBRATED<sup>9+</sup>
C
cff-gite 已提交
881 882 883 884 885 886 887 888 889 890 891 892 893 894 895

once(type: 

SensorId.GYROSCOPE_UNCALIBRATED,callback:Callback&lt;GyroscopeUncalibratedResponse&gt;): void

一次订阅未校准的陀螺仪传感器数据。

**需要权限**:ohos.permission.GYROSCOPE 

**系统能力**:SystemCapability.Sensors.Sensor 

**参数:** 

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
896
| type     | [SensorId](#sensorid9)                                       | 是   | 未校准陀螺仪传感器类型为GYROSCOPE_UNCALIBRATED。             |
C
cff-gite 已提交
897 898 899 900 901
| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | 是   | 注册一次未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 |

**示例:**

```js
C
cff-gite 已提交
902 903 904 905 906 907 908 909 910 911 912
try {
    sensor.once(sensor.SensorId.GYROSCOPE_UNCALIBRATED, function(data) {
        console.info('X-coordinate component: ' + data.x);
        console.info('Y-coordinate component: ' + data.y);
        console.info('Z-coordinate component: ' + data.z);
        console.info('X-coordinate bias: ' + data.biasX);
        console.info('Y-coordinate bias: ' + data.biasY);
        console.info('Z-coordinate bias: ' + data.biasZ);
      }
    );
} catch(err) {
C
cff-gite 已提交
913
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
914
}
C
cff-gite 已提交
915 916
```

C
cff-gite 已提交
917
### HALL<sup>9+</sup>
C
cff-gite 已提交
918 919 920 921 922 923 924 925 926 927 928

once(type: SensorId.HALL, callback: Callback&lt;HallResponse&gt;): void

订阅一次霍尔传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor 

**参数:** 

| 参数名   | 类型                                          | 必填 | 说明                                                         |
| -------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
929
| type     | [SensorId](#sensorid9)                        | 是   | 霍尔传感器类型为HALL。                                       |
C
cff-gite 已提交
930 931 932 933 934
| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | 是   | 注册一次霍尔传感器的回调函数,上报的数据类型为HallResponse。 |

**示例:**

```js
C
cff-gite 已提交
935 936 937 938 939 940
try {
    sensor.once(sensor.SensorId.HALL, function(data) {
        console.info('Status: ' + data.status);
      }
    );
} catch(err) {
C
cff-gite 已提交
941
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
942
}
C
cff-gite 已提交
943 944
```

C
cff-gite 已提交
945
### HEART_RATE<sup>9+</sup>
C
cff-gite 已提交
946 947 948 949 950 951 952 953 954 955 956 957 958

once(type: SensorId.HEART_RATE, callback: Callback&lt;HeartRateResponse&gt;): void

订阅一次心率传感器数据。

**需要权限**: ohos.permission.READ_HEALTH_DATA 

**系统能力**:SystemCapability.Sensors.Sensor 

**参数:** 

| 参数名   | 类型                                                    | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
959
| type     | [SensorId](#sensorid9)                                  | 是   | 心率传感器类型为HEART_RATE。                                 |
C
cff-gite 已提交
960 961 962 963 964
| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | 是   | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 |

**示例:**

```js
C
cff-gite 已提交
965 966 967 968 969 970
try {
    sensor.once(sensor.SensorId.HEART_BEAT_RATE, function(data) {
        console.info('Heart rate: ' + data.heartRate);
      }
    );
} catch(err) {
C
cff-gite 已提交
971
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
972
}
C
cff-gite 已提交
973 974 975 976 977 978 979 980 981 982 983 984 985 986
```

### HUMIDITY<sup>9+</sup>

once(type: SensorId.HUMIDITY, callback: Callback&lt;HumidityResponse&gt;): void

订阅一次湿度传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor 

**参数:** 

| 参数名   | 类型                                                  | 必填 | 说明                                                         |
| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
987
| type     | [SensorId](#sensorid9)                                | 是   | 湿度传感器类型为HUMIDITY。                                   |
C
cff-gite 已提交
988 989 990 991 992
| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | 是   | 注册一次湿度传感器的回调函数,上报的数据类型为HumidityResponse。 |

**示例:**

```js
C
cff-gite 已提交
993 994 995 996 997 998
try {
    sensor.once(sensor.SensorId.HUMIDITY, function(data) {
        console.info('Humidity: ' + data.humidity);
      }
    );
} catch(err) {
C
cff-gite 已提交
999
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1000
}
C
cff-gite 已提交
1001 1002 1003 1004
```

### LINEAR_ACCELERATION<sup>9+</sup>

C
cff-gite 已提交
1005
once(type: SensorId.LINEAR_ACCELEROMETER, callback: Callback&lt;LinearAccelerometerResponse&gt;): void
C
cff-gite 已提交
1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016

订阅一次线性加速度传感器数据。

**需要权限**:ohos.permission.ACCELEROMETER 

**系统能力**:SystemCapability.Sensors.Sensor 

**参数:** 

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1017
| type     | [SensorId](#sensorid9)                                       | 是   | 线性加速度传感器类型为LINEAR_ACCELEROMETER。                 |
C
cff-gite 已提交
1018 1019 1020 1021 1022
| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | 是   | 注册一次线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 |

**示例:**

```js
C
cff-gite 已提交
1023 1024 1025 1026 1027 1028 1029 1030
try {
    sensor.once(sensor.SensorId.LINEAR_ACCELEROMETER, function(data) {
        console.info('X-coordinate component: ' + data.x);
        console.info('Y-coordinate component: ' + data.y);
        console.info('Z-coordinate component: ' + data.z);
      }
    );
} catch(err) {
C
cff-gite 已提交
1031
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1032
}
C
cff-gite 已提交
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046
```

### MAGNETIC_FIELD<sup>9+</sup>

once(type: SensorId.MAGNETIC_FIELD, callback: Callback&lt;MagneticFieldResponse&gt;): void

订阅一次磁场传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1047
| type     | [SensorId](#sensorid9)                                       | 是   | 磁场传感器类型为MAGNETIC_FIELD。                             |
C
cff-gite 已提交
1048 1049 1050 1051 1052
| callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | 是   | 注册一次磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 |

**示例:**

```js
C
cff-gite 已提交
1053 1054 1055 1056 1057 1058 1059 1060
try {
   sensor.once(sensor.SensorId.MAGNETIC_FIELD, function(data) {
       console.info('X-coordinate component: ' + data.x);
       console.info('Y-coordinate component: ' + data.y);
       console.info('Z-coordinate component: ' + data.z);
     }
   );
} catch(err) {
C
cff-gite 已提交
1061
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1062
}
C
cff-gite 已提交
1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076
```

### MAGNETIC_FIELD_UNCALIBRATED<sup>9+</sup>

once(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED,callback:Callback&lt;MagneticFieldUncalibratedResponse&gt;): void

订阅一次未经校准的磁场传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1077
| type     | [SensorId](#sensorid9)                                       | 是   | 未校准磁场传感器类型为MAGNETIC_FIELD_UNCALIBRATED。          |
C
cff-gite 已提交
1078 1079 1080 1081 1082
| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | 是   | 注册一次未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 |

**示例:**

```js
C
cff-gite 已提交
1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093
try {
    sensor.once(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, function(data) {
        console.info('X-coordinate component: ' + data.x);
        console.info('Y-coordinate component: ' + data.y);
        console.info('Z-coordinate component: ' + data.z);
        console.info('X-coordinate bias: ' + data.biasX);
        console.info('Y-coordinate bias: ' + data.biasY);
        console.info('Z-coordinate bias: ' + data.biasZ);
      }
    );
} catch(err) {
C
cff-gite 已提交
1094
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1095
}
C
cff-gite 已提交
1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109
```

### ORIENTATION<sup>9+</sup>

once(type: SensorId.ORIENTATION, callback: Callback&lt;OrientationResponse&gt;): void

订阅一次定向传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名   | 类型                                                        | 必填 | 说明                                                         |
| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1110
| type     | [SensorId](#sensorid9)                                      | 是   | 方向传感器类型为ORIENTATION。                                |
C
cff-gite 已提交
1111 1112 1113 1114 1115
| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | 是   | 注册一次方向传感器的回调函数,上报的数据类型为OrientationResponse。 |

**示例:**

```js
C
cff-gite 已提交
1116 1117 1118 1119 1120 1121 1122 1123
try {
   sensor.once(sensor.SensorId.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 Y axis: ' + data.gamma);
       console.info('The device rotates at an angle around the Z axis: ' + data.alpha);
     }
   );
} catch(err) {
C
cff-gite 已提交
1124
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1125
}
C
cff-gite 已提交
1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141
```

### PEDOMETER<sup>9+</sup>

once(type: SensorId.PEDOMETER, callback: Callback&lt;PedometerResponse&gt;): void

订阅一次计步器传感器数据。

**需要权限**:ohos.permission.ACTIVITY_MOTION 

**系统能力**:SystemCapability.Sensors.Sensor 

**参数:**

| 参数名   | 类型                                                    | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1142
| type     | [SensorId](#sensorid9)                                  | 是   | 计步传感器类型为PEDOMETER。                                  |
C
cff-gite 已提交
1143 1144 1145 1146 1147
| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | 是   | 注册一次计步传感器的回调函数,上报的数据类型为PedometerResponse。 |

**示例:**

```js
C
cff-gite 已提交
1148 1149 1150 1151 1152 1153
try {
    sensor.once(sensor.SensorId.PEDOMETER, function(data) {
        console.info('Steps: ' + data.steps);
      }
    );
} catch(err) {
C
cff-gite 已提交
1154
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1155
}
C
cff-gite 已提交
1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171
```

### PEDOMETER_DETECTION<sup>9+</sup>

once(type: SensorId.PEDOMETER_DETECTION, callback: Callback&lt;PedometerDetectionResponse&gt;): void

订阅一次计步器检测传感器数据。

**需要权限**:ohos.permission.ACTIVITY_MOTION 

**系统能力**:SystemCapability.Sensors.Sensor 

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1172
| type     | [SensorId](#sensorid9)                                       | 是   | 计步检测传感器类型为PEDOMETER_DETECTION。                    |
C
cff-gite 已提交
1173 1174 1175 1176 1177
| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | 是   | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 |

**示例:**

```js
C
cff-gite 已提交
1178 1179 1180 1181 1182 1183
try {
    sensor.once(sensor.SensorId.PEDOMETER_DETECTION, function(data) {
        console.info('Scalar data: ' + data.scalar);
      }
    );
} catch(err) {
C
cff-gite 已提交
1184
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1185
}
C
cff-gite 已提交
1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199
```

### PROXIMITY<sup>9+</sup>

once(type: SensorId.PROXIMITY, callback: Callback&lt;ProximityResponse&gt;): void

订阅一次接近传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                    | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1200
| type     | [SensorId](#sensorid9)                                  | 是   | 接近光传感器类型为PROXIMITY。                                |
C
cff-gite 已提交
1201 1202 1203 1204 1205
| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | 是   | 注册一次接近光传感器的回调函数,上报的数据类型为ProximityResponse。 |

**示例:**

```js
C
cff-gite 已提交
1206 1207 1208 1209 1210 1211
try {
   sensor.once(sensor.SensorId.PROXIMITY, function(data) {
       console.info('Distance: ' + data.distance);
     }
   );
} catch(err) {
C
cff-gite 已提交
1212
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1213
}
C
cff-gite 已提交
1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227
```

### ROTATION_VECTOR<sup>9+</sup>

once(type: SensorId.ROTATION_VECTOR, callback: Callback&lt;RotationVectorResponse&gt;): void

订阅一次旋转矢量传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1228
| type     | [SensorId](#sensorid9)                                       | 是   | 旋转矢量传感器类型为ROTATION_VECTOR。                        |
C
cff-gite 已提交
1229 1230 1231 1232 1233
| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | 是   | 注册一次旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 |

**示例:** 

```js
C
cff-gite 已提交
1234 1235 1236 1237 1238 1239 1240 1241 1242
try {
   sensor.once(sensor.SensorId.ROTATION_VECTOR, function(data) {
       console.info('X-coordinate component: ' + data.x);
       console.info('Y-coordinate component: ' + data.y);
       console.info('Z-coordinate component: ' + data.z);
       console.info('Scalar quantity: ' + data.w);
     }
   );
} catch(err) {
C
cff-gite 已提交
1243
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1244
}
C
cff-gite 已提交
1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258
```

### SIGNIFICANT_MOTION<sup>9+</sup>

once(type: SensorId.SIGNIFICANT_MOTION, callback: Callback&lt;SignificantMotionResponse&gt;): void

订阅一次重要的运动传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1259
| type     | [SensorId](#sensorid9)                                       | 是   | 有效运动传感器类型为SIGNIFICANT_MOTION。                     |
C
cff-gite 已提交
1260 1261 1262 1263 1264
| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | 是   | 注册一次有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 |

**示例:** 

```js
C
cff-gite 已提交
1265 1266 1267 1268 1269 1270
try {
   sensor.once(sensor.SensorId.SIGNIFICANT_MOTION, function(data) {
       console.info('Scalar data: ' + data.scalar);
     }
   );
} catch(err) {
C
cff-gite 已提交
1271
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1272
}
C
cff-gite 已提交
1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286
```

### WEAR_DETECTION<sup>9+</sup>

once(type: SensorId.WEAR_DETECTION, callback: Callback&lt;WearDetectionResponse&gt;): void

订阅一次磨损检测传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1287
| type     | [SensorId](#sensorid9)                                       | 是   | 佩戴检测传感器类型为WEAR_DETECTION。                         |
C
cff-gite 已提交
1288 1289 1290 1291 1292
| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | 是   | 注册一次穿戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 |

**示例:** 

```js
C
cff-gite 已提交
1293 1294 1295 1296 1297 1298
try {
   sensor.once(sensor.SensorId.WEAR_DETECTION, function(data) {
       console.info("Wear status: "+ data.value);
     }
   );
} catch(err) {
C
cff-gite 已提交
1299
      console.info('once fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1300
}
C
cff-gite 已提交
1301 1302
```

C
cff-gite 已提交
1303
## sensor.off<sup>9+</sup>
C
cff-gite 已提交
1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318

### ACCELEROMETER<sup>9+</sup> 

off(type: SensorId.ACCELEROMETER, callback?: Callback&lt;AccelerometerResponse&gt;): void

取消订阅加速度计传感器数据。

**需要权限**:ohos.permission.ACCELEROMETER 

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1319
| type     | [SensorId](#sensorid9)                                       | 是   | 要取消订阅的加速度传感器类型为ACCELEROMETER。                |
C
cff-gite 已提交
1320 1321 1322 1323 1324
| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | 是   | 取消注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 |

**示例:**

```js
C
cff-gite 已提交
1325 1326 1327 1328 1329 1330 1331 1332
try {
    function callback(data) {
        console.info('x-coordinate component: ' + data.x);
        console.info('Y-coordinate component: ' + data.y);
        console.info('Z-coordinate component: ' + data.z);
    }
    sensor.off(sensor.SensorId.ACCELEROMETER, callback);
} catch(err) {
C
cff-gite 已提交
1333
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350
}
```

### ACCELEROMETER_UNCALIBRATED<sup>9+</sup>  

off(type: SensorId.ACCELEROMETER_UNCALIBRATED,callback?:Callback&lt;AccelerometerUncalibratedResponse&gt;): void

取消订阅未校准的加速度计传感器数据。

**需要权限**:ohos.permission.ACCELEROMETER 

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1351
| type     | [SensorId](#sensorid9)                                       | 是   | 要取消订阅的未校准加速度计传感器类型为ACCELEROMETER_UNCALIBRATED。 |
C
cff-gite 已提交
1352 1353 1354 1355 1356
| callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | 是   | 取消注册未校准加速度计传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 |

**示例:**

```js
C
cff-gite 已提交
1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367
try {
    function callback(data) {
        console.info('X-coordinate component: ' + data.x);
        console.info('Y-coordinate component: ' + data.y);
        console.info('Z-coordinate component: ' + data.z);
        console.info('X-coordinate bias: ' + data.biasX);
        console.info('Y-coordinate bias: ' + data.biasY);
        console.info('Z-coordinate bias: ' + data.biasZ);
    }
    sensor.off(sensor.SensorId.ACCELEROMETER_UNCALIBRATED, callback);
} catch(err) {
C
cff-gite 已提交
1368
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383
}
```

### AMBIENT_LIGHT<sup>9+</sup> 

off(type: SensorId.AMBIENT_LIGHT, callback?: Callback&lt;LightResponse&gt;): void

取消订阅环境光传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                            | 必填 | 说明                                                         |
| -------- | ----------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1384
| type     | [SensorId](#sensorid9)                          | 是   | 要取消订阅的环境光传感器类型为AMBIENT_LIGHT。                |
C
cff-gite 已提交
1385 1386 1387 1388 1389
| callback | Callback&lt;[LightResponse](#lightresponse)&gt; | 是   | 取消注册环境光传感器的回调函数,上报的数据类型为LightResponse。 |

**示例:**

```js
C
cff-gite 已提交
1390 1391 1392 1393 1394 1395
try {
    function callback(data) {
        console.info('Illumination: ' + data.intensity);
    }
    sensor.off(sensor.SensorId.AMBIENT_LIGHT, callback);
} catch(err) {
C
cff-gite 已提交
1396
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411
}
```

### AMBIENT_TEMPERATURE<sup>9+</sup> 

off(type: SensorId.AMBIENT_TEMPERATURE, callback?: Callback&lt;AmbientTemperatureResponse&gt;): void

取消订阅环境温度传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1412
| type     | [SensorId](#sensorid9)                                       | 是   | 要取消订阅的环境温度传感器类型为AMBIENT_TEMPERATURE。        |
C
cff-gite 已提交
1413 1414 1415 1416 1417
| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | 是   | 取消注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 |

**示例:**

```js
C
cff-gite 已提交
1418 1419 1420 1421 1422 1423
try {
    function callback(data) {
        console.info('Temperature: ' + data.temperature);
    }
    sensor.off( sensor.SensorId.AMBIENT_TEMPERATURE, callback);
} catch(err) {
C
cff-gite 已提交
1424
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439
}
```

### BAROMETER<sup>9+</sup>  

off(type: SensorId.BAROMETER, callback?: Callback&lt;BarometerResponse&gt;): void

取消订阅气压计传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                    | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1440
| type     | [SensorId](#sensorid9)                                  | 是   | 要取消订阅的气压计传感器类型为BAROMETER。                    |
C
cff-gite 已提交
1441 1442 1443 1444 1445
| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | 是   | 取消注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 |

**示例:**

```js
C
cff-gite 已提交
1446 1447 1448 1449 1450 1451
try {
    function callback(data) {
        console.info('Atmospheric pressure: ' + data.pressure);
    }
    sensor.off(sensor.SensorId.BAROMETER, callback);
} catch(err) {
C
cff-gite 已提交
1452
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467
}
```

### GRAVITY<sup>9+</sup> 

off(type: SensorId.GRAVITY, callback?: Callback&lt;GravityResponse&gt;): void

取消订阅重力传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名   | 类型                                                | 必填 | 说明                                                         |
| -------- | --------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1468
| type     | [SensorId](#sensorid9)                              | 是   | 要取消订阅的重力传感器类型为GRAVITY。                        |
C
cff-gite 已提交
1469 1470 1471 1472 1473
| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | 是   | 取消注册注册重力传感器的回调函数,上报的数据类型为GravityResponse。 |

**示例:**

```js
C
cff-gite 已提交
1474 1475 1476 1477 1478 1479 1480 1481
try {
    function callback(data) {
        console.info('X-coordinate component: ' + data.x);
        console.info('Y-coordinate component: ' + data.y);
        console.info('Z-coordinate component: ' + data.z);
    }
    sensor.off( sensor.SensorId.GRAVITY, callback);
} catch(err) {
C
cff-gite 已提交
1482
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499
}
```

### GYROSCOPE<sup>9+</sup> 

off(type: SensorId.GYROSCOPE, callback?: Callback&lt;GyroscopeResponse&gt;): void

取消订阅陀螺仪传感器数据。

**需要权限**:ohos.permission.GYROSCOPE 

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                    | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1500
| type     | [SensorId](#sensorid9)                                  | 是   | 要取消订阅的陀螺仪传感器类型为GYROSCOPE。                    |
C
cff-gite 已提交
1501 1502 1503 1504 1505
| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | 是   | 取消注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 |

**示例:**

```js
C
cff-gite 已提交
1506 1507 1508 1509 1510 1511 1512 1513
try {
    function callback(data) {
        console.info('X-coordinate component: ' + data.x);
        console.info('Y-coordinate component: ' + data.y);
        console.info('Z-coordinate component: ' + data.z);
    }
    sensor.off(sensor.SensorId.GYROSCOPE, callback);
} catch(err) {
C
cff-gite 已提交
1514
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531
}
```

### GYROSCOPE_UNCALIBRATED<sup>9+</sup> 

off(type: SensorId.GYROSCOPE_UNCALIBRATED, callback?:Callback&lt;GyroscopeUncalibratedResponse&gt;): void

 取消订阅未校准的陀螺仪传感器数据。

**需要权限**:ohos.permission.GYROSCOPE

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1532
| type     | [SensorId](#sensorid9)                                       | 是   | 要取消订阅的未校准陀螺仪传感器类型为GYROSCOPE_UNCALIBRATED。 |
C
cff-gite 已提交
1533 1534 1535 1536 1537
| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | 是   | 取消注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 |

**示例:**

```js
C
cff-gite 已提交
1538 1539 1540 1541 1542 1543 1544 1545
try {
    function callback(data) {
        console.info('X-coordinate component: ' + data.x);
        console.info('Y-coordinate component: ' + data.y);
        console.info('Z-coordinate component: ' + data.z);
    }
    sensor.off(sensor.SensorId.GYROSCOPE_UNCALIBRATED, callback);
} catch(err) {
C
cff-gite 已提交
1546
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561
}
```

### HALL<sup>9+</sup> 

off(type: SensorId.HALL, callback?: Callback&lt;HallResponse&gt;): void

取消订阅霍尔传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                          | 必填 | 说明                                                         |
| -------- | --------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1562
| type     | [SensorId](#sensorid9)                        | 是   | 要取消订阅的霍尔传感器类型为HALL。                           |
C
cff-gite 已提交
1563 1564 1565 1566 1567
| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | 是   | 取消注册霍尔传感器的回调函数,上报的数据类型为&nbsp;HallResponse。 |

**示例:**

```js
C
cff-gite 已提交
1568 1569 1570 1571 1572 1573
try {
    function callback(data) {
        console.info('Status: ' + data.status);
    }
    sensor.off(sensor.SensorId.HALL, callback);
} catch(err) {
C
cff-gite 已提交
1574
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591
}
```

### HEART_RATE<sup>9+</sup> 

off(type: SensorId.HEART_RATE, callback?: Callback&lt;HeartRateResponse&gt;): void

取消订阅心率传感器数据。

**需要权限**:ohos.permission.READ_HEALTH_DATA 

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                    | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1592
| type     | [SensorId](#sensorid9)                                  | 是   | 要取消订阅的心率传感器类型为HEART_RATE。                     |
C
cff-gite 已提交
1593 1594 1595 1596 1597
| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | 是   | 取消注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 |

**示例:**

```js
C
cff-gite 已提交
1598 1599 1600 1601 1602 1603
try {
    function callback(data) {
        console.info("Heart rate: " + data.heartRate);
    }
    sensor.off(sensor.SensorId.HEART_RATE, callback);
} catch(err) {
C
cff-gite 已提交
1604
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619
}
```

### HUMIDITY<sup>9+</sup> 

off(type: SensorId.HUMIDITY, callback?: Callback&lt;HumidityResponse&gt;): void

取消订阅湿度传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                  | 必填 | 说明                                                         |
| -------- | ----------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1620
| type     | [SensorId](#sensorid9)                                | 是   | 要取消订阅的湿度传感器类型为HUMIDITY。                       |
C
cff-gite 已提交
1621 1622 1623 1624 1625
| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | 是   | 取消注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 |

**示例:**

```js
C
cff-gite 已提交
1626 1627 1628 1629 1630 1631
try {
    function callback(data) {
        console.info('Humidity: ' + data.humidity);
    }
    sensor.off(sensor.SensorId.HUMIDITY, callback);
} catch(err) {
C
cff-gite 已提交
1632
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649
}
```

### LINEAR_ACCELEROMETER<sup>9+</sup> 

off(type: SensorId.LINEAR_ACCELEROMETER, callback?: Callback&lt;LinearAccelerometerResponse&gt;): void

取消订阅线性加速度传感器数据。

**需要权限**:ohos.permission.ACCELEROMETER 

**系统能力**:SystemCapability.Sensors.Sensor 

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1650
| type     | [SensorId](#sensorid9)                                       | 是   | 要取消订阅的线性加速度传感器类型为LINEAR_ACCELERATION。      |
C
cff-gite 已提交
1651 1652 1653 1654 1655
| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | 是   | 取消注册性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 |

**示例:**

```js
C
cff-gite 已提交
1656 1657 1658 1659 1660 1661 1662 1663
try {
    function callback(data) {
        console.info('X-coordinate component: ' + data.x);
        console.info('Y-coordinate component: ' + data.y);
        console.info('Z-coordinate component: ' + data.z);
    }
    sensor.off(sensor.SensorId.LINEAR_ACCELEROMETER, callback);
} catch(err) {
C
cff-gite 已提交
1664
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679
}
```

### MAGNETIC_FIELD<sup>9+</sup> 

off(type: SensorId.MAGNETIC_FIELD, callback?: Callback&lt;MagneticFieldResponse&gt;): void

取消订阅磁场传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor 

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1680
| type     | [SensorId](#sensorid9)                                       | 是   | 要取消订阅的磁场传感器类型为MAGNETIC_FIELD。                 |
C
cff-gite 已提交
1681 1682 1683 1684 1685
| callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | 是   | 取消注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 |

**示例:**

```js
C
cff-gite 已提交
1686 1687 1688 1689 1690 1691 1692 1693
try {
    function callback(data) {
        console.info('X-coordinate component: ' + data.x);
        console.info('Y-coordinate component: ' + data.y);
        console.info('Z-coordinate component: ' + data.z);
    }
    sensor.off(sensor.SensorId.MAGNETIC_FIELD, callback);
} catch(err) {
C
cff-gite 已提交
1694
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709
}
```

### MAGNETIC_FIELD_UNCALIBRATED<sup>9+</sup> 

off(type: SensorId.MAGNETIC_FIELD_UNCALIBRATED,callback?:Callback&lt;MagneticFieldUncalibratedResponse&gt;): void

取消订阅未校准的磁场传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor 

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1710
| type     | [SensorId](#sensorid9)                                       | 是   | 要取消订阅的未校准磁场传感器类型为MAGNETIC_FIELD_UNCALIBRATED。 |
C
cff-gite 已提交
1711 1712 1713 1714 1715
| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | 是   | 取消注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 |

**示例:**

```js
C
cff-gite 已提交
1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726
try {
    function callback(data) {
        console.info('X-coordinate component: ' + data.x);
        console.info('Y-coordinate component: ' + data.y);
        console.info('Z-coordinate component: ' + data.z);
        console.info('X-coordinate bias: ' + data.biasX);
        console.info('Y-coordinate bias: ' + data.biasY);
        console.info('Z-coordinate bias: ' + data.biasZ);
    }
    sensor.off(sensor.SensorId.MAGNETIC_FIELD_UNCALIBRATED, callback);
} catch(err) {
C
cff-gite 已提交
1727
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742
}
```

### ORIENTATION<sup>9+</sup> 

off(type: SensorId.ORIENTATION, callback?: Callback&lt;OrientationResponse&gt;): void

取消订阅方向传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                        | 必填 | 说明                                                         |
| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1743
| type     | [SensorId](#sensorid9)                                      | 是   | 要取消订阅的方向传感器类型为ORIENTATION。                    |
C
cff-gite 已提交
1744 1745 1746 1747 1748
| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | 是   | 取消注册方向传感器的回调函数,上报的数据类型为OrientationResponse。 |

**示例:**

```js
C
cff-gite 已提交
1749 1750 1751 1752 1753 1754 1755 1756
try {
    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 Y axis: ' + data.gamma);
        console.info('The device rotates at an angle around the Z axis: ' + data.alpha);
    }
    sensor.off(sensor.SensorId.ORIENTATION, callback);
} catch(err) {
C
cff-gite 已提交
1757
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774
}
```

### PEDOMETER<sup>9+</sup>

off(type: SensorId.PEDOMETER, callback?: Callback&lt;PedometerResponse&gt;): void

取消订阅计步器传感器数据。

**需要权限**:ohos.permission.ACTIVITY_MOTION 

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                    | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1775
| type     | [SensorId](#sensorid9)                                  | 是   | 要取消订阅的计步传感器类型为PEDOMETER。                      |
C
cff-gite 已提交
1776 1777 1778 1779 1780
| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | 是   | 取消注册计步传感器的回调函数,上报的数据类型为PedometerResponse。 |

**示例:**

```js
C
cff-gite 已提交
1781 1782 1783 1784 1785 1786
try {
    function callback(data) {
        console.info('Steps: ' + data.steps);
    }
    sensor.off(sensor.SensorId.PEDOMETER, callback);
} catch(err) {
C
cff-gite 已提交
1787
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804
}
```

### PEDOMETER_DETECTION<sup>9+</sup> 

off(type: SensorId.PEDOMETER_DETECTION, callback?: Callback&lt;PedometerDetectionResponse&gt;): void

取消订阅计步器检测传感器数据。

**需要权限**:ohos.permission.ACTIVITY_MOTION 

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1805
| type     | [SensorId](#sensorid9)                                       | 是   | 要取消订阅的计步检测传感器类型为PEDOMETER_DETECTION。        |
C
cff-gite 已提交
1806 1807 1808 1809 1810
| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | 是   | 取消注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 |

**示例:**

```js
C
cff-gite 已提交
1811 1812 1813 1814 1815 1816
try {
    function callback(data) {
        console.info('Scalar data: ' + data.scalar);
    }
    sensor.off(sensor.SensorId.PEDOMETER_DETECTION, callback);
} catch(err) {
C
cff-gite 已提交
1817
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832
}
```

### PROXIMITY<sup>9+</sup>  

off(type: SensorId.PROXIMITY, callback?: Callback&lt;ProximityResponse&gt;): void

取消订阅接近传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                    | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1833
| type     | [SensorId](#sensorid9)                                  | 是   | 要取消订阅的接近光传感器类型为PROXIMITY。                    |
C
cff-gite 已提交
1834 1835 1836 1837 1838
| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | 是   | 取消注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 |

**示例:**

```js
C
cff-gite 已提交
1839 1840 1841 1842 1843 1844
try {
    function callback(data) {
        console.info('Distance: ' + data.distance);
    }
    sensor.off(sensor.SensorId.PROXIMITY, callback);
} catch(err) {
C
cff-gite 已提交
1845
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860
}
```

### ROTATION_VECTOR<sup>9+</sup> 

off(type: SensorId.ROTATION_VECTOR, callback?: Callback&lt;RotationVectorResponse&gt;): void

取消订阅旋转矢量传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1861
| type     | [SensorId](#sensorid9)                                       | 是   | 要取消订阅的旋转矢量传感器类型为ROTATION_VECTOR。            |
C
cff-gite 已提交
1862 1863 1864 1865 1866
| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | 是   | 取消注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 |

**示例:**

```js
C
cff-gite 已提交
1867 1868 1869 1870 1871 1872 1873 1874 1875
try {
    function callback(data) {
        console.info('X-coordinate component: ' + data.x);
        console.info('Y-coordinate component: ' + data.y);
        console.info('Z-coordinate component: ' + data.z);
        console.info('Scalar quantity: ' + data.w);
    }
    sensor.off(sensor.SensorId.ROTATION_VECTOR, callback);
} catch(err) {
C
cff-gite 已提交
1876
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891
}
```

### SIGNIFICANT_MOTION<sup>9+</sup> 

off(type: SensorId.SIGNIFICANT_MOTION, callback?: Callback&lt;SignificantMotionResponse&gt;): void

取消订阅重要的运动传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1892
| type     | [SensorId](#sensorid9)                                       | 是   | 要取消订阅的大幅动作传感器类型为SIGNIFICANT_MOTION。         |
C
cff-gite 已提交
1893 1894 1895 1896 1897
| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | 是   | 取消注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 |

**示例:**

```js
C
cff-gite 已提交
1898 1899 1900 1901 1902 1903
try {
    function callback(data) {
        console.info('Scalar data: ' + data.scalar);
    }
    sensor.off(sensor.SensorId.SIGNIFICANT_MOTION, callback);
} catch(err) {
C
cff-gite 已提交
1904
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919
}
```

### WEAR_DETECTION<sup>9+</sup> 

off(type: SensorId.WEAR_DETECTION, callback?: Callback&lt;WearDetectionResponse&gt;): void

取消订阅磨损检测传感器数据。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
1920
| type     | [SensorId](#sensorid9)                                       | 是   | 要取消订阅的佩戴检测传感器类型为WEAR_DETECTION。             |
C
cff-gite 已提交
1921 1922 1923 1924 1925
| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | 是   | 取消注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 |

**示例:**

```js
C
cff-gite 已提交
1926 1927 1928 1929 1930 1931
try {
    function accCallback(data) {
        console.info('Wear status: ' + data.value);
    }
    sensor.off(sensor.SensorId.WEAR_DETECTION, accCallback);
} catch(err) {
C
cff-gite 已提交
1932
      console.info('off fail, errCode: ' + err.code + ' ,msg: ' + err.message);
C
cff-gite 已提交
1933 1934 1935
}
```

C
cff-gite 已提交
1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 2532
## sensor.getGeomagneticInfo<sup>9+</sup> 

getGeomagneticInfo(locationOptions: LocationOptions, timeMillis: number, callback: AsyncCallback&lt;GeomagneticResponse&gt;): void

获取地球上特定位置的地磁场 。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名          | 类型                                                         | 必填 | 说明                               |
| --------------- | ------------------------------------------------------------ | ---- | ---------------------------------- |
| locationOptions | [LocationOptions](#locationoptions)                          | 是   | 地理位置。                         |
| timeMillis      | number                                                       | 是   | 表示获取磁偏角的时间,单位为毫秒。 |
| callback        | AsyncCallback&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 是   | 返回磁场信息。                     |

**示例:** 

```js
try {
    sensor.getGeomagneticInfo({latitude:80, longitude:0, altitude:0}, 1580486400000, function(data)  {
    console.info('sensor_getGeomagneticInfo_callback x: ' + data.x + ',y: ' + data.y + ',z: ' +
	             data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle +
		     ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity);
    });
} catch (err) {
        console.error('getGeomagneticInfo failed. Error code: ' + err.code + '; message: ' + err.message);
}
```

## sensor.getGeomagneticInfo<sup>9+</sup> 

getGeomagneticInfo(locationOptions: LocationOptions, timeMillis: number): Promise&lt;GeomagneticResponse&gt;

获取地球上特定位置的地磁场 。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名          | 类型                                | 必填 | 说明                               |
| --------------- | ----------------------------------- | ---- | ---------------------------------- |
| locationOptions | [LocationOptions](#locationoptions) | 是   | 地理位置。                         |
| timeMillis      | number                              | 是   | 表示获取磁偏角的时间,单位为毫秒。 |

**返回值:** 

| 类型                                                       | 说明           |
| ---------------------------------------------------------- | -------------- |
| Promise&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 返回磁场信息。 |

**示例:** 

```js
try {
      const promise = sensor.getGeomagneticInfo({latitude:80, longitude:0, altitude:0}, 1580486400000);
      promise.then((data) => {
          console.info('sensor_getGeomagneticInfo_promise x: ' + data.x + ',y: ' + data.y + ',z: ' +
  	             data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle +
  		     ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity);
      }).catch((reason) => {
          console.info('Operation failed.');
  })
} catch (err) {
        console.error('getGeomagneticInfo failed. Error code: ' + err.code + '; message: ' + err.message);
}
```

## sensor. getDeviceAltitude<sup>9+</sup> 

getDeviceAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallback&lt;number&gt;): void

根据当前气压获取设备所在的海拔高度。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名          | 类型                        | 必填 | 说明                                  |
| --------------- | --------------------------- | ---- | ------------------------------------- |
| seaPressure     | number                      | 是   | 表示海平面气压值,单位为hPa。         |
| currentPressure | number                      | 是   | 表示设备所在高度的气压值,单位为hPa。 |
| callback        | AsyncCallback&lt;number&gt; | 是   | 返回设备所在的海拔高度,单位为米。    |

**示例:**

```js
try {
  sensor.getDeviceAltitude(0, 200, function(err, data)  {
          console.info("Successed to get getDeviceAltitude interface get data: " + data);
  });
} catch (err) {
        console.error('getDeviceAltitude failed. Error code: ' + err.code + '; message: ' + err.message);
}
```

## sensor. getDeviceAltitude<sup>9+</sup> 

getDeviceAltitude(seaPressure: number, currentPressure: number): Promise&lt;number&gt;

根据当前气压获取设备所在的海拔高度。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名          | 类型   | 必填 | 说明                                  |
| --------------- | ------ | ---- | ------------------------------------- |
| seaPressure     | number | 是   | 表示海平面气压值,单位为hPa。         |
| currentPressure | number | 是   | 表示设备所在高度的气压值,单位为hPa。 |

**返回值:** 

| 类型                  | 说明                                 |
| --------------------- | ------------------------------------ |
| Promise&lt;number&gt; | 返回设备所在的海拔高度(单位:米)。 |

**示例:** 

```js
try {
  const promise = sensor.getDeviceAltitude (0, 200);
      promise.then((data) => {
          console.info('sensor_getDeviceAltitude_Promise success', data);
      }).catch((err) => {
          console.error("Operation failed");
  })
} catch (err) {
        console.error('getDeviceAltitude failed. Error code: ' + err.code + '; message: ' + err.message);
}
```

## sensor. getInclination<sup>9+</sup> 

getInclination(inclinationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;number&gt;): void

从倾角矩阵计算地磁倾角的弧度。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名            | 类型                        | 必填 | 说明                         |
| ----------------- | --------------------------- | ---- | ---------------------------- |
| inclinationMatrix | Array&lt;number&gt;         | 是   | 表示倾斜矩阵。               |
| callback          | AsyncCallback&lt;number&gt; | 是   | 返回地磁倾斜角,单位为弧度。 |

**示例:** 

```js
try {
  sensor.getInclination ([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data)  {
          console.info("Successed to get getInclination  interface get data: " + data);
  })
} catch (err) {
        console.error('getInclination failed. Error code: ' + err.code + '; message: ' + err.message);
}
```

## sensor. getInclination<sup>9+</sup> 

 getInclination(inclinationMatrix: Array&lt;number&gt;): Promise&lt;number&gt;

 从倾角矩阵计算地磁倾角的弧度。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名            | 类型                | 必填 | 说明           |
| ----------------- | ------------------- | ---- | -------------- |
| inclinationMatrix | Array&lt;number&gt; | 是   | 表示倾斜矩阵。 |

**返回值:** 

| 类型                  | 说明                         |
| --------------------- | ---------------------------- |
| Promise&lt;number&gt; | 返回地磁倾斜角,单位为弧度。 |

**示例:** 

```js
try {
  const promise = sensor.getInclination ([1, 0, 0, 0, 1, 0, 0, 0, 1]);
      promise.then((data) => {
          console.info('getInclination_promise successed', data);
      }).catch((err) => {
           console.error("Operation failed");
  })
} catch (err) {
        console.error('getInclination failed. Error code: ' + err.code + '; message: ' + err.message);
}
```

## sensor. getAngleVariation<sup>9+</sup>

 getAngleVariation(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Array&lt;number&gt;,
        callback: AsyncCallback<Array&lt;number&gt;>): void

得到两个旋转矩阵之间的角度变化。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名                | 类型                                     | 必填 | 说明                              |
| --------------------- | ---------------------------------------- | ---- | --------------------------------- |
| currentRotationMatrix | Array&lt;number&gt;                      | 是   | 表示当前旋转矩阵。                |
| preRotationMatrix     | Array&lt;number&gt;                      | 是   | 表示旋转矩阵。                    |
| callback              | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是   | 返回z、x、y轴方向的旋转角度变化。 |

**示例:** 

```js
try {
  sensor.getAngleVariation([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)  {
      for (var i=0; i < data.length; i++) {
          console.info("data[" + i + "]: " + data[i]);
      }
  })
} catch (err) {
        console.error('getAngleVariation failed. Error code: ' + err.code + '; message: ' + err.message);
}
```

## sensor. getAngleVariation<sup>9+</sup>

getAngleVariation(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Array&lt;number&gt;): Promise<Array&lt;number&gt;> 

得到两个旋转矩阵之间的角度变化。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名                | 类型                | 必填 | 说明               |
| --------------------- | ------------------- | ---- | ------------------ |
| currentRotationMatrix | Array&lt;number&gt; | 是   | 表示当前旋转矩阵。 |
| preRotationMatrix     | Array&lt;number&gt; | 是   |                    |

**返回值:** 

| 类型                               | 说明                              |
| ---------------------------------- | --------------------------------- |
| Promise&lt;Array&lt;number&gt;&gt; | 返回z、x、y轴方向的旋转角度变化。 |

**示例:** 

```js
try {
  const promise = sensor.getAngleVariation([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) => {
          for (var i=0; i < data.length; i++) {
              console.info("data[" + i + "]: " + data[i]);
          }
      }).catch((reason) => {
          console.info("promise::catch", reason);
  })
} catch (err) {
        console.error('getAngleVariation failed. Error code: ' + err.code + '; message: ' + err.message);
}
```

## sensor. getRotationMatrix<sup>9+</sup> 

getRotationMatrix(rotationVector: Array&lt;number&gt;, callback: AsyncCallback<Array&lt;number&gt;>): void

将旋转向量转换为旋转矩阵。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名         | 类型                                     | 必填 | 说明           |
| -------------- | ---------------------------------------- | ---- | -------------- |
| rotationVector | Array&lt;number&gt;                      | 是   | 表示旋转矢量。 |
| callback       | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是   | 返回旋转矩阵。 |

**示例:** 

```js
try {
  sensor.getRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) {
      for (var i=0; i < data.length; i++) {
          console.info("data[" + i + "]: " + data[i]);
      }
  })
} catch (err) {
        console.error('getRotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
}
```

## sensor. getRotationMatrix<sup>9+</sup>

getRotationMatrix(rotationVector: Array&lt;number&gt;): Promise<Array<number&gt;> 

将旋转向量转换为旋转矩阵。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名         | 类型                | 必填 | 说明           |
| -------------- | ------------------- | ---- | -------------- |
| rotationVector | Array&lt;number&gt; | 是   | 表示旋转矢量。 |

**返回值:**

| 类型                               | 说明           |
| ---------------------------------- | -------------- |
| Promise&lt;Array&lt;number&gt;&gt; | 返回旋转矩阵。 |

**示例:** 

```js
try {
  const promise = sensor.getRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]);
      promise.then((data) => {
          for (var i=0; i < data.length; i++) {
              console.info("data[" + i + "]: " + data[i]);
          }
      }).catch((reason) => {
          console.info("promise::catch", reason);
  })
} catch (err) {
        console.error('getRotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
}
```

## sensor. transformRotationMatrix<sup>9+</sup> 

transformRotationMatrix(inRotationVector: Array&lt;number&gt;, coordinates: CoordinatesOptions,
        callback: AsyncCallback<Array&lt;number&gt;>): void

旋转提供的旋转矩阵,使其可以以不同的方式表示坐标系。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名           | 类型                                      | 必填 | 说明                   |
| ---------------- | ----------------------------------------- | ---- | ---------------------- |
| inRotationVector | Array&lt;number&gt;                       | 是   | 表示旋转矩阵。         |
| coordinates      | [CoordinatesOptions](#coordinatesoptions) | 是   | 表示坐标系方向。       |
| callback         | AsyncCallback&lt;Array&lt;number&gt;&gt;  | 是   | 返回转换后的旋转矩阵。 |

**示例:** 

```js
try {
sensor.transformRotationMatrix([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3}, function(data) {
    for (var i=0; i < data.length; i++) {
        console.info("transformRotationMatrix  data[ " + i + "] = " + data[i]);
    }
 })
} catch (err) {
        console.error('transformRotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
}
```

## sensor. transformRotationMatrix<sup>9+</sup>

transformRotationMatrix(inRotationVector: Array&lt;number&gt;, coordinates: CoordinatesOptions): Promise<Array&lt;number&gt;> 

旋转提供的旋转矩阵,使其可以以不同的方式表示坐标系。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名           | 类型                                      | 必填 | 说明             |
| ---------------- | ----------------------------------------- | ---- | ---------------- |
| inRotationVector | Array&lt;number&gt;                       | 是   | 表示旋转矩阵。   |
| coordinates      | [CoordinatesOptions](#coordinatesoptions) | 是   | 表示坐标系方向。 |

**返回值:**

| 类型                               | 说明                   |
| ---------------------------------- | ---------------------- |
| Promise&lt;Array&lt;number&gt;&gt; | 返回转换后的旋转矩阵。 |

**示例:**

```js
try {
    const promise = sensor.transformRotationMatrix([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3});
    promise.then((data) => {
        for (var i=0; i < data.length; i++) {
            console.info("transformRotationMatrix data[ " + i + "] = " + data[i]);
        }
    }).catch((err) => {
           console.info("Operation failed");
})
} catch (err) {
        console.error('transformRotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
}
```

## sensor.getQuaternion<sup>9+</sup> 

getQuaternion(rotationVector: Array&lt;number&gt;, callback: AsyncCallback<Array&lt;number&gt;>): void 

将旋转向量转换为归一化四元数。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名         | 类型                                     | 必填 | 说明           |
| -------------- | ---------------------------------------- | ---- | -------------- |
| rotationVector | Array&lt;number&gt;                      | 是   | 表示旋转矢量。 |
| callback       | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是   | 返回四元数。   |

**示例:**

```js
try {
    sensor.getQuaternion ([0.20046076, 0.21907, 0.73978853, 0.60376877], function(data)  {
      for (var i=0; i < data.length; i++) {
          console.info("data[" + i + "]: " + data[i]);
      }
  })
} catch (err) {
        console.error('getQuaternion failed. Error code: ' + err.code + '; message: ' + err.message);
}
```

## sensor.getQuaternion<sup>9+</sup>

getQuaternion(rotationVector: Array&lt;number&gt;): Promise<Array&lt;number&gt;> 

将旋转向量转换为归一化四元数。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名         | 类型                | 必填 | 说明           |
| -------------- | ------------------- | ---- | -------------- |
| rotationVector | Array&lt;number&gt; | 是   | 表示旋转矢量。 |

**返回值:**

| 类型                               | 说明         |
| ---------------------------------- | ------------ |
| Promise&lt;Array&lt;number&gt;&gt; | 返回四元数。 |

**示例:** 

```js
try {
  const promise = sensor.getQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]);
      promise.then((data) => {
          console.info('getQuaternionn_promise successed');
          for (var i=0; i < data.length; i++) {
              console.info("data[" + i + "]: " + data[i]);
          }
      }).catch((err) => {
          console.info('promise failed');
  })
} catch (err) {
        console.error('getQuaternion failed. Error code: ' + err.code + '; message: ' + err.message);
}
```

## sensor.getOrientation<sup>9+</sup>

getOrientation(rotationMatrix: Array&lt;number&gt;, callback: AsyncCallback<Array&lt;number&gt;>): void 

根据旋转矩阵计算设备的方向。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名         | 类型                                     | 必填 | 说明                              |
| -------------- | ---------------------------------------- | ---- | --------------------------------- |
| rotationMatrix | Array&lt;number&gt;                      | 是   | 表示旋转矩阵。                    |
| callback       | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是   | 返回围绕z、x、y轴方向的旋转角度。 |

**示例:** 

```js
try {
  sensor.getOrientation([1, 0, 0, 0, 1, 0, 0, 0, 1], function(data)  {
      console.info("SensorJsAPI--->Successed to get getOrientation interface get data: " + data);
      for (var i = 1; i < data.length; i++) {
          console.info("sensor_getOrientation_callback" + data[i]);
      }
  })
} catch (err) {
        console.error('getOrientation failed. Error code: ' + err.code + '; message: ' + err.message);
}
```

## sensor.getOrientation<sup>9+</sup>

getOrientation(rotationMatrix: Array&lt;number&gt;): Promise<Array&lt;number&gt;> 

根据旋转矩阵计算设备的方向。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

| 参数名         | 类型                | 必填 | 说明           |
| -------------- | ------------------- | ---- | -------------- |
| rotationMatrix | Array&lt;number&gt; | 是   | 表示旋转矩阵。 |

**返回值:**

| 类型                               | 说明                              |
| ---------------------------------- | --------------------------------- |
| Promise&lt;Array&lt;number&gt;&gt; | 返回围绕z、x、y轴方向的旋转角度。 |

**示例:** 

```js
try {
  const promise = sensor.getOrientation([1, 0, 0, 0, 1, 0, 0, 0, 1]);
      promise.then((data) => {
          console.info('sensor_getOrientation_Promise success', data);
          for (var i = 1; i < data.length; i++) {
              console.info("sensor_getOrientation_promise" + data[i]);
          }
      }).catch((err) => {
          console.info('promise failed');
  })
} catch (err) {
        console.error('getOrientation failed. Error code: ' + err.code + '; message: ' + err.message);
}
```

## sensor. getRotationMatrix<sup>9+</sup> 

getRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&gt;, callback: AsyncCallback&lt;RotationMatrixResponse&gt;): void 

根据重力矢量和地磁矢量计算旋转矩阵。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名      | 类型                                                         | 必填 | 说明           |
| ----------- | ------------------------------------------------------------ | ---- | -------------- |
| gravity     | Array&lt;number&gt;                                          | 是   | 表示重力向量。 |
| geomagnetic | Array&lt;number&gt;                                          | 是   | 表示地磁矢量。 |
| callback    | AsyncCallback&lt;[RotationMatrixResponse](#rotationmatrixresponse)&gt; | 是   | 返回旋转矩阵。 |

**示例:**

```js
try {
  sensor.getRotationMatrix ([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(data)  {
      console.info("sensor_getRotationMatrix_callback" + JSON.stringify(data));
  })
} catch (err) {
        console.error('getRotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
}
```

## sensor. getRotationMatrix<sup>9+</sup> 

getRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&gt;,): Promise&lt;RotationMatrixResponse>&gt;

根据重力矢量和地磁矢量计算旋转矩阵。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

| 参数名      | 类型                | 必填 | 说明           |
| ----------- | ------------------- | ---- | -------------- |
| gravity     | Array&lt;number&gt; | 是   | 表示重力向量。 |
| geomagnetic | Array&lt;number&gt; | 是   | 表示地磁矢量。 |

**返回值:** 

| 类型                                                         | 说明           |
| ------------------------------------------------------------ | -------------- |
| Promise&lt;[RotationMatrixResponse](#rotationmatrixresponse)&gt; | 返回旋转矩阵。 |

**示例:** 

```js
try {
  const promise = sensor.getRotationMatrix ([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]);
      promise.then((data) => {
          console.info("sensor_getRotationMatrix_callback" + JSON.stringify(data));
      }).catch((err) => {
          console.info('promise failed');
  })
} catch (err) {
        console.error('getRotationMatrix failed. Error code: ' + err.code + '; message: ' + err.message);
}
```

C
cff-gite 已提交
2533
## SensorId<sup>9+</sup>
C
cff-gite 已提交
2534 2535 2536 2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 2547 2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563

表示要订阅或取消订阅的传感器类型。

**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

| 名称                        | 默认值 | 说明                   |
| --------------------------- | ------ | ---------------------- |
| ACCELEROMETER               | 1      | 加速度传感器。         |
| GYROSCOPE                   | 2      | 陀螺仪传感器。         |
| AMBIENT_LIGHT               | 5      | 环境光传感器。         |
| MAGNETIC_FIELD              | 6      | 磁场传感器。           |
| BAROMETER                   | 8      | 气压计传感器。         |
| HALL                        | 10     | 霍尔传感器。           |
| PROXIMITY                   | 12     | 接近光传感器。         |
| HUMIDITY                    | 13     | 湿度传感器。           |
| ORIENTATION                 | 256    | 方向传感器。           |
| GRAVITY                     | 257    | 重力传感器。           |
| LINEAR_ACCELEROMETER        | 258    | 线性加速度传感器。     |
| ROTATION_VECTOR             | 259    | 旋转矢量传感器。       |
| AMBIENT_TEMPERATURE         | 260    | 环境温度传感器。       |
| MAGNETIC_FIELD_UNCALIBRATED | 261    | 未校准磁场传感器。     |
| GYROSCOPE_UNCALIBRATED      | 263    | 未校准陀螺仪传感器。   |
| SIGNIFICANT_MOTION          | 264    | 有效运动传感器。       |
| PEDOMETER_DETECTION         | 265    | 计步检测传感器。       |
| PEDOMETER                   | 266    | 计步传感器。           |
| HEART_RATE                  | 278    | 心率传感器。           |
| WEAR_DETECTION              | 280    | 佩戴检测传感器。       |
| ACCELEROMETER_UNCALIBRATED  | 281    | 未校准加速度计传感器。 |

## sensor.on<sup>(deprecated)</sup>
C
cff-gite 已提交
2564 2565

### ACCELEROMETER<sup>(deprecated)</sup>
Z
zengyawen 已提交
2566

C
cff-gite 已提交
2567
on(type:  SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;AccelerometerResponse&gt;,options?: Options): void
Z
zengyawen 已提交
2568 2569 2570

监听加速度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。

C
cff-gite 已提交
2571
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.on.ACCELEROMETER](#accelerometer9)
C
cff-gite 已提交
2572

L
li-yaoyao777 已提交
2573
**需要权限**:ohos.permission.ACCELEROMETER
C
cff-gite 已提交
2574 2575 2576

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
2577
**参数:** 
C
cff-gite 已提交
2578

H
HelloCrease 已提交
2579 2580 2581 2582 2583
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 |
| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | 是    | 注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
2584

H
HelloCrease 已提交
2585
**示例:** 
C
cff-gite 已提交
2586

H
HelloCrease 已提交
2587
  ```js
C
cff-gite 已提交
2588
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
2589
      console.info('X-coordinate component: ' + data.x);
Z
zengyawen 已提交
2590 2591
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
2592 2593
  },
      {interval: 10000000}
Z
zengyawen 已提交
2594 2595
  );
  ```
Z
zengyawen 已提交
2596

C
cff-gite 已提交
2597
### LINEAR_ACCELERATION<sup>(deprecated)</sup>
Z
zengyawen 已提交
2598

C
cff-gite 已提交
2599
on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;LinearAccelerometerResponse&gt;, options?: Options): void
Z
zengyawen 已提交
2600

Z
zengyawen 已提交
2601 2602
监听线性加速度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。

C
cff-gite 已提交
2603
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.on.LINEAR_ACCELEROMETER](#linear_accelerometer9)
H
h00514358 已提交
2604

L
li-yaoyao777 已提交
2605
**需要权限**:ohos.permission.ACCELEROMETER
C
cff-gite 已提交
2606 2607 2608

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
2609
**参数:** 
C
cff-gite 已提交
2610

H
HelloCrease 已提交
2611 2612 2613 2614 2615
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 |
| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | 是    | 注册线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
2616

H
h00514358 已提交
2617
### LINEAR_ACCELEROMETER<sup>9+</sup>
H
h00514358 已提交
2618

C
cff-gite 已提交
2619 2620
on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;LinearAccelerometerResponse&gt;,
        options?: Options): void
H
h00514358 已提交
2621 2622 2623

监听线性加速度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。

L
li-yaoyao777 已提交
2624
**需要权限**:ohos.permission.ACCELEROMETER
H
h00514358 已提交
2625 2626 2627 2628

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**
C
cff-gite 已提交
2629 2630 2631 2632 2633
| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type     | [SensorType](#sensortype)                                    | 是   | 要订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELEROMETER。 |
| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | 是   | 注册线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 |
| options  | [Options](#options)                                          | 否   | 可选参数列表,设置上报频率,默认值为200000000ns。            |
H
h00514358 已提交
2634 2635

**示例:**
C
cff-gite 已提交
2636

H
h00514358 已提交
2637 2638 2639 2640 2641 2642 2643 2644 2645 2646
  ```js
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER,function(data){
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
  },
      {interval: 10000000}
  );
  ```

C
cff-gite 已提交
2647
### ACCELEROMETER_UNCALIBRATED<sup>(deprecated)</sup>
Z
zengyawen 已提交
2648

C
cff-gite 已提交
2649
on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback&lt;AccelerometerUncalibratedResponse&gt;, options?: Options): void
Z
zengyawen 已提交
2650

Z
zengyawen 已提交
2651
监听未校准加速度计传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
Z
zengyawen 已提交
2652

C
cff-gite 已提交
2653
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用 [sensor.on.ACCELEROMETER_UNCALIBRATED](#accelerometer_uncalibrated9)
C
cff-gite 已提交
2654

L
li-yaoyao777 已提交
2655
**需要权限**:ohos.permission.ACCELEROMETER
C
cff-gite 已提交
2656 2657 2658

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
2659
**参数:** 
C
cff-gite 已提交
2660

H
HelloCrease 已提交
2661 2662 2663 2664 2665
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的未校准加速度计传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 |
| callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | 是    | 注册未校准加速度计传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
2666

H
HelloCrease 已提交
2667
**示例:** 
H
HelloCrease 已提交
2668
  ```js
C
cff-gite 已提交
2669
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(data){
Z
zengyawen 已提交
2670 2671 2672 2673 2674 2675
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
      console.info('X-coordinate bias: ' + data.biasX);
      console.info('Y-coordinate bias: ' + data.biasY);
      console.info('Z-coordinate bias: ' + data.biasZ);
2676 2677
  },
      {interval: 10000000}
Z
zengyawen 已提交
2678 2679
  );
  ```
Z
zengyawen 已提交
2680

C
cff-gite 已提交
2681
### GRAVITY<sup>(deprecated)</sup>
Z
zengyawen 已提交
2682

C
cff-gite 已提交
2683
on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityResponse&gt;,options?: Options): void
Z
zengyawen 已提交
2684

Z
zengyawen 已提交
2685
监听重力传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
Z
zengyawen 已提交
2686

C
cff-gite 已提交
2687
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.on.GRAVITY](#gravity9)
C
cff-gite 已提交
2688

C
cff-gite 已提交
2689 2690
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
2691
**参数:** 
C
cff-gite 已提交
2692

H
HelloCrease 已提交
2693 2694 2695 2696 2697
| 参数名      | 类型                                       | 必填   | 说明                                    |
| -------- | ---------------------------------------- | ---- | ------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的重力传感器类型为SENSOR_TYPE_ID_GRAVITY。   |
| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | 是    | 注册重力传感器的回调函数,上报的数据类型为GravityResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。        |
Z
zengyawen 已提交
2698

H
HelloCrease 已提交
2699
**示例:** 
H
HelloCrease 已提交
2700
  ```js
C
cff-gite 已提交
2701
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,function(data){
2702
      console.info('X-coordinate component: ' + data.x);
Z
zengyawen 已提交
2703 2704
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
2705 2706
  },
      {interval: 10000000}
Z
zengyawen 已提交
2707 2708
  );
  ```
Z
zengyawen 已提交
2709

C
cff-gite 已提交
2710
### GYROSCOPE<sup>(deprecated)</sup>
Z
zengyawen 已提交
2711

C
cff-gite 已提交
2712
on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeResponse&gt;, options?: Options): void
Z
zengyawen 已提交
2713

Z
zengyawen 已提交
2714
监听陀螺仪传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
Z
zengyawen 已提交
2715

C
cff-gite 已提交
2716
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.on.GYROSCOPE](#gyroscope9)
C
cff-gite 已提交
2717

L
li-yaoyao777 已提交
2718
**需要权限**:ohos.permission.GYROSCOPE
C
cff-gite 已提交
2719 2720 2721

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
2722
**参数:** 
C
cff-gite 已提交
2723

H
HelloCrease 已提交
2724 2725 2726 2727 2728
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。   |
| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | 是    | 注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
2729

H
HelloCrease 已提交
2730
**示例:** 
H
HelloCrease 已提交
2731
  ```js
C
cff-gite 已提交
2732
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,function(data){
2733
      console.info('X-coordinate component: ' + data.x);
Z
zengyawen 已提交
2734 2735
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
2736 2737
  },
      {interval: 10000000}
Z
zengyawen 已提交
2738 2739
  );
  ```
Z
zengyawen 已提交
2740

C
cff-gite 已提交
2741
### GYROSCOPE_UNCALIBRATED<sup>(deprecated)</sup>
Z
zengyawen 已提交
2742

C
cff-gite 已提交
2743
on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:Callback&lt;GyroscopeUncalibratedResponse&gt;, options?: Options): void
Z
zengyawen 已提交
2744

Z
zengyawen 已提交
2745
监听未校准陀螺仪传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
Z
zengyawen 已提交
2746

C
cff-gite 已提交
2747
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.on.GYROSCOPE_UNCALIBRATED](#gyroscope_uncalibrated9)
C
cff-gite 已提交
2748

L
li-yaoyao777 已提交
2749
**需要权限**:ohos.permission.GYROSCOPE
C
cff-gite 已提交
2750 2751 2752

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
2753
**参数:** 
C
cff-gite 已提交
2754

H
HelloCrease 已提交
2755 2756 2757 2758 2759
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 |
| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | 是    | 注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率。                           |
Z
zengyawen 已提交
2760

H
HelloCrease 已提交
2761
**示例:** 
H
HelloCrease 已提交
2762
  ```js
C
cff-gite 已提交
2763
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(data){
2764
      console.info('X-coordinate component: ' + data.x);
Z
zengyawen 已提交
2765 2766
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
2767
      console.info('X-coordinate bias: ' + data.biasX);
Z
zengyawen 已提交
2768 2769
      console.info('Y-coordinate bias: ' + data.biasY);
      console.info('Z-coordinate bias: ' + data.biasZ);
2770 2771
  },
      {interval: 10000000}
Z
zengyawen 已提交
2772 2773
  );
  ```
Z
zengyawen 已提交
2774

C
cff-gite 已提交
2775
### SIGNIFICANT_MOTION<sup>(deprecated)</sup>
Z
zengyawen 已提交
2776

C
cff-gite 已提交
2777
on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback&lt;SignificantMotionResponse&gt;, options?: Options): void
Z
zengyawen 已提交
2778

Z
zengyawen 已提交
2779
监听大幅动作传感器数据变化。如果多次调用该接口,仅最后一次调用生效。
Z
zengyawen 已提交
2780

C
cff-gite 已提交
2781
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.on.SIGNIFICANT_MOTION](#significant_motion9) 
C
cff-gite 已提交
2782

C
cff-gite 已提交
2783 2784
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
2785
**参数:** 
C
cff-gite 已提交
2786

H
HelloCrease 已提交
2787 2788 2789 2790 2791
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的大幅动作传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 |
| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | 是    | 注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
2792

H
HelloCrease 已提交
2793
**示例:** 
H
HelloCrease 已提交
2794
  ```js
C
cff-gite 已提交
2795
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(data){
Z
zengyawen 已提交
2796
      console.info('Scalar data: ' + data.scalar);
2797 2798
  },
      {interval: 10000000}
Z
zengyawen 已提交
2799 2800
  );
  ```
Z
zengyawen 已提交
2801

C
cff-gite 已提交
2802
### PEDOMETER_DETECTION<sup>(deprecated)</sup>
Z
zengyawen 已提交
2803

C
cff-gite 已提交
2804
on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback&lt;PedometerDetectionResponse&gt;, options?: Options): void
Z
zengyawen 已提交
2805

Z
zengyawen 已提交
2806
监听计步检测传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
Z
zengyawen 已提交
2807

C
cff-gite 已提交
2808
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.on.PEDOMETER_DETECTION](#pedometer_detection9) 
C
cff-gite 已提交
2809

C
cff-gite 已提交
2810
**需要权限**:ohos.permission.ACTIVITY_MOTION
C
cff-gite 已提交
2811 2812 2813

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
2814
**参数:** 
C
cff-gite 已提交
2815

H
HelloCrease 已提交
2816 2817 2818 2819 2820
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 |
| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | 是    | 注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
2821

H
HelloCrease 已提交
2822
**示例:** 
H
HelloCrease 已提交
2823
  ```js
C
cff-gite 已提交
2824
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(data){
Z
zengyawen 已提交
2825
      console.info('Scalar data: ' + data.scalar);
2826 2827
  },
      {interval: 10000000}
Z
zengyawen 已提交
2828 2829
  );
  ```
Z
zengyawen 已提交
2830

C
cff-gite 已提交
2831
### PEDOMETER<sup>(deprecated)</sup>
Z
zengyawen 已提交
2832

C
cff-gite 已提交
2833
on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerResponse&gt;, options?: Options): void
Z
zengyawen 已提交
2834

Z
zengyawen 已提交
2835
监听计步传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
Z
zengyawen 已提交
2836

C
cff-gite 已提交
2837
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.on.PEDOMETER](#pedometer9) 
C
cff-gite 已提交
2838

C
cff-gite 已提交
2839
**需要权限**:ohos.permission.ACTIVITY_MOTION 
C
cff-gite 已提交
2840 2841 2842

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
2843
**参数:** 
C
cff-gite 已提交
2844

H
HelloCrease 已提交
2845 2846 2847 2848 2849
| 参数名      | 类型                                       | 必填   | 说明                                      |
| -------- | ---------------------------------------- | ---- | --------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。   |
| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | 是    | 注册计步传感器的回调函数,上报的数据类型为PedometerResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。          |
Z
zengyawen 已提交
2850

H
HelloCrease 已提交
2851
**示例:** 
H
HelloCrease 已提交
2852
  ```js
C
cff-gite 已提交
2853
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,function(data){
Z
zengyawen 已提交
2854
      console.info('Steps: ' + data.steps);
2855 2856
  },
      {interval: 10000000}
Z
zengyawen 已提交
2857 2858
  );
  ```
Z
zengyawen 已提交
2859

C
cff-gite 已提交
2860
### AMBIENT_TEMPERATURE<sup>(deprecated)</sup>
Z
zengyawen 已提交
2861

C
cff-gite 已提交
2862
on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:Callback&lt;AmbientTemperatureResponse&gt;,  options?: Options): void
Z
zengyawen 已提交
2863

Z
zengyawen 已提交
2864
监听环境温度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
Z
zengyawen 已提交
2865

C
cff-gite 已提交
2866
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.on.AMBIENT_TEMPERATURE](#ambient_temperature9) 
C
cff-gite 已提交
2867

C
cff-gite 已提交
2868 2869
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
2870
**参数:** 
C
cff-gite 已提交
2871

H
HelloCrease 已提交
2872 2873 2874 2875 2876
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 |
| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | 是    | 注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
2877

H
HelloCrease 已提交
2878
**示例:** 
C
cff-gite 已提交
2879

H
HelloCrease 已提交
2880
  ```js
C
cff-gite 已提交
2881
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,function(data){
Z
zengyawen 已提交
2882
      console.info('Temperature: ' + data.temperature);
2883 2884
  },
      {interval: 10000000}
Z
zengyawen 已提交
2885 2886
  );
  ```
Z
zengyawen 已提交
2887

C
cff-gite 已提交
2888
### MAGNETIC_FIELD<sup>(deprecated)</sup>
Z
zengyawen 已提交
2889

C
cff-gite 已提交
2890
on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;MagneticFieldResponse&gt;,options?: Options): void
Z
zengyawen 已提交
2891

Z
zengyawen 已提交
2892
监听磁场传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
Z
zengyawen 已提交
2893

C
cff-gite 已提交
2894
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.on.MAGNETIC_FIELD](#magnetic_field9)  
C
cff-gite 已提交
2895

C
cff-gite 已提交
2896 2897
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
2898
**参数:** 
C
cff-gite 已提交
2899

H
HelloCrease 已提交
2900 2901 2902 2903 2904
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 |
| callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | 是    | 注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
2905

H
HelloCrease 已提交
2906
**示例:** 
C
cff-gite 已提交
2907

H
HelloCrease 已提交
2908
  ```js
C
cff-gite 已提交
2909
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,function(data){
Z
zengyawen 已提交
2910 2911 2912
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
2913 2914
  },
      {interval: 10000000}
Z
zengyawen 已提交
2915 2916
  );
  ```
Z
zengyawen 已提交
2917

C
cff-gite 已提交
2918
### MAGNETIC_FIELD_UNCALIBRATED<sup>(deprecated)</sup>
Z
zengyawen 已提交
2919

H
HelloCrease 已提交
2920
on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback&lt;MagneticFieldUncalibratedResponse&gt;, options?: Options): void
Z
zengyawen 已提交
2921

Z
zengyawen 已提交
2922
监听未校准磁场传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
Z
zengyawen 已提交
2923

C
cff-gite 已提交
2924
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.on.MAGNETIC_FIELD_UNCALIBRATED](#magnetic_field_uncalibrated9)  
C
cff-gite 已提交
2925

C
cff-gite 已提交
2926 2927
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
2928
**参数:** 
C
cff-gite 已提交
2929

H
HelloCrease 已提交
2930 2931 2932 2933 2934
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 |
| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | 是    | 注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
2935

H
HelloCrease 已提交
2936
**示例:** 
H
HelloCrease 已提交
2937
  ```js
C
cff-gite 已提交
2938
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(data){
2939 2940 2941 2942
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
      console.info('X-coordinate bias: ' + data.biasX);
Z
zengyawen 已提交
2943 2944
      console.info('Y-coordinate bias: ' + data.biasY);
      console.info('Z-coordinate bias: ' + data.biasZ);
2945 2946
  },
      {interval: 10000000}
Z
zengyawen 已提交
2947 2948
  );
  ```
Z
zengyawen 已提交
2949

C
cff-gite 已提交
2950
### PROXIMITY<sup>(deprecated)</sup>
Z
zengyawen 已提交
2951

C
cff-gite 已提交
2952
on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityResponse&gt;,options?: Options): void
Z
zengyawen 已提交
2953

Z
zengyawen 已提交
2954
监听接近光传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
Z
zengyawen 已提交
2955

C
cff-gite 已提交
2956
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.on.PROXIMITY](#proximity9) 
C
cff-gite 已提交
2957

C
cff-gite 已提交
2958 2959
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
2960
**参数:** 
C
cff-gite 已提交
2961

H
HelloCrease 已提交
2962 2963 2964 2965 2966
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。   |
| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | 是    | 注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
2967

H
HelloCrease 已提交
2968
**示例:** 
H
HelloCrease 已提交
2969
  ```js
C
cff-gite 已提交
2970
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY,function(data){
Z
zengyawen 已提交
2971
      console.info('Distance: ' + data.distance);
2972 2973
  },
      {interval: 10000000}
Z
zengyawen 已提交
2974 2975
  );
  ```
Z
zengyawen 已提交
2976

C
cff-gite 已提交
2977
### HUMIDITY<sup>(deprecated)</sup>
Z
zengyawen 已提交
2978

C
cff-gite 已提交
2979
on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityResponse&gt;,options?: Options): void
Z
zengyawen 已提交
2980

Z
zengyawen 已提交
2981
监听湿度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
Z
zengyawen 已提交
2982

C
cff-gite 已提交
2983
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.on.HUMIDITY](#humidity9)  
C
cff-gite 已提交
2984

C
cff-gite 已提交
2985 2986
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
2987
**参数:** 
C
cff-gite 已提交
2988

H
HelloCrease 已提交
2989 2990 2991 2992 2993
| 参数名      | 类型                                       | 必填   | 说明                                     |
| -------- | ---------------------------------------- | ---- | -------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。   |
| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | 是    | 注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。         |
Z
zengyawen 已提交
2994

H
HelloCrease 已提交
2995
**示例:** 
C
cff-gite 已提交
2996

H
HelloCrease 已提交
2997
  ```js
C
cff-gite 已提交
2998
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY,function(data){
Z
zengyawen 已提交
2999
      console.info('Humidity: ' + data.humidity);
3000 3001
  },
      {interval: 10000000}
Z
zengyawen 已提交
3002 3003
  );
  ```
Z
zengyawen 已提交
3004

C
cff-gite 已提交
3005
### BAROMETER<sup>(deprecated)</sup>
Z
zengyawen 已提交
3006

C
cff-gite 已提交
3007
on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerResponse&gt;,options?: Options): void
Z
zengyawen 已提交
3008

Z
zengyawen 已提交
3009
监听气压计传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
Z
zengyawen 已提交
3010

C
cff-gite 已提交
3011
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.on.BAROMETER](#barometer9)
C
cff-gite 已提交
3012

C
cff-gite 已提交
3013 3014
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3015
**参数:** 
C
cff-gite 已提交
3016

H
HelloCrease 已提交
3017 3018 3019 3020 3021
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。   |
| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | 是    | 注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
3022

H
HelloCrease 已提交
3023
**示例:** 
C
cff-gite 已提交
3024

H
HelloCrease 已提交
3025
  ```js
C
cff-gite 已提交
3026
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,function(data){
Z
zengyawen 已提交
3027
      console.info('Atmospheric pressure: ' + data.pressure);
3028 3029
  },
      {interval: 10000000}
Z
zengyawen 已提交
3030 3031
  );
  ```
Z
zengyawen 已提交
3032

C
cff-gite 已提交
3033
### HALL<sup>(deprecated)</sup>
Z
zengyawen 已提交
3034

C
cff-gite 已提交
3035
on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt;, options?: Options): void
Z
zengyawen 已提交
3036

Z
zengyawen 已提交
3037
监听霍尔传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
Z
zengyawen 已提交
3038

C
cff-gite 已提交
3039
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.on.HALL](#hall9)
C
cff-gite 已提交
3040

C
cff-gite 已提交
3041 3042
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3043
**参数:** 
C
cff-gite 已提交
3044

H
HelloCrease 已提交
3045 3046 3047 3048 3049
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的霍尔传感器类型为SENSOR_TYPE_ID_HALL。         |
| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | 是    | 注册霍尔传感器的回调函数,上报的数据类型为&nbsp;HallResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
3050

H
HelloCrease 已提交
3051
**示例:** 
H
HelloCrease 已提交
3052
  ```js
C
cff-gite 已提交
3053
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL,function(data){
Z
zengyawen 已提交
3054
      console.info('Status: ' + data.status);
3055 3056
  },
      {interval: 10000000}
Z
zengyawen 已提交
3057 3058
  );
  ```
Z
zengyawen 已提交
3059

C
cff-gite 已提交
3060
### AMBIENT_LIGHT<sup>(deprecated)</sup>
Z
zengyawen 已提交
3061

C
cff-gite 已提交
3062
on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightResponse&gt;, options?: Options): void
Z
zengyawen 已提交
3063

Z
zengyawen 已提交
3064
监听环境光传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
Z
zengyawen 已提交
3065

C
cff-gite 已提交
3066
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.on.AMBIENT_LIGHT](#ambient_light9)
C
cff-gite 已提交
3067

C
cff-gite 已提交
3068 3069
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3070
**参数:** 
C
cff-gite 已提交
3071

H
HelloCrease 已提交
3072 3073 3074 3075 3076
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 |
| callback | Callback&lt;[LightResponse](#lightresponse)&gt; | 是    | 注册环境光传感器的回调函数,上报的数据类型为LightResponse。     |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
3077

H
HelloCrease 已提交
3078
**示例:** 
C
cff-gite 已提交
3079

H
HelloCrease 已提交
3080
  ```js
C
cff-gite 已提交
3081
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,function(data){
3082 3083 3084
      console.info(' Illumination: ' + data.intensity);
  },
      {interval: 10000000}
Z
zengyawen 已提交
3085 3086
  );
  ```
Z
zengyawen 已提交
3087

C
cff-gite 已提交
3088
### ORIENTATION<sup>(deprecated)</sup>
Z
zengyawen 已提交
3089

C
cff-gite 已提交
3090
on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;OrientationResponse&gt;, options?: Options): void
Z
zengyawen 已提交
3091

Z
zengyawen 已提交
3092
监听方向传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
Z
zengyawen 已提交
3093

C
cff-gite 已提交
3094
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.on.ORIENTATION](#orientation9)
C
cff-gite 已提交
3095

C
cff-gite 已提交
3096 3097
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3098
**参数:** 
C
cff-gite 已提交
3099

H
HelloCrease 已提交
3100 3101 3102 3103 3104
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的方向传感器类型为SENSOR_TYPE_ID_ORIENTATION   |
| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | 是    | 注册方向传感器的回调函数,上报的数据类型为OrientationResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
3105

H
HelloCrease 已提交
3106
**示例:** 
H
HelloCrease 已提交
3107
  ```js
C
cff-gite 已提交
3108
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,function(data){
C
cff-gite 已提交
3109 3110 3111
      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 Z axis: ' + data.alpha);
3112 3113
  },
      {interval: 10000000}
Z
zengyawen 已提交
3114 3115
  );
  ```
Z
zengyawen 已提交
3116

C
cff-gite 已提交
3117
### HEART_RATE<sup>(deprecated)</sup>
C
cff-gite 已提交
3118

C
cff-gite 已提交
3119
on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRateResponse&gt;, options?: Options): void
C
cff-gite 已提交
3120 3121 3122

监听心率传感器数据变化一次。

C
cff-gite 已提交
3123
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.on.HEART_BEAT_RATE](#heart_beat_rate9)
H
h00514358 已提交
3124

C
cff-gite 已提交
3125
**需要权限**:ohos.permission.HEALTH_DATA 
C
cff-gite 已提交
3126 3127 3128

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3129
**参数:** 
C
cff-gite 已提交
3130

C
cff-gite 已提交
3131 3132 3133 3134
| 参数名   | 类型                                                    | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type     | [SensorType](#sensortype)                               | 是   | 要订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。          |
| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | 是   | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 |
Z
zengyawen 已提交
3135

H
h00514358 已提交
3136
### HEART_BEAT_RATE<sup>9+</sup>
H
h00514358 已提交
3137

C
cff-gite 已提交
3138 3139
on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRateResponse&gt;,
        options?: Options): void
H
h00514358 已提交
3140 3141 3142

监听心率传感器数据变化一次。

C
cff-gite 已提交
3143
**需要权限**:ohos.permission.HEALTH_DATA 
H
h00514358 已提交
3144 3145 3146 3147 3148

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

C
cff-gite 已提交
3149 3150 3151 3152
| 参数名   | 类型                                                    | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type     | [SensorType](#sensortype)                               | 是   | 要订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_BEAT_RATE。     |
| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | 是   | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 |
H
h00514358 已提交
3153 3154 3155 3156 3157 3158 3159 3160 3161 3162 3163

**示例:**

```js
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE,function(data){
    console.info("Heart rate: " + data.heartRate);
},
    {interval: 10000000}
);
```

C
cff-gite 已提交
3164
### ROTATION_VECTOR<sup>(deprecated)</sup>
Z
zengyawen 已提交
3165

C
cff-gite 已提交
3166
on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback: Callback&lt;RotationVectorResponse&gt;,options?: Options): void
Z
zengyawen 已提交
3167

Z
zengyawen 已提交
3168
监听旋转矢量传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
Z
zengyawen 已提交
3169

C
cff-gite 已提交
3170
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.on.ROTATION_VECTOR](#rotation_vector9)
C
cff-gite 已提交
3171

C
cff-gite 已提交
3172 3173
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3174
**参数:** 
C
cff-gite 已提交
3175

H
HelloCrease 已提交
3176 3177 3178 3179 3180
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 |
| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | 是    | 注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
3181

H
HelloCrease 已提交
3182
**示例:** 
H
HelloCrease 已提交
3183
  ```js
C
cff-gite 已提交
3184
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(data){
Z
zengyawen 已提交
3185 3186 3187
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
C
cff-gite 已提交
3188
      console.info('Scalar quantity: ' + data.w);
3189 3190
  },
      {interval: 10000000}
Z
zengyawen 已提交
3191 3192
  );
  ```
Z
zengyawen 已提交
3193

C
cff-gite 已提交
3194
### WEAR_DETECTION<sup>(deprecated)</sup>
Z
zengyawen 已提交
3195

C
cff-gite 已提交
3196
on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearDetectionResponse&gt;,options?: Options): void
Z
zengyawen 已提交
3197

Z
zengyawen 已提交
3198
监听佩戴检测传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
Z
zengyawen 已提交
3199

C
cff-gite 已提交
3200
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.on.WEAR_DETECTION](#wear_detection9)
C
cff-gite 已提交
3201

C
cff-gite 已提交
3202 3203
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3204
**参数:** 
C
cff-gite 已提交
3205

H
HelloCrease 已提交
3206 3207 3208 3209 3210
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 |
| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | 是    | 注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
3211

H
HelloCrease 已提交
3212
**示例:** 
H
HelloCrease 已提交
3213
  ```js
C
cff-gite 已提交
3214
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(data){
Z
zengyawen 已提交
3215
      console.info('Wear status: ' + data.value);
3216 3217
  },
      {interval: 10000000}
Z
zengyawen 已提交
3218 3219
  );
  ```
Z
zengyawen 已提交
3220

C
cff-gite 已提交
3221
## sensor.once<sup>(deprecated)</sup>
Z
zengyawen 已提交
3222

C
cff-gite 已提交
3223
### ACCELEROMETER<sup>(deprecated)</sup>
Z
zengyawen 已提交
3224

C
cff-gite 已提交
3225
once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback&lt;AccelerometerResponse&gt;): void
Z
zengyawen 已提交
3226

Z
zengyawen 已提交
3227
监听加速度传感器的数据变化一次。
Z
zengyawen 已提交
3228

C
cff-gite 已提交
3229
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.once.ACCELEROMETER](#accelerometer9-1)
C
cff-gite 已提交
3230

L
li-yaoyao777 已提交
3231
**需要权限**:ohos.permission.ACCELEROMETER
C
cff-gite 已提交
3232 3233 3234

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3235
**参数:** 
C
cff-gite 已提交
3236

H
HelloCrease 已提交
3237 3238 3239 3240
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。   |
| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | 是    | 注册一次加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 |
Z
zengyawen 已提交
3241

H
HelloCrease 已提交
3242
**示例:** 
H
HelloCrease 已提交
3243
  ```js
C
cff-gite 已提交
3244
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
Z
zengyawen 已提交
3245 3246 3247
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
Z
zengyawen 已提交
3248
    }
Z
zengyawen 已提交
3249 3250
  );
  ```
Z
zengyawen 已提交
3251

C
cff-gite 已提交
3252
### LINEAR_ACCELERATION<sup>(deprecated)</sup>
Z
zengyawen 已提交
3253

C
cff-gite 已提交
3254
once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;LinearAccelerometerResponse&gt;): void
Z
zengyawen 已提交
3255

Z
zengyawen 已提交
3256
监听线性加速度传感器数据变化一次。
Z
zengyawen 已提交
3257

C
cff-gite 已提交
3258
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请用[sensor.once.LINEAR_ACCELEROMETER](#linear_accelerometer9)
H
h00514358 已提交
3259

L
li-yaoyao777 已提交
3260
**需要权限**:ohos.permission.ACCELERATION
C
cff-gite 已提交
3261 3262 3263

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3264
**参数:** 
C
cff-gite 已提交
3265

H
HelloCrease 已提交
3266 3267 3268 3269
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 |
| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | 是    | 注册一次线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 |
Z
zengyawen 已提交
3270

H
h00514358 已提交
3271
### LINEAR_ACCELEROMETER<sup>9+</sup>
H
h00514358 已提交
3272

C
cff-gite 已提交
3273
once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback&lt;LinearAccelerometerResponse&gt;): void
H
h00514358 已提交
3274

H
h00514358 已提交
3275
订阅一次线性加速度传感器数据。
H
h00514358 已提交
3276

C
cff-gite 已提交
3277
**需要权限**:ohos.permission.ACCELERATION 
H
h00514358 已提交
3278 3279 3280 3281

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**
C
cff-gite 已提交
3282 3283 3284 3285
| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type     | [SensorType](#sensortype)                                    | 是   | 线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELEROMETER。  |
| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | 是   | 注册一次线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 |
H
h00514358 已提交
3286 3287

**示例:**
C
cff-gite 已提交
3288

H
h00514358 已提交
3289 3290 3291 3292 3293 3294 3295 3296 3297
  ```js
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, function(data) {
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
    }
  );
  ```

C
cff-gite 已提交
3298
### ACCELEROMETER_UNCALIBRATED<sup>(deprecated)</sup>
Z
zengyawen 已提交
3299

C
cff-gite 已提交
3300
once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback&lt;AccelerometerUncalibratedResponse&gt;): void
Z
zengyawen 已提交
3301

Z
zengyawen 已提交
3302
监听未校准加速度传感器的数据变化一次。
Z
zengyawen 已提交
3303

C
cff-gite 已提交
3304
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请用[sensor.once.ACCELEROMETER_UNCALIBRATED](#accelerometer_uncalibrated9-1)
C
cff-gite 已提交
3305

L
li-yaoyao777 已提交
3306
**需要权限**:ohos.permission.ACCELEROMETER
C
cff-gite 已提交
3307 3308 3309

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3310
**参数:** 
C
cff-gite 已提交
3311

H
HelloCrease 已提交
3312 3313 3314 3315
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 未校准加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 |
| callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | 是    | 注册一次未校准加速度传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 |
Z
zengyawen 已提交
3316

H
HelloCrease 已提交
3317
**示例:** 
Z
zengyawen 已提交
3318
  ```
C
cff-gite 已提交
3319
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, function(data) {
Z
zengyawen 已提交
3320 3321 3322 3323 3324 3325
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
      console.info('X-coordinate bias: ' + data.biasX);
      console.info('Y-coordinate bias: ' + data.biasY);
      console.info('Z-coordinate bias: ' + data.biasZ);
Z
zengyawen 已提交
3326
    }
Z
zengyawen 已提交
3327 3328
  );
  ```
Z
zengyawen 已提交
3329

C
cff-gite 已提交
3330
### GRAVITY<sup>(deprecated)</sup>
Z
zengyawen 已提交
3331

C
cff-gite 已提交
3332
once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback&lt;GravityResponse&gt;): void
Z
zengyawen 已提交
3333

Z
zengyawen 已提交
3334
监听重力传感器的数据变化一次。
Z
zengyawen 已提交
3335

C
cff-gite 已提交
3336
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请用[sensor.once.GRAVITY](#gravity9-1)
C
cff-gite 已提交
3337

C
cff-gite 已提交
3338 3339
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3340
**参数:** 
C
cff-gite 已提交
3341

H
HelloCrease 已提交
3342 3343 3344 3345
| 参数名      | 类型                                       | 必填   | 说明                                      |
| -------- | ---------------------------------------- | ---- | --------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 重力传感器类型为SENSOR_TYPE_ID_GRAVITY。         |
| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | 是    | 注册一次重力传感器的回调函数,上报的数据类型为GravityResponse。 |
Z
zengyawen 已提交
3346

H
HelloCrease 已提交
3347
**示例:** 
H
HelloCrease 已提交
3348
  ```js
C
cff-gite 已提交
3349
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function(data) {
Z
zengyawen 已提交
3350 3351 3352
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
Z
zengyawen 已提交
3353
    }
Z
zengyawen 已提交
3354 3355
  );
  ```
Z
zengyawen 已提交
3356

C
cff-gite 已提交
3357
### GYROSCOPE<sup>(deprecated)</sup>
Z
zengyawen 已提交
3358

C
cff-gite 已提交
3359
once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback&lt;GyroscopeResponse&gt;): void
Z
zengyawen 已提交
3360

Z
zengyawen 已提交
3361
监听陀螺仪传感器的数据变化一次。
Z
zengyawen 已提交
3362

C
cff-gite 已提交
3363
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请用[sensor.once.GYROSCOPE](#gyroscope9-1)
C
cff-gite 已提交
3364

L
li-yaoyao777 已提交
3365
**需要权限**:ohos.permission.GYROSCOPE
C
cff-gite 已提交
3366 3367 3368

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3369
**参数:** 
C
cff-gite 已提交
3370

H
HelloCrease 已提交
3371 3372 3373 3374
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。       |
| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | 是    | 注册一次陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 |
Z
zengyawen 已提交
3375

H
HelloCrease 已提交
3376
**示例:** 
H
HelloCrease 已提交
3377
  ```js
C
cff-gite 已提交
3378
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(data) {
Z
zengyawen 已提交
3379 3380 3381
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
Z
zengyawen 已提交
3382
    }
Z
zengyawen 已提交
3383 3384
  );
  ```
Z
zengyawen 已提交
3385

C
cff-gite 已提交
3386
### GYROSCOPE_UNCALIBRATED<sup>(deprecated)</sup>
Z
zengyawen 已提交
3387

C
cff-gite 已提交
3388
once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback: Callback&lt;GyroscopeUncalibratedResponse&gt;): void
Z
zengyawen 已提交
3389

Z
zengyawen 已提交
3390
监听未校准陀螺仪传感器的数据变化一次。
Z
zengyawen 已提交
3391

C
cff-gite 已提交
3392
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请用[sensor.once.GYROSCOPE_UNCALIBRATED](#gyroscope_uncalibrated9-1)
C
cff-gite 已提交
3393

L
li-yaoyao777 已提交
3394
**需要权限**:ohos.permission.GYROSCOPE
C
cff-gite 已提交
3395 3396 3397

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3398
**参数:** 
C
cff-gite 已提交
3399

H
HelloCrease 已提交
3400 3401 3402 3403
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 |
| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | 是    | 注册一次未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 |
Z
zengyawen 已提交
3404

H
HelloCrease 已提交
3405
**示例:** 
H
HelloCrease 已提交
3406
  ```js
C
cff-gite 已提交
3407
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(data) {
Z
zengyawen 已提交
3408 3409 3410 3411 3412 3413
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
      console.info('X-coordinate bias: ' + data.biasX);
      console.info('Y-coordinate bias: ' + data.biasY);
      console.info('Z-coordinate bias: ' + data.biasZ);
Z
zengyawen 已提交
3414
    }
Z
zengyawen 已提交
3415 3416
  );
  ```
Z
zengyawen 已提交
3417

C
cff-gite 已提交
3418
### SIGNIFICANT_MOTION<sup>(deprecated)</sup>
Z
zengyawen 已提交
3419

C
cff-gite 已提交
3420
once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback: Callback&lt;SignificantMotionResponse&gt;): void
Z
zengyawen 已提交
3421

Z
zengyawen 已提交
3422
监听有效运动传感器的数据变化一次。
Z
zengyawen 已提交
3423

C
cff-gite 已提交
3424
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请用[sensor.once.SIGNIFICANT_MOTION](#significant_motion9-1)
C
cff-gite 已提交
3425

C
cff-gite 已提交
3426 3427
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3428
**参数:** 
C
cff-gite 已提交
3429

H
HelloCrease 已提交
3430 3431 3432 3433
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 有效运动传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 |
| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | 是    | 注册一次有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 |
Z
zengyawen 已提交
3434

H
HelloCrease 已提交
3435
**示例:** 
H
HelloCrease 已提交
3436
  ```js
C
cff-gite 已提交
3437
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(data) {
Z
zengyawen 已提交
3438
      console.info('Scalar data: ' + data.scalar);
Z
zengyawen 已提交
3439
    }
Z
zengyawen 已提交
3440 3441
  );
  ```
Z
zengyawen 已提交
3442

C
cff-gite 已提交
3443
### PEDOMETER_DETECTION<sup>(deprecated)</sup>
Z
zengyawen 已提交
3444

C
cff-gite 已提交
3445
once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback: Callback&lt;PedometerDetectionResponse&gt;): void
Z
zengyawen 已提交
3446

Z
zengyawen 已提交
3447
监听计步检测传感器数据变化一次。
Z
zengyawen 已提交
3448

C
cff-gite 已提交
3449
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请用[sensor.once.PEDOMETER_DETECTION](#pedometer_detection9-1)
C
cff-gite 已提交
3450

C
cff-gite 已提交
3451
**需要权限**:ohos.permission.ACTIVITY_MOTION
C
cff-gite 已提交
3452 3453 3454

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3455
**参数:** 
C
cff-gite 已提交
3456

H
HelloCrease 已提交
3457 3458 3459 3460
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 |
| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | 是    | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 |
Z
zengyawen 已提交
3461

H
HelloCrease 已提交
3462
**示例:** 
H
HelloCrease 已提交
3463
  ```js
C
cff-gite 已提交
3464
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(data) {
Z
zengyawen 已提交
3465
      console.info('Scalar data: ' + data.scalar);
Z
zengyawen 已提交
3466
    }
Z
zengyawen 已提交
3467 3468
  );
  ```
Z
zengyawen 已提交
3469

C
cff-gite 已提交
3470
### PEDOMETER<sup>(deprecated)</sup>
Z
zengyawen 已提交
3471

C
cff-gite 已提交
3472
once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback&lt;PedometerResponse&gt;): void
Z
zengyawen 已提交
3473

Z
zengyawen 已提交
3474
监听计步器传感器数据变化一次。
Z
zengyawen 已提交
3475

C
cff-gite 已提交
3476
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请用[sensor.once.PEDOMETER](#pedometer9-1)
C
cff-gite 已提交
3477

C
cff-gite 已提交
3478
**需要权限**:ohos.permission.ACTIVITY_MOTION
C
cff-gite 已提交
3479 3480 3481

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3482
**参数:** 
C
cff-gite 已提交
3483

H
HelloCrease 已提交
3484 3485 3486 3487
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。        |
| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | 是    | 注册一次计步传感器的回调函数,上报的数据类型为PedometerResponse。 |
Z
zengyawen 已提交
3488

H
HelloCrease 已提交
3489
**示例:** 
H
HelloCrease 已提交
3490
  ```js
C
cff-gite 已提交
3491
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function(data) {
Z
zengyawen 已提交
3492
      console.info('Steps: ' + data.steps);
Z
zengyawen 已提交
3493
    }
Z
zengyawen 已提交
3494 3495
  );
  ```
Z
zengyawen 已提交
3496

C
cff-gite 已提交
3497
### AMBIENT_TEMPERATURE<sup>(deprecated)</sup>
Z
zengyawen 已提交
3498

C
cff-gite 已提交
3499
once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback: Callback&lt;AmbientTemperatureResponse&gt;): void
Z
zengyawen 已提交
3500

Z
zengyawen 已提交
3501
监听环境温度传感器数据变化一次。
Z
zengyawen 已提交
3502

C
cff-gite 已提交
3503
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请用[sensor.once.AMBIENT_TEMPERATURE](#ambient_temperature9-1)
C
cff-gite 已提交
3504

C
cff-gite 已提交
3505 3506
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3507
**参数:** 
C
cff-gite 已提交
3508

H
HelloCrease 已提交
3509 3510 3511 3512
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 |
| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | 是    | 注册一次环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 |
Z
zengyawen 已提交
3513

H
HelloCrease 已提交
3514
**示例:** 
H
HelloCrease 已提交
3515
  ```js
C
cff-gite 已提交
3516
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(data) {
Z
zengyawen 已提交
3517
      console.info('Temperature: ' + data.temperature);
Z
zengyawen 已提交
3518
    }
Z
zengyawen 已提交
3519 3520
  );
  ```
Z
zengyawen 已提交
3521

C
cff-gite 已提交
3522
### MAGNETIC_FIELD<sup>(deprecated)</sup>
Z
zengyawen 已提交
3523

C
cff-gite 已提交
3524
once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback&lt;MagneticFieldResponse&gt;): void
Z
zengyawen 已提交
3525

Z
zengyawen 已提交
3526
监听磁场传感器数据变化一次。
Z
zengyawen 已提交
3527

C
cff-gite 已提交
3528
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请用[sensor.once.MAGNETIC_FIELD](#magnetic_field9-1)
C
cff-gite 已提交
3529

C
cff-gite 已提交
3530 3531
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3532
**参数:** 
C
cff-gite 已提交
3533

H
HelloCrease 已提交
3534 3535 3536 3537
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。   |
| callback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | 是    | 注册一次磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 |
Z
zengyawen 已提交
3538

H
HelloCrease 已提交
3539
**示例:** 
H
HelloCrease 已提交
3540
  ```js
C
cff-gite 已提交
3541
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(data) {
Z
zengyawen 已提交
3542 3543 3544
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
Z
zengyawen 已提交
3545
    }
Z
zengyawen 已提交
3546 3547
  );
  ```
Z
zengyawen 已提交
3548

C
cff-gite 已提交
3549
### MAGNETIC_FIELD_UNCALIBRATED<sup>(deprecated)</sup>
Z
zengyawen 已提交
3550

C
cff-gite 已提交
3551
once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback&lt;MagneticFieldUncalibratedResponse&gt;): void
Z
zengyawen 已提交
3552

Z
zengyawen 已提交
3553
监听未校准磁场传感器数据变化一次。
Z
zengyawen 已提交
3554

C
cff-gite 已提交
3555
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请用[sensor.once.MAGNETIC_FIELD_UNCALIBRATED](#magnetic_field_uncalibrated9-1)
C
cff-gite 已提交
3556

C
cff-gite 已提交
3557 3558
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3559
**参数:** 
C
cff-gite 已提交
3560

H
HelloCrease 已提交
3561 3562 3563 3564
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 |
| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | 是    | 注册一次未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 |
Z
zengyawen 已提交
3565

H
HelloCrease 已提交
3566
**示例:** 
H
HelloCrease 已提交
3567
  ```js
C
cff-gite 已提交
3568
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(data) {
Z
zengyawen 已提交
3569 3570 3571 3572 3573 3574
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
      console.info('X-coordinate bias: ' + data.biasX);
      console.info('Y-coordinate bias: ' + data.biasY);
      console.info('Z-coordinate bias: ' + data.biasZ);
Z
zengyawen 已提交
3575
    }
Z
zengyawen 已提交
3576 3577
  );
  ```
Z
zengyawen 已提交
3578

C
cff-gite 已提交
3579
### PROXIMITY<sup>(deprecated)</sup>
Z
zengyawen 已提交
3580

C
cff-gite 已提交
3581
once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback&lt;ProximityResponse&gt;): void
Z
zengyawen 已提交
3582

Z
zengyawen 已提交
3583
监听接近光传感器数据变化一次。
Z
zengyawen 已提交
3584

C
cff-gite 已提交
3585
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请用[sensor.once.PROXIMITY](#proximity9-1) 
C
cff-gite 已提交
3586

C
cff-gite 已提交
3587 3588
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3589
**参数:** 
C
cff-gite 已提交
3590

H
HelloCrease 已提交
3591 3592 3593 3594
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。       |
| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | 是    | 注册一次接近光传感器的回调函数,上报的数据类型为ProximityResponse。 |
Z
zengyawen 已提交
3595

H
HelloCrease 已提交
3596
**示例:** 
H
HelloCrease 已提交
3597
  ```js
L
li-yaoyao777 已提交
3598
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(data) {
Z
zengyawen 已提交
3599
      console.info('Distance: ' + data.distance);
Z
zengyawen 已提交
3600
    }
Z
zengyawen 已提交
3601 3602
  );
  ```
Z
zengyawen 已提交
3603

C
cff-gite 已提交
3604
### HUMIDITY<sup>(deprecated)</sup>
Z
zengyawen 已提交
3605

C
cff-gite 已提交
3606
once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback&lt;HumidityResponse&gt;): void
Z
zengyawen 已提交
3607

Z
zengyawen 已提交
3608
监听湿度传感器数据变化一次。
Z
zengyawen 已提交
3609

C
cff-gite 已提交
3610
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请用[sensor.once.HUMIDITY](#humidity9-1)
C
cff-gite 已提交
3611

C
cff-gite 已提交
3612 3613
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3614
**参数:** 
C
cff-gite 已提交
3615

H
HelloCrease 已提交
3616 3617 3618 3619
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。         |
| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | 是    | 注册一次湿度传感器的回调函数,上报的数据类型为HumidityResponse。 |
Z
zengyawen 已提交
3620

H
HelloCrease 已提交
3621
**示例:** 
H
HelloCrease 已提交
3622
  ```js
C
cff-gite 已提交
3623
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function(data) {
Z
zengyawen 已提交
3624
      console.info('Humidity: ' + data.humidity);
Z
zengyawen 已提交
3625
    }
Z
zengyawen 已提交
3626 3627
  );
  ```
Z
zengyawen 已提交
3628

C
cff-gite 已提交
3629
### BAROMETER<sup>(deprecated)</sup>
Z
zengyawen 已提交
3630

C
cff-gite 已提交
3631
once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback&lt;BarometerResponse&gt;): void
Z
zengyawen 已提交
3632

Z
zengyawen 已提交
3633
监听气压计传感器数据变化一次。
Z
zengyawen 已提交
3634

C
cff-gite 已提交
3635
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请用[sensor.once.BAROMETER](#barometer9-1)
C
cff-gite 已提交
3636

C
cff-gite 已提交
3637 3638
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3639
**参数:** 
C
cff-gite 已提交
3640

H
HelloCrease 已提交
3641 3642 3643 3644
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。       |
| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | 是    | 注册一次气压计传感器的回调函数,上报的数据类型为BarometerResponse。 |
Z
zengyawen 已提交
3645

H
HelloCrease 已提交
3646
**示例:** 
H
HelloCrease 已提交
3647
  ```js
C
cff-gite 已提交
3648
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) {
Z
zengyawen 已提交
3649
      console.info('Atmospheric pressure: ' + data.pressure);
Z
zengyawen 已提交
3650
    }
Z
zengyawen 已提交
3651 3652
  );
  ```
Z
zengyawen 已提交
3653

C
cff-gite 已提交
3654
### HALL<sup>(deprecated)</sup>
Z
zengyawen 已提交
3655

C
cff-gite 已提交
3656
once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback&lt;HallResponse&gt;): void
Z
zengyawen 已提交
3657

Z
zengyawen 已提交
3658
监听霍尔传感器数据变化一次。
Z
zengyawen 已提交
3659

C
cff-gite 已提交
3660
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请用[sensor.once.HALL](#hall9-1)
C
cff-gite 已提交
3661

C
cff-gite 已提交
3662 3663
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3664
**参数:** 
C
cff-gite 已提交
3665

H
HelloCrease 已提交
3666 3667 3668 3669
| 参数名      | 类型                                       | 必填   | 说明                                   |
| -------- | ---------------------------------------- | ---- | ------------------------------------ |
| type     | [SensorType](#sensortype)                | 是    | 霍尔传感器类型为SENSOR_TYPE_ID_HALL。         |
| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | 是    | 注册一次霍尔传感器的回调函数,上报的数据类型为HallResponse。 |
Z
zengyawen 已提交
3670

H
HelloCrease 已提交
3671
**示例:** 
H
HelloCrease 已提交
3672
  ```js
C
cff-gite 已提交
3673
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function(data) {
Z
zengyawen 已提交
3674
      console.info('Status: ' + data.status);
Z
zengyawen 已提交
3675
    }
Z
zengyawen 已提交
3676 3677
  );
  ```
Z
zengyawen 已提交
3678

C
cff-gite 已提交
3679
### AMBIENT_LIGHT<sup>(deprecated)</sup>
Z
zengyawen 已提交
3680

C
cff-gite 已提交
3681
once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback&lt;LightResponse&gt;): void
Z
zengyawen 已提交
3682

Z
zengyawen 已提交
3683
监听环境光传感器数据变化一次。
Z
zengyawen 已提交
3684

C
cff-gite 已提交
3685
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请用[sensor.once.AMBIENT_LIGHT](#ambient_light9-1)
C
cff-gite 已提交
3686

C
cff-gite 已提交
3687 3688
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3689
**参数:** 
C
cff-gite 已提交
3690

H
HelloCrease 已提交
3691 3692 3693 3694
| 参数名      | 类型                                       | 必填   | 说明                                     |
| -------- | ---------------------------------------- | ---- | -------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 |
| callback | Callback&lt;[LightResponse](#lightresponse)&gt; | 是    | 注册一次环境光传感器的回调函数,上报的数据类型为LightResponse。 |
Z
zengyawen 已提交
3695

H
HelloCrease 已提交
3696
**示例:** 
C
cff-gite 已提交
3697

H
HelloCrease 已提交
3698
  ```js
C
cff-gite 已提交
3699
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function(data) {
3700
      console.info(' Illumination: ' + data.intensity);
Z
zengyawen 已提交
3701
    }
Z
zengyawen 已提交
3702 3703
  );
  ```
Z
zengyawen 已提交
3704

C
cff-gite 已提交
3705
### ORIENTATION<sup>(deprecated)</sup>
Z
zengyawen 已提交
3706

C
cff-gite 已提交
3707
once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback&lt;OrientationResponse&gt;): void
Z
zengyawen 已提交
3708

Z
zengyawen 已提交
3709
监听方向传感器数据变化一次。
Z
zengyawen 已提交
3710

C
cff-gite 已提交
3711
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请用[sensor.once.ORIENTATION](#orientation9-1) 
C
cff-gite 已提交
3712

C
cff-gite 已提交
3713 3714
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3715
**参数:** 
C
cff-gite 已提交
3716

H
HelloCrease 已提交
3717 3718 3719 3720
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 方向传感器类型为SENSOR_TYPE_ID_ORIENTATION。      |
| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | 是    | 注册一次方向传感器的回调函数,上报的数据类型为OrientationResponse。 |
Z
zengyawen 已提交
3721

H
HelloCrease 已提交
3722
**示例:** 
H
HelloCrease 已提交
3723
  ```js
C
cff-gite 已提交
3724
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function(data) {
C
cff-gite 已提交
3725 3726 3727
      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 Z axis: ' + data.alpha);
Z
zengyawen 已提交
3728
    }
Z
zengyawen 已提交
3729 3730
  );
  ```
Z
zengyawen 已提交
3731

C
cff-gite 已提交
3732
### ROTATION_VECTOR<sup>(deprecated)</sup>
Z
zengyawen 已提交
3733

C
cff-gite 已提交
3734
once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback&lt;RotationVectorResponse&gt;): void
Z
zengyawen 已提交
3735

Z
zengyawen 已提交
3736
监听旋转矢量传感器数据变化一次。
Z
zengyawen 已提交
3737

C
cff-gite 已提交
3738
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请用[sensor.once.ROTATION_VECTOR](#rotation_vector9-1)  
C
cff-gite 已提交
3739

C
cff-gite 已提交
3740 3741
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3742
**参数:** 
C
cff-gite 已提交
3743

H
HelloCrease 已提交
3744 3745 3746 3747
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 |
| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | 是    | 注册一次旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 |
Z
zengyawen 已提交
3748

H
HelloCrease 已提交
3749
**示例:** 
H
HelloCrease 已提交
3750
  ```js
C
cff-gite 已提交
3751
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(data) {
Z
zengyawen 已提交
3752 3753 3754
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
C
cff-gite 已提交
3755
      console.info('Scalar quantity: ' + data.w);
Z
zengyawen 已提交
3756
    }
Z
zengyawen 已提交
3757 3758
  );
  ```
Z
zengyawen 已提交
3759

C
cff-gite 已提交
3760
### HEART_RATE<sup>(deprecated)</sup>
Z
zengyawen 已提交
3761

C
cff-gite 已提交
3762
once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRateResponse&gt;): void
Z
zengyawen 已提交
3763

Z
zengyawen 已提交
3764
监听心率传感器数据变化一次。
Z
zengyawen 已提交
3765

C
cff-gite 已提交
3766
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.once.HEART_BEAT_RATE](#heart_beat_rate9)
H
h00514358 已提交
3767

C
cff-gite 已提交
3768
**需要权限**:ohos.permission.HEART_RATE  
C
cff-gite 已提交
3769 3770 3771

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3772
**参数:** 
C
cff-gite 已提交
3773

H
HelloCrease 已提交
3774 3775 3776 3777
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。       |
| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | 是    | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 |
Z
zengyawen 已提交
3778

H
h00514358 已提交
3779
### HEART_BEAT_RATE<sup>9+</sup>
H
h00514358 已提交
3780

C
cff-gite 已提交
3781
once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback&lt;HeartRateResponse&gt;): void		
H
h00514358 已提交
3782

H
h00514358 已提交
3783
订阅一次心率传感器数据。
H
h00514358 已提交
3784

C
cff-gite 已提交
3785
**需要权限**:ohos.permission.HEART_RATE 
H
h00514358 已提交
3786 3787 3788 3789

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**
C
cff-gite 已提交
3790 3791 3792 3793 3794

| 参数名   | 类型                                                    | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type     | [SensorType](#sensortype)                               | 是   | 心率传感器类型为SENSOR_TYPE_ID_HEART_BEAT_RATE。             |
| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | 是   | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 |
H
h00514358 已提交
3795 3796

**示例:**
C
cff-gite 已提交
3797

H
h00514358 已提交
3798 3799 3800 3801 3802 3803 3804
  ```js
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, function(data) {
      console.info("Heart rate: " + data.heartRate);
    }
  );
  ```

C
cff-gite 已提交
3805
### WEAR_DETECTION<sup>(deprecated)</sup>
Z
zengyawen 已提交
3806

C
cff-gite 已提交
3807
once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback&lt;WearDetectionResponse&gt;): void
Z
zengyawen 已提交
3808

Z
zengyawen 已提交
3809
监听佩戴检测传感器数据变化一次。
Z
zengyawen 已提交
3810

C
cff-gite 已提交
3811
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.once.WEAR_DETECTION](#wear_detection9-1)  
C
cff-gite 已提交
3812

C
cff-gite 已提交
3813 3814
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3815
**参数:** 
C
cff-gite 已提交
3816

H
HelloCrease 已提交
3817 3818 3819 3820
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 |
| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | 是    | 注册一次穿戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 |
Z
zengyawen 已提交
3821

H
HelloCrease 已提交
3822
**示例:** 
H
HelloCrease 已提交
3823
  ```js
C
cff-gite 已提交
3824
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function(data) {
Z
zengyawen 已提交
3825
      console.info("Wear status: "+ data.value);
Z
zengyawen 已提交
3826
    }
Z
zengyawen 已提交
3827 3828
  );
  ```
Z
zengyawen 已提交
3829

C
cff-gite 已提交
3830
## sensor.off<sup>(deprecated)</sup>
H
HelloCrease 已提交
3831

C
cff-gite 已提交
3832
### ACCELEROMETER<sup>(deprecated)</sup>
Z
zengyawen 已提交
3833

C
cff-gite 已提交
3834
off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback&lt;AccelerometerResponse&gt;): void
C
cff-gite 已提交
3835 3836

取消订阅传感器数据。
Z
zengyawen 已提交
3837

C
cff-gite 已提交
3838
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.ACCELEROMETER](#accelerometer9-2)  
C
cff-gite 已提交
3839

L
li-yaoyao777 已提交
3840
**需要权限**:ohos.permission.ACCELEROMETER
C
cff-gite 已提交
3841 3842 3843

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3844
**参数:** 
C
cff-gite 已提交
3845

H
HelloCrease 已提交
3846 3847 3848 3849
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 |
| callback | Callback&lt;[AccelerometerResponse](#accelerometerresponse)&gt; | 是    | 取消注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 |
C
cff-gite 已提交
3850

H
HelloCrease 已提交
3851
**示例:** 
C
cff-gite 已提交
3852

H
HelloCrease 已提交
3853
```js
C
cff-gite 已提交
3854 3855 3856 3857 3858 3859 3860 3861
function callback(data) {
    console.info('x-coordinate component: ' + data.x);
    console.info('Y-coordinate component: ' + data.y);
    console.info('Z-coordinate component: ' + data.z);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback);
```

C
cff-gite 已提交
3862
### ACCELEROMETER_UNCALIBRATED<sup>(deprecated)</sup>
C
cff-gite 已提交
3863

C
cff-gite 已提交
3864
off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callback&lt;AccelerometerUncalibratedResponse&gt;): void
Z
zengyawen 已提交
3865

Z
zengyawen 已提交
3866
取消订阅传感器数据。
Z
zengyawen 已提交
3867

C
cff-gite 已提交
3868
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.ACCELEROMETER_UNCALIBRATED](#accelerometer_uncalibrated9-2) 
C
cff-gite 已提交
3869

L
li-yaoyao777 已提交
3870
**需要权限**:ohos.permission.ACCELEROMETER
C
cff-gite 已提交
3871

C
cff-gite 已提交
3872 3873
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3874
**参数:** 
C
cff-gite 已提交
3875

H
HelloCrease 已提交
3876 3877 3878 3879
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的未校准加速度计传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 |
| callback | Callback&lt;[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)&gt; | 是    | 取消注册未校准加速度计传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 |
Z
zengyawen 已提交
3880

H
HelloCrease 已提交
3881
**示例:** 
C
cff-gite 已提交
3882

H
HelloCrease 已提交
3883
```js
C
cff-gite 已提交
3884 3885 3886 3887 3888 3889 3890 3891 3892 3893 3894
function callback(data) {
    console.info('X-coordinate component: ' + data.x);
    console.info('Y-coordinate component: ' + data.y);
    console.info('Z-coordinate component: ' + data.z);
    console.info('X-coordinate bias: ' + data.biasX);
    console.info('Y-coordinate bias: ' + data.biasY);
    console.info('Z-coordinate bias: ' + data.biasZ);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback);
```

C
cff-gite 已提交
3895
### AMBIENT_LIGHT<sup>(deprecated)</sup>
C
cff-gite 已提交
3896

C
cff-gite 已提交
3897
off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback&lt;LightResponse&gt;): void
C
cff-gite 已提交
3898 3899 3900

取消订阅传感器数据。

C
cff-gite 已提交
3901
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.AMBIENT_LIGHT](#ambient_light9-2) 
C
cff-gite 已提交
3902

C
cff-gite 已提交
3903 3904
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3905
**参数:** 
C
cff-gite 已提交
3906

H
HelloCrease 已提交
3907 3908 3909 3910
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 |
| callback | Callback&lt;[LightResponse](#lightresponse)&gt; | 是    | 取消注册环境光传感器的回调函数,上报的数据类型为LightResponse。   |
C
cff-gite 已提交
3911

H
HelloCrease 已提交
3912
**示例:** 
C
cff-gite 已提交
3913

H
HelloCrease 已提交
3914
```js
C
cff-gite 已提交
3915 3916 3917 3918 3919 3920
function callback(data) {
    console.info(' Illumination: ' + data.intensity);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback);
```

C
cff-gite 已提交
3921
### AMBIENT_TEMPERATURE<sup>(deprecated)</sup>
C
cff-gite 已提交
3922

C
cff-gite 已提交
3923
off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback&lt;AmbientTemperatureResponse&gt;): void
C
cff-gite 已提交
3924 3925 3926

取消订阅传感器数据。

C
cff-gite 已提交
3927
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.AMBIENT_TEMPERATURE](#ambient_temperature9-2) 
C
cff-gite 已提交
3928

C
cff-gite 已提交
3929 3930
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3931
**参数:** 
C
cff-gite 已提交
3932

H
HelloCrease 已提交
3933 3934 3935 3936
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 |
| callback | Callback&lt;[AmbientTemperatureResponse](#ambienttemperatureresponse)&gt; | 是    | 取消注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 |
C
cff-gite 已提交
3937

H
HelloCrease 已提交
3938
**示例:** 
C
cff-gite 已提交
3939

H
HelloCrease 已提交
3940
```js
C
cff-gite 已提交
3941 3942 3943 3944 3945 3946
function callback(data) {
     console.info('Temperature: ' + data.temperature);
}
sensor.off( sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback);
```

C
cff-gite 已提交
3947
### BAROMETER<sup>(deprecated)</sup>
C
cff-gite 已提交
3948

C
cff-gite 已提交
3949
off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback&lt;BarometerResponse&gt;): void
C
cff-gite 已提交
3950 3951 3952

取消订阅传感器数据。

C
cff-gite 已提交
3953
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.BAROMETER](#barometer9-2) 
C
cff-gite 已提交
3954

C
cff-gite 已提交
3955 3956
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3957
**参数:** 
C
cff-gite 已提交
3958

H
HelloCrease 已提交
3959 3960 3961 3962
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。 |
| callback | Callback&lt;[BarometerResponse](#barometerresponse)&gt; | 是    | 取消注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 |
C
cff-gite 已提交
3963

H
HelloCrease 已提交
3964
**示例:** 
C
cff-gite 已提交
3965

H
HelloCrease 已提交
3966
```js
C
cff-gite 已提交
3967 3968 3969 3970 3971 3972
function callback(data) {
     console.info('Atmospheric pressure: ' + data.pressure);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback);
```

C
cff-gite 已提交
3973
### GRAVITY<sup>(deprecated)</sup>
C
cff-gite 已提交
3974

C
cff-gite 已提交
3975
off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback&lt;GravityResponse&gt;): void
C
cff-gite 已提交
3976 3977 3978

取消订阅传感器数据。

C
cff-gite 已提交
3979
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.GRAVITY](#gravity9-2)  
C
cff-gite 已提交
3980

C
cff-gite 已提交
3981 3982
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
3983
**参数:** 
C
cff-gite 已提交
3984

H
HelloCrease 已提交
3985 3986 3987 3988
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的重力传感器类型为SENSOR_TYPE_ID_GRAVITY。    |
| callback | Callback&lt;[GravityResponse](#gravityresponse)&gt; | 是    | 取消注册注册重力传感器的回调函数,上报的数据类型为GravityResponse。 |
C
cff-gite 已提交
3989

H
HelloCrease 已提交
3990
**示例:** 
C
cff-gite 已提交
3991

H
HelloCrease 已提交
3992
```js
C
cff-gite 已提交
3993 3994 3995 3996 3997 3998 3999 4000
function callback(data) {
    console.info('X-coordinate component: ' + data.x);
    console.info('Y-coordinate component: ' + data.y);
    console.info('Z-coordinate component: ' + data.z);
}
sensor.off( sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, callback);
```

C
cff-gite 已提交
4001
### GYROSCOPE<sup>(deprecated)</sup>
C
cff-gite 已提交
4002

C
cff-gite 已提交
4003
off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback&lt;GyroscopeResponse&gt;): void
C
cff-gite 已提交
4004 4005 4006

取消订阅传感器数据。

C
cff-gite 已提交
4007
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.GYROSCOPE](#gyroscope9-2) 
C
cff-gite 已提交
4008

L
li-yaoyao777 已提交
4009
**需要权限**:ohos.permission.GYROSCOPE
C
cff-gite 已提交
4010 4011 4012

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4013
**参数:** 
C
cff-gite 已提交
4014

H
HelloCrease 已提交
4015 4016 4017 4018
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。 |
| callback | Callback&lt;[GyroscopeResponse](#gyroscoperesponse)&gt; | 是    | 取消注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 |
C
cff-gite 已提交
4019

H
HelloCrease 已提交
4020
**示例:** 
C
cff-gite 已提交
4021

H
HelloCrease 已提交
4022
```js
C
cff-gite 已提交
4023 4024 4025 4026 4027 4028 4029 4030
function callback(data) {
    console.info('X-coordinate component: ' + data.x);
    console.info('Y-coordinate component: ' + data.y);
    console.info('Z-coordinate component: ' + data.z);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback);
```

C
cff-gite 已提交
4031
### GYROSCOPE_UNCALIBRATED<sup>(deprecated)</sup>
C
cff-gite 已提交
4032

H
HelloCrease 已提交
4033
off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback&lt;GyroscopeUncalibratedResponse&gt;): void
C
cff-gite 已提交
4034 4035 4036

取消订阅传感器数据。

C
cff-gite 已提交
4037
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.GYROSCOPE_UNCALIBRATED](#gyroscope_uncalibrated9-2)  
C
cff-gite 已提交
4038

L
li-yaoyao777 已提交
4039
**需要权限**:ohos.permission.GYROSCOPE
C
cff-gite 已提交
4040 4041 4042

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4043
**参数:** 
C
cff-gite 已提交
4044

H
HelloCrease 已提交
4045 4046 4047 4048
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 |
| callback | Callback&lt;[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)&gt; | 是    | 取消注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 |
C
cff-gite 已提交
4049

H
HelloCrease 已提交
4050
**示例:** 
C
cff-gite 已提交
4051

H
HelloCrease 已提交
4052
```js
C
cff-gite 已提交
4053 4054 4055 4056 4057 4058 4059 4060
function callback(data) {
    console.info('X-coordinate component: ' + data.x);
    console.info('Y-coordinate component: ' + data.y);
    console.info('Z-coordinate component: ' + data.z);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback);
```

C
cff-gite 已提交
4061
### HALL<sup>(deprecated)</sup>
C
cff-gite 已提交
4062

C
cff-gite 已提交
4063
off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback&lt;HallResponse&gt;): void
C
cff-gite 已提交
4064 4065 4066

取消订阅传感器数据。

C
cff-gite 已提交
4067
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.HALL](#hall9-2) 
C
cff-gite 已提交
4068

C
cff-gite 已提交
4069 4070
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4071
**参数:** 
C
cff-gite 已提交
4072

H
HelloCrease 已提交
4073 4074 4075 4076
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的霍尔传感器类型为SENSOR_TYPE_ID_HALL。       |
| callback | Callback&lt;[HallResponse](#hallresponse)&gt; | 是    | 取消注册霍尔传感器的回调函数,上报的数据类型为&nbsp;HallResponse。 |
C
cff-gite 已提交
4077

H
HelloCrease 已提交
4078
**示例:** 
C
cff-gite 已提交
4079

H
HelloCrease 已提交
4080
```js
C
cff-gite 已提交
4081 4082 4083 4084 4085 4086
function callback(data) {
    console.info('Status: ' + data.status);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback);
```

C
cff-gite 已提交
4087
### HEART_RATE<sup>(deprecated)</sup>
C
cff-gite 已提交
4088

C
cff-gite 已提交
4089
off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback&lt;HeartRateResponse&gt;): void
C
cff-gite 已提交
4090 4091 4092

取消订阅传感器数据。

C
cff-gite 已提交
4093
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.HEART_BEAT_RATE](#heart_beat_rate9)
H
h00514358 已提交
4094

C
cff-gite 已提交
4095
**需要权限**:ohos.permission.HEALTH_DATA 
C
cff-gite 已提交
4096 4097 4098

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4099
**参数:** 
C
cff-gite 已提交
4100

C
cff-gite 已提交
4101 4102 4103 4104
| 参数名   | 类型                                                    | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type     | [SensorType](#sensortype)                               | 是   | 要取消订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。      |
| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | 是   | 取消注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 |
C
cff-gite 已提交
4105

H
h00514358 已提交
4106
### HEART_BEAT_RATE<sup>9+</sup>
H
h00514358 已提交
4107

C
cff-gite 已提交
4108
off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback&lt;HeartRateResponse&gt;): void
H
h00514358 已提交
4109 4110 4111

取消订阅传感器数据。

C
cff-gite 已提交
4112
**需要权限**:ohos.permission.HEALTH_DATA 
H
h00514358 已提交
4113 4114 4115 4116 4117

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

C
cff-gite 已提交
4118 4119 4120 4121
| 参数名   | 类型                                                    | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type     | [SensorType](#sensortype)                               | 是   | 要取消订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_BEAT_RATE。 |
| callback | Callback&lt;[HeartRateResponse](#heartrateresponse)&gt; | 是   | 取消注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 |
H
h00514358 已提交
4122 4123 4124 4125 4126 4127 4128 4129 4130 4131

**示例:**

```js
function callback(data) {
    console.info("Heart rate: " + data.heartRate);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HEART_BEAT_RATE, callback);
```

C
cff-gite 已提交
4132
### HUMIDITY<sup>(deprecated)</sup>
C
cff-gite 已提交
4133

C
cff-gite 已提交
4134
off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback&lt;HumidityResponse&gt;): void
C
cff-gite 已提交
4135 4136 4137

取消订阅传感器数据。

C
cff-gite 已提交
4138
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.HUMIDITY](#humidity9-2) 
C
cff-gite 已提交
4139

C
cff-gite 已提交
4140 4141
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4142
**参数:** 
C
cff-gite 已提交
4143

H
HelloCrease 已提交
4144 4145 4146 4147
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。   |
| callback | Callback&lt;[HumidityResponse](#humidityresponse)&gt; | 是    | 取消注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 |
C
cff-gite 已提交
4148

H
HelloCrease 已提交
4149
**示例:** 
C
cff-gite 已提交
4150

H
HelloCrease 已提交
4151
```js
C
cff-gite 已提交
4152 4153 4154 4155 4156 4157
function callback(data) {
    console.info('Humidity: ' + data.humidity);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, callback);
```

C
cff-gite 已提交
4158
### LINEAR_ACCELERATION<sup>(deprecated)</sup>
C
cff-gite 已提交
4159

C
cff-gite 已提交
4160
off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback&lt;LinearAccelerometerResponse&gt;): void
C
cff-gite 已提交
4161 4162 4163

取消订阅传感器数据。

C
cff-gite 已提交
4164
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.LINEAR_ACCELEROMETER](#linear_accelerometer9)
H
h00514358 已提交
4165

L
li-yaoyao777 已提交
4166
**需要权限**:ohos.permission.ACCELEROMETER
C
cff-gite 已提交
4167 4168 4169

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4170
**参数:** 
C
cff-gite 已提交
4171

H
HelloCrease 已提交
4172 4173 4174 4175
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 |
| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | 是    | 取消注册性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 |
C
cff-gite 已提交
4176

H
h00514358 已提交
4177
### LINEAR_ACCELEROMETER<sup>9+</sup>
H
h00514358 已提交
4178

C
cff-gite 已提交
4179
off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback?:Callback&lt;LinearAccelerometerResponse&gt;): void
H
h00514358 已提交
4180 4181 4182

取消订阅传感器数据。

L
li-yaoyao777 已提交
4183
**需要权限**:ohos.permission.ACCELEROMETER
H
h00514358 已提交
4184 4185 4186 4187 4188

**系统能力**:SystemCapability.Sensors.Sensor

**参数:**

C
cff-gite 已提交
4189 4190 4191 4192
| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type     | [SensorType](#sensortype)                                    | 是   | 要取消订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELEROMETER。 |
| callback | Callback&lt;[LinearAccelerometerResponse](#linearaccelerometerresponse)&gt; | 是   | 取消注册性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 |
H
h00514358 已提交
4193 4194 4195 4196 4197 4198 4199 4200 4201 4202 4203 4204

**示例:**

```js
function callback(data) {
    console.info('X-coordinate component: ' + data.x);
    console.info('Y-coordinate component: ' + data.y);
    console.info('Z-coordinate component: ' + data.z);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER, callback);
```

C
cff-gite 已提交
4205
### MAGNETIC_FIELD<sup>(deprecated)</sup>
C
cff-gite 已提交
4206

C
cff-gite 已提交
4207
 off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback?: Callback&lt;MagneticFieldResponse&gt;): void
C
cff-gite 已提交
4208 4209 4210

取消订阅传感器数据。

C
cff-gite 已提交
4211
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.MAGNETIC_FIELD](#magnetic_field9-2) 
C
cff-gite 已提交
4212

C
cff-gite 已提交
4213 4214
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4215
**参数:** 
C
cff-gite 已提交
4216

H
HelloCrease 已提交
4217 4218 4219 4220
| 参数名              | 类型                                       | 必填   | 说明                                       |
| ---------------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type             | [SensorType](#sensortype)                | 是    | 要取消订阅的磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 |
| callbackcallback | Callback&lt;[MagneticFieldResponse](#magneticfieldresponse)&gt; | 是    | 取消注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 |
C
cff-gite 已提交
4221

H
HelloCrease 已提交
4222
**示例:** 
C
cff-gite 已提交
4223

H
HelloCrease 已提交
4224
```js
C
cff-gite 已提交
4225 4226 4227 4228 4229 4230 4231 4232
function callback(data) {
    console.info('X-coordinate component: ' + data.x);
    console.info('Y-coordinate component: ' + data.y);
    console.info('Z-coordinate component: ' + data.z);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback);
```

C
cff-gite 已提交
4233
### MAGNETIC_FIELD_UNCALIBRATED<sup>(deprecated)</sup>
C
cff-gite 已提交
4234

C
cff-gite 已提交
4235
 off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback?: Callback&lt;MagneticFieldUncalibratedResponse&gt;): void
C
cff-gite 已提交
4236 4237 4238

取消订阅传感器数据。

C
cff-gite 已提交
4239
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.MAGNETIC_FIELD_UNCALIBRATED](#magnetic_field_uncalibrated9-2) 
C
cff-gite 已提交
4240

C
cff-gite 已提交
4241 4242
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4243
**参数:** 
C
cff-gite 已提交
4244

H
HelloCrease 已提交
4245 4246 4247 4248
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 |
| callback | Callback&lt;[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)&gt; | 是    | 取消注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 |
C
cff-gite 已提交
4249

H
HelloCrease 已提交
4250
**示例:** 
C
cff-gite 已提交
4251

H
HelloCrease 已提交
4252
```js
C
cff-gite 已提交
4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263
function callback(data) {
    console.info('X-coordinate component: ' + data.x);
    console.info('Y-coordinate component: ' + data.y);
    console.info('Z-coordinate component: ' + data.z);
    console.info('X-coordinate bias: ' + data.biasX);
    console.info('Y-coordinate bias: ' + data.biasY);
    console.info('Z-coordinate bias: ' + data.biasZ);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback);
```

C
cff-gite 已提交
4264
### ORIENTATION<sup>(deprecated)</sup>
C
cff-gite 已提交
4265

C
cff-gite 已提交
4266
 off(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback?: Callback&lt;OrientationResponse&gt;): void
C
cff-gite 已提交
4267 4268 4269

取消订阅传感器数据。

C
cff-gite 已提交
4270
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.ORIENTATION](#orientation9-2) 
C
cff-gite 已提交
4271

C
cff-gite 已提交
4272 4273
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4274
**参数:** 
C
cff-gite 已提交
4275

H
HelloCrease 已提交
4276 4277 4278 4279
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的方向传感器类型为SENSOR_TYPE_ID_ORIENTATION |
| callback | Callback&lt;[OrientationResponse](#orientationresponse)&gt; | 是    | 取消注册方向传感器的回调函数,上报的数据类型为OrientationResponse。 |
C
cff-gite 已提交
4280

H
HelloCrease 已提交
4281
**示例:** 
C
cff-gite 已提交
4282

H
HelloCrease 已提交
4283
```js
C
cff-gite 已提交
4284
function callback(data) {
C
cff-gite 已提交
4285 4286 4287
    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 Z axis: ' + data.alpha);
C
cff-gite 已提交
4288 4289 4290 4291
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback);
```

C
cff-gite 已提交
4292
### PEDOMETER<sup>(deprecated)</sup>
C
cff-gite 已提交
4293

C
cff-gite 已提交
4294
off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback&lt;PedometerResponse&gt;): void
C
cff-gite 已提交
4295 4296 4297

取消订阅传感器数据。

C
cff-gite 已提交
4298
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.PEDOMETER](#pedometer9-2) 
C
cff-gite 已提交
4299

C
cff-gite 已提交
4300
**需要权限**:ohos.permission.ACTIVITY_MOTION
C
cff-gite 已提交
4301

C
cff-gite 已提交
4302 4303
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4304
**参数:** 
C
cff-gite 已提交
4305

H
HelloCrease 已提交
4306 4307 4308 4309
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。  |
| callback | Callback&lt;[PedometerResponse](#pedometerresponse)&gt; | 是    | 取消注册计步传感器的回调函数,上报的数据类型为PedometerResponse。 |
C
cff-gite 已提交
4310

H
HelloCrease 已提交
4311
**示例:** 
C
cff-gite 已提交
4312

H
HelloCrease 已提交
4313
```js
C
cff-gite 已提交
4314 4315 4316 4317 4318 4319
function callback(data) {
    console.info('Steps: ' + data.steps);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback);
```

C
cff-gite 已提交
4320
### PEDOMETER_DETECTION<sup>(deprecated)</sup>
C
cff-gite 已提交
4321

C
cff-gite 已提交
4322
off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback&lt;PedometerDetectionResponse&gt;): void
C
cff-gite 已提交
4323 4324 4325

取消订阅传感器数据。

C
cff-gite 已提交
4326
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.PEDOMETER_DETECTION](#pedometer_detection9-2) 
C
cff-gite 已提交
4327

C
cff-gite 已提交
4328 4329 4330 4331
**需要权限**:ohos.permission.ACTIVITY_MOTION

**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4332
**参数:** 
C
cff-gite 已提交
4333

H
HelloCrease 已提交
4334 4335 4336 4337
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 |
| callback | Callback&lt;[PedometerDetectionResponse](#pedometerdetectionresponse)&gt; | 是    | 取消注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 |
C
cff-gite 已提交
4338

H
HelloCrease 已提交
4339
**示例:** 
C
cff-gite 已提交
4340

H
HelloCrease 已提交
4341
```js
C
cff-gite 已提交
4342 4343 4344 4345 4346 4347
function callback(data) {
    console.info('Scalar data: ' + data.scalar);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback);
```

C
cff-gite 已提交
4348
### PROXIMITY<sup>(deprecated)</sup>
C
cff-gite 已提交
4349

C
cff-gite 已提交
4350
off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback&lt;ProximityResponse&gt;): void
C
cff-gite 已提交
4351 4352 4353

取消订阅传感器数据。

C
cff-gite 已提交
4354
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.PROXIMITY](#proximity9-2) 
C
cff-gite 已提交
4355

C
cff-gite 已提交
4356 4357
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4358
**参数:** 
C
cff-gite 已提交
4359

H
HelloCrease 已提交
4360 4361 4362 4363
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。 |
| callback | Callback&lt;[ProximityResponse](#proximityresponse)&gt; | 是    | 取消注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 |
C
cff-gite 已提交
4364

H
HelloCrease 已提交
4365
**示例:** 
C
cff-gite 已提交
4366

H
HelloCrease 已提交
4367
```js
C
cff-gite 已提交
4368 4369 4370 4371 4372 4373
function callback(data) {
    console.info('Distance: ' + data.distance);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, callback);
```

C
cff-gite 已提交
4374
### ROTATION_VECTOR<sup>(deprecated)</sup>
C
cff-gite 已提交
4375

C
cff-gite 已提交
4376
off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback&lt;RotationVectorResponse&gt;): void
C
cff-gite 已提交
4377 4378 4379

取消订阅传感器数据。

C
cff-gite 已提交
4380
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.ROTATION_VECTOR](#rotation_vector9-2) 
C
cff-gite 已提交
4381

C
cff-gite 已提交
4382 4383
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4384
**参数:** 
C
cff-gite 已提交
4385

H
HelloCrease 已提交
4386 4387 4388 4389
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 |
| callback | Callback&lt;[RotationVectorResponse](#rotationvectorresponse)&gt; | 是    | 取消注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 |
C
cff-gite 已提交
4390

H
HelloCrease 已提交
4391
**示例:** 
C
cff-gite 已提交
4392

H
HelloCrease 已提交
4393
```js
C
cff-gite 已提交
4394 4395 4396 4397
function callback(data) {
    console.info('X-coordinate component: ' + data.x);
    console.info('Y-coordinate component: ' + data.y);
    console.info('Z-coordinate component: ' + data.z);
C
cff-gite 已提交
4398
    console.info('Scalar quantity: ' + data.w);
C
cff-gite 已提交
4399 4400 4401 4402
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback);
```

C
cff-gite 已提交
4403
### SIGNIFICANT_MOTION<sup>(deprecated)</sup>
C
cff-gite 已提交
4404

C
cff-gite 已提交
4405
off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback&lt;SignificantMotionResponse&gt;): void
C
cff-gite 已提交
4406 4407 4408

取消订阅传感器数据。

C
cff-gite 已提交
4409
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.SIGNIFICANT_MOTION](#significant_motion9-2) 
C
cff-gite 已提交
4410

C
cff-gite 已提交
4411 4412
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4413
**参数:** 
C
cff-gite 已提交
4414

H
HelloCrease 已提交
4415 4416 4417 4418
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的大幅动作传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 |
| callback | Callback&lt;[SignificantMotionResponse](#significantmotionresponse)&gt; | 是    | 取消注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 |
C
cff-gite 已提交
4419

H
HelloCrease 已提交
4420
**示例:** 
C
cff-gite 已提交
4421

H
HelloCrease 已提交
4422
```js
C
cff-gite 已提交
4423 4424 4425 4426 4427 4428
function callback(data) {
    console.info('Scalar data: ' + data.scalar);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback);
```

C
cff-gite 已提交
4429
### WEAR_DETECTION<sup>(deprecated)</sup>
C
cff-gite 已提交
4430

C
cff-gite 已提交
4431
off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback&lt;WearDetectionResponse&gt;): void
C
cff-gite 已提交
4432 4433 4434

取消订阅传感器数据。

C
cff-gite 已提交
4435
[newMethod](https://gitee.com/openharmony/docs/pulls/10074#newmethod),请使用[sensor.off.WEAR_DETECTION](#wear_detection9-2) 
C
cff-gite 已提交
4436

C
cff-gite 已提交
4437 4438
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4439
**参数:** 
C
cff-gite 已提交
4440

H
HelloCrease 已提交
4441 4442 4443 4444
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 |
| callback | Callback&lt;[WearDetectionResponse](#weardetectionresponse)&gt; | 是    | 取消注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 |
C
cff-gite 已提交
4445

H
HelloCrease 已提交
4446
**示例:** 
C
cff-gite 已提交
4447

H
HelloCrease 已提交
4448
```js
C
cff-gite 已提交
4449 4450 4451 4452 4453
function accCallback(data) {
    console.info('Wear status: ' + data.value);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, accCallback);
```
Z
zengyawen 已提交
4454

Z
zengyawen 已提交
4455 4456 4457 4458 4459 4460
## sensor.transformCoordinateSystem

transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: CoordinatesOptions, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void

旋转提供的旋转矩阵,使其可以以不同的方式表示坐标系。

C
cff-gite 已提交
4461 4462
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4463
**参数:** 
Z
zengyawen 已提交
4464

H
HelloCrease 已提交
4465 4466 4467 4468 4469
| 参数名              | 类型                                       | 必填   | 说明          |
| ---------------- | ---------------------------------------- | ---- | ----------- |
| inRotationVector | Array&lt;number&gt;                      | 是    | 表示旋转矩阵。     |
| coordinates      | [CoordinatesOptions](#coordinatesoptions) | 是    | 表示坐标系方向。    |
| callback         | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是    | 返回转换后的旋转矩阵。 |
Z
zengyawen 已提交
4470

H
HelloCrease 已提交
4471
**示例:** 
Z
zengyawen 已提交
4472

H
HelloCrease 已提交
4473
```js
C
cff-gite 已提交
4474
sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3}, function(err, data) {
H
HelloCrease 已提交
4475 4476 4477 4478
    if (err) {
        console.error("Operation failed. Error code: " + err.code + ", message: " + err.message);
        return;
    }
H
HelloCrease 已提交
4479
    console.info("Operation successed. Data obtained: " + data);
H
HelloCrease 已提交
4480 4481 4482 4483 4484
    for (var i=0; i < data.length; i++) {
        console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]);
    }
 })
```
Z
zengyawen 已提交
4485 4486 4487 4488 4489 4490
## sensor.transformCoordinateSystem

transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: CoordinatesOptions): Promise&lt;Array&lt;number&gt;&gt;

旋转提供的旋转矩阵,使其可以以不同的方式表示坐标系。

C
cff-gite 已提交
4491 4492
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4493
**参数:** 
Z
zengyawen 已提交
4494

H
HelloCrease 已提交
4495 4496 4497 4498
| 参数名              | 类型                                       | 必填   | 说明       |
| ---------------- | ---------------------------------------- | ---- | -------- |
| inRotationVector | Array&lt;number&gt;                      | 是    | 表示旋转矩阵。  |
| coordinates      | [CoordinatesOptions](#coordinatesoptions) | 是    | 表示坐标系方向。 |
Z
zengyawen 已提交
4499

H
HelloCrease 已提交
4500
**返回值:** 
Z
zengyawen 已提交
4501

H
HelloCrease 已提交
4502 4503 4504
| 类型                                 | 说明          |
| ---------------------------------- | ----------- |
| Promise&lt;Array&lt;number&gt;&gt; | 返回转换后的旋转矩阵。 |
Z
zengyawen 已提交
4505

H
HelloCrease 已提交
4506
**示例:** 
Z
zengyawen 已提交
4507

H
HelloCrease 已提交
4508
```js
C
cff-gite 已提交
4509
const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {x:2, y:3});
H
HelloCrease 已提交
4510 4511 4512 4513 4514 4515 4516 4517 4518
    promise.then((data) => {
        console.info("Operation successed.");
        for (var i=0; i < data.length; i++) {
            console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]);
        }
    }).catch((err) => {
           console.info("Operation failed");
})
```
Z
zengyawen 已提交
4519

Z
zengyawen 已提交
4520
## sensor.getGeomagneticField
Z
zengyawen 已提交
4521

Z
zengyawen 已提交
4522
getGeomagneticField(locationOptions: LocationOptions, timeMillis: number, callback: AsyncCallback&lt;GeomagneticResponse&gt;): void
Z
zengyawen 已提交
4523

Z
zengyawen 已提交
4524
获取地球上特定位置的地磁场。
Z
zengyawen 已提交
4525

C
cff-gite 已提交
4526 4527
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4528
**参数:** 
C
cff-gite 已提交
4529 4530 4531 4532 4533
| 参数名          | 类型                                                         | 必填 | 说明                               |
| --------------- | ------------------------------------------------------------ | ---- | ---------------------------------- |
| locationOptions | [LocationOptions](#locationoptions)                          | 是   | 地理位置。                         |
| timeMillis      | number                                                       | 是   | 表示获取磁偏角的时间,单位为毫秒。 |
| callback        | AsyncCallback&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 是   | 返回磁场信息。                     |
Z
zengyawen 已提交
4534

H
HelloCrease 已提交
4535
**示例:** 
H
HelloCrease 已提交
4536
```js
C
cff-gite 已提交
4537
sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000, function(err, data)  {
H
HelloCrease 已提交
4538 4539 4540 4541
    if (err) {
        console.error('Operation failed. Error code: ' + err.code + '; message: ' + err.message);
        return;
    }
C
cff-gite 已提交
4542
    console.info('sensor_getGeomagneticField_callback x: ' + data.x + ',y: ' + data.y + ',z: ' +
H
HelloCrease 已提交
4543 4544 4545 4546
	             data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle +
		     ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity);
});
```
Z
zengyawen 已提交
4547 4548 4549 4550 4551 4552
## sensor.getGeomagneticField

getGeomagneticField(locationOptions: LocationOptions, timeMillis: number): Promise&lt;GeomagneticResponse&gt;

获取地球上特定位置的地磁场。

C
cff-gite 已提交
4553 4554
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4555 4556 4557 4558 4559
**参数:** 
| 参数名             | 类型                                  | 必填   | 说明                |
| --------------- | ----------------------------------- | ---- | ----------------- |
| locationOptions | [LocationOptions](#locationoptions) | 是    | 地理位置。             |
| timeMillis      | number                              | 是    | 表示获取磁偏角的时间,单位为毫秒。 |
Z
zengyawen 已提交
4560

H
HelloCrease 已提交
4561 4562 4563 4564
**返回值:** 
| 类型                                       | 说明      |
| ---------------------------------------- | ------- |
| Promise&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 返回磁场信息。 |
Z
zengyawen 已提交
4565

H
HelloCrease 已提交
4566
**示例:** 
H
HelloCrease 已提交
4567
  ```js
C
cff-gite 已提交
4568
  const promise = sensor.getGeomagneticField({latitude:80, longitude:0, altitude:0}, 1580486400000);
Z
zengyawen 已提交
4569
      promise.then((data) => {
Z
zengyawen 已提交
4570 4571 4572
          console.info('sensor_getGeomagneticField_promise x: ' + data.x + ',y: ' + data.y + ',z: ' +
  	             data.z + ',geomagneticDip: ' + data.geomagneticDip + ',deflectionAngle: ' + data.deflectionAngle +
  		     ',levelIntensity: ' + data.levelIntensity + ',totalIntensity: ' + data.totalIntensity);
Z
zengyawen 已提交
4573
      }).catch((reason) => {
Z
zengyawen 已提交
4574 4575
          console.info('Operation failed.');
  })
Z
zengyawen 已提交
4576 4577
  ```

Z
zengyawen 已提交
4578 4579 4580 4581 4582 4583
## sensor.getAltitude

getAltitude(seaPressure: number, currentPressure: number, callback: AsyncCallback&lt;number&gt;): void

根据气压值获取设备所在的海拔高度。

C
cff-gite 已提交
4584 4585
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4586
**参数:** 
Z
zengyawen 已提交
4587

H
HelloCrease 已提交
4588 4589 4590 4591 4592
| 参数名             | 类型                          | 必填   | 说明                   |
| --------------- | --------------------------- | ---- | -------------------- |
| seaPressure     | number                      | 是    | 表示海平面气压值,单位为hPa。     |
| currentPressure | number                      | 是    | 表示设备所在高度的气压值,单位为hPa。 |
| callback        | AsyncCallback&lt;number&gt; | 是    | 返回设备所在的海拔高度,单位为米。    |
Z
zengyawen 已提交
4593

H
HelloCrease 已提交
4594
**示例:** 
Z
zengyawen 已提交
4595

H
HelloCrease 已提交
4596
  ```js
Z
zengyawen 已提交
4597 4598 4599 4600 4601 4602 4603 4604 4605 4606 4607 4608 4609 4610 4611 4612
  sensor.getAltitude(0, 200, function(err, data)  {
      if (err) {
          console.error(
  "Operation failed. Error code: " + err.code + ", message: " + err.message);
          return;
      }
          console.info("Successed to get getAltitude interface get data: " + data);
  });
  ```

## sensor.getAltitude

getAltitude(seaPressure: number, currentPressure: number): Promise&lt;number&gt;

根据气压值获取设备所在的海拔高度。

C
cff-gite 已提交
4613 4614
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4615
**参数:** 
Z
zengyawen 已提交
4616

H
HelloCrease 已提交
4617 4618 4619 4620
| 参数名             | 类型     | 必填   | 说明                   |
| --------------- | ------ | ---- | -------------------- |
| seaPressure     | number | 是    | 表示海平面气压值,单位为hPa。     |
| currentPressure | number | 是    | 表示设备所在高度的气压值,单位为hPa。 |
Z
zengyawen 已提交
4621

H
HelloCrease 已提交
4622
**返回值:** 
Z
zengyawen 已提交
4623

H
HelloCrease 已提交
4624 4625 4626
| 类型                    | 说明                 |
| --------------------- | ------------------ |
| Promise&lt;number&gt; | 返回设备所在的海拔高度(单位:米)。 |
Z
zengyawen 已提交
4627

H
HelloCrease 已提交
4628
**示例:** 
Z
zengyawen 已提交
4629

H
HelloCrease 已提交
4630
  ```js
Z
zengyawen 已提交
4631 4632 4633 4634 4635 4636 4637 4638 4639 4640 4641 4642 4643 4644 4645
  const promise = sensor.getAltitude(0, 200);
      promise.then((data) => {
          console.info(' sensor_getAltitude_Promise success', data);
      }).catch((err) => {
          console.error("Operation failed");
  })
  ```


## sensor.getGeomagneticDip

getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;number&gt;): void

根据倾斜矩阵计算地磁倾斜角。

C
cff-gite 已提交
4646 4647
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4648
**参数:** 
Z
zengyawen 已提交
4649

H
HelloCrease 已提交
4650 4651 4652 4653
| 参数名               | 类型                          | 必填   | 说明             |
| ----------------- | --------------------------- | ---- | -------------- |
| inclinationMatrix | Array&lt;number&gt;         | 是    | 表示倾斜矩阵。        |
| callback          | AsyncCallback&lt;number&gt; | 是    | 返回地磁倾斜角,单位为弧度。 |
Z
zengyawen 已提交
4654

H
HelloCrease 已提交
4655
**示例:** 
Z
zengyawen 已提交
4656

H
HelloCrease 已提交
4657
  ```js
Z
zengyawen 已提交
4658 4659
  sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data)  {
      if (err) {
C
cff-gite 已提交
4660
          console.error('SensorJsAPI--->Failed to register data, error code is:' + err.code + ', message: ' + 
Z
zengyawen 已提交
4661 4662 4663
                        err.message);
          return;
      }
H
HelloCrease 已提交
4664
          console.info("Successed to get getGeomagneticDip interface get data: " + data);
Z
zengyawen 已提交
4665 4666 4667 4668 4669 4670 4671 4672 4673
  })
  ```

## sensor.getGeomagneticDip

getGeomagneticDip(inclinationMatrix: Array&lt;number&gt;): Promise&lt;number&gt;

根据倾斜矩阵计算地磁倾斜角。

C
cff-gite 已提交
4674 4675
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4676
**参数:** 
Z
zengyawen 已提交
4677

H
HelloCrease 已提交
4678 4679 4680
| 参数名               | 类型                  | 必填   | 说明      |
| ----------------- | ------------------- | ---- | ------- |
| inclinationMatrix | Array&lt;number&gt; | 是    | 表示倾斜矩阵。 |
Z
zengyawen 已提交
4681

H
HelloCrease 已提交
4682
**返回值:** 
Z
zengyawen 已提交
4683

H
HelloCrease 已提交
4684 4685 4686
| 类型                    | 说明             |
| --------------------- | -------------- |
| Promise&lt;number&gt; | 返回地磁倾斜角,单位为弧度。 |
Z
zengyawen 已提交
4687

H
HelloCrease 已提交
4688
**示例:** 
Z
zengyawen 已提交
4689

H
HelloCrease 已提交
4690
  ```js
Z
zengyawen 已提交
4691 4692
  const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]);
      promise.then((data) => {
C
cff-gite 已提交
4693
          console.info('getGeomagneticDip_promise successed', data);
Z
zengyawen 已提交
4694 4695 4696 4697 4698 4699 4700
      }).catch((err) => {
           console.error("Operation failed");
  })
  ```

## sensor. getAngleModify

H
HelloCrease 已提交
4701
getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
Z
zengyawen 已提交
4702 4703 4704

获取两个旋转矩阵之间的角度变化。

C
cff-gite 已提交
4705 4706
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4707
**参数:** 
Z
zengyawen 已提交
4708

H
HelloCrease 已提交
4709 4710 4711 4712 4713
| 参数名                   | 类型                                       | 必填   | 说明                 |
| --------------------- | ---------------------------------------- | ---- | ------------------ |
| currentRotationMatrix | Array&lt;number&gt;                      | 是    | 表示当前旋转矩阵。          |
| preRotationMatrix     | Array&lt;number&gt;                      | 是    | 表示旋转矩阵。            |
| callback              | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是    | 返回z、x、y轴方向的旋转角度变化。 |
Z
zengyawen 已提交
4714

H
HelloCrease 已提交
4715
**示例:** 
Z
zengyawen 已提交
4716

H
HelloCrease 已提交
4717
  ```js
Z
zengyawen 已提交
4718 4719
  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) {
H
HelloCrease 已提交
4720
          console.error('Failed to register data, error code is: ' + err.code + ', message: ' + 
Z
zengyawen 已提交
4721 4722 4723 4724
                        err.message);
          return;
      }
      for (var i=0; i < data.length; i++) {
H
HelloCrease 已提交
4725
          console.info("data[" + i + "]: " + data[i]);
Z
zengyawen 已提交
4726 4727 4728 4729 4730 4731 4732 4733 4734 4735 4736
      }
  })
  ```


## sensor. getAngleModify

getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;

获取两个旋转矩阵之间的角度变化。

C
cff-gite 已提交
4737 4738
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4739
**参数:** 
Z
zengyawen 已提交
4740

H
HelloCrease 已提交
4741 4742 4743 4744
| 参数名                   | 类型                  | 必填   | 说明        |
| --------------------- | ------------------- | ---- | --------- |
| currentRotationMatrix | Array&lt;number&gt; | 是    | 表示当前旋转矩阵。 |
| preRotationMatrix     | Array&lt;number&gt; | 是    | 表示旋转矩阵。   |
Z
zengyawen 已提交
4745

H
HelloCrease 已提交
4746
**返回值:** 
Z
zengyawen 已提交
4747

H
HelloCrease 已提交
4748 4749 4750
| 类型                                 | 说明                 |
| ---------------------------------- | ------------------ |
| Promise&lt;Array&lt;number&gt;&gt; | 返回z、x、y轴方向的旋转角度变化。 |
Z
zengyawen 已提交
4751

H
HelloCrease 已提交
4752
**示例:** 
Z
zengyawen 已提交
4753

H
HelloCrease 已提交
4754
  ```js
Z
zengyawen 已提交
4755 4756
  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) => {
H
HelloCrease 已提交
4757
          console.info('getAngleModifiy_promise success');
Z
zengyawen 已提交
4758
          for (var i=0; i < data.length; i++) {
H
HelloCrease 已提交
4759
              console.info("data[" + i + "]: " + data[i]);
Z
zengyawen 已提交
4760 4761
          }
      }).catch((reason) => {
H
HelloCrease 已提交
4762
          console.info("promise::catch", reason);
Z
zengyawen 已提交
4763 4764 4765 4766 4767 4768 4769 4770 4771 4772
  })
  ```


## sensor.createRotationMatrix

createRotationMatrix(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void

将旋转矢量转换为旋转矩阵。

C
cff-gite 已提交
4773 4774
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4775
**参数:** 
Z
zengyawen 已提交
4776

H
HelloCrease 已提交
4777 4778 4779 4780
| 参数名            | 类型                                       | 必填   | 说明      |
| -------------- | ---------------------------------------- | ---- | ------- |
| rotationVector | Array&lt;number&gt;                      | 是    | 表示旋转矢量。 |
| callback       | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是    | 返回旋转矩阵。 |
Z
zengyawen 已提交
4781

H
HelloCrease 已提交
4782
**示例:** 
Z
zengyawen 已提交
4783

H
HelloCrease 已提交
4784
  ```js
Z
zengyawen 已提交
4785 4786
  sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) {
      if (err) {
H
HelloCrease 已提交
4787
          console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + 
Z
zengyawen 已提交
4788 4789 4790
                        err.message);
          return;
      }
C
cff-gite 已提交
4791
      for (var i=0; i < data.length; i++) {
L
li-yaoyao777 已提交
4792
          console.info("data[" + i + "]: " + data[i]);
Z
zengyawen 已提交
4793 4794 4795 4796 4797 4798 4799 4800 4801 4802 4803
      }
  })
  ```


## sensor.createRotationMatrix

createRotationMatrix(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;

将旋转矢量转换为旋转矩阵。

C
cff-gite 已提交
4804 4805
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4806
**参数:** 
Z
zengyawen 已提交
4807

H
HelloCrease 已提交
4808 4809 4810
| 参数名            | 类型                  | 必填   | 说明      |
| -------------- | ------------------- | ---- | ------- |
| rotationVector | Array&lt;number&gt; | 是    | 表示旋转矢量。 |
Z
zengyawen 已提交
4811

H
HelloCrease 已提交
4812
**返回值:** 
Z
zengyawen 已提交
4813

H
HelloCrease 已提交
4814 4815 4816
| 类型                                 | 说明      |
| ---------------------------------- | ------- |
| Promise&lt;Array&lt;number&gt;&gt; | 返回旋转矩阵。 |
Z
zengyawen 已提交
4817

H
HelloCrease 已提交
4818
**示例:** 
Z
zengyawen 已提交
4819

H
HelloCrease 已提交
4820
  ```js
Z
zengyawen 已提交
4821 4822
  const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]);
      promise.then((data) => {
H
HelloCrease 已提交
4823
          console.info('createRotationMatrix_promise success');
C
cff-gite 已提交
4824
          for (var i=0; i < data.length; i++) {
H
HelloCrease 已提交
4825
              console.info("data[" + i + "]: " + data[i]);
Z
zengyawen 已提交
4826 4827
          }
      }).catch((reason) => {
H
HelloCrease 已提交
4828
          console.info("promise::catch", reason);
Z
zengyawen 已提交
4829 4830 4831 4832 4833 4834 4835 4836 4837 4838
  })	
  ```


## sensor.createQuaternion

createQuaternion(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void

将旋转矢量转换为四元数。

C
cff-gite 已提交
4839 4840
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4841
**参数:** 
Z
zengyawen 已提交
4842

H
HelloCrease 已提交
4843 4844 4845 4846
| 参数名            | 类型                                       | 必填   | 说明      |
| -------------- | ---------------------------------------- | ---- | ------- |
| rotationVector | Array&lt;number&gt;                      | 是    | 表示旋转矢量。 |
| callback       | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是    | 返回四元数。  |
Z
zengyawen 已提交
4847

H
HelloCrease 已提交
4848
**示例:** 
Z
zengyawen 已提交
4849

H
HelloCrease 已提交
4850
  ```js
Z
zengyawen 已提交
4851 4852
  sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data)  {
      if (err) {
H
HelloCrease 已提交
4853
          console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + 
Z
zengyawen 已提交
4854 4855 4856 4857
                        err.message);
          return;
      }
      for (var i=0; i < data.length; i++) {
H
HelloCrease 已提交
4858
          console.info("data[" + i + "]: " + data[i]);
Z
zengyawen 已提交
4859 4860 4861 4862 4863 4864 4865 4866 4867 4868 4869
      }
  })
  ```


## sensor.createQuaternion

createQuaternion(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;

将旋转矢量转换为四元数。

C
cff-gite 已提交
4870 4871
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4872
**参数:** 
Z
zengyawen 已提交
4873

H
HelloCrease 已提交
4874 4875 4876
| 参数名            | 类型                  | 必填   | 说明      |
| -------------- | ------------------- | ---- | ------- |
| rotationVector | Array&lt;number&gt; | 是    | 表示旋转矢量。 |
Z
zengyawen 已提交
4877

H
HelloCrease 已提交
4878
**返回值:** 
Z
zengyawen 已提交
4879

H
HelloCrease 已提交
4880 4881 4882
| 类型                                 | 说明     |
| ---------------------------------- | ------ |
| Promise&lt;Array&lt;number&gt;&gt; | 返回四元数。 |
Z
zengyawen 已提交
4883

H
HelloCrease 已提交
4884
**示例:** 
Z
zengyawen 已提交
4885

H
HelloCrease 已提交
4886
  ```js
Z
zengyawen 已提交
4887 4888 4889 4890
  const promise = sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877]);
      promise.then((data) => {
          console.info('createQuaternion_promise successed');
          for (var i=0; i < data.length; i++) {
H
HelloCrease 已提交
4891
              console.info("data[" + i + "]: " + data[i]);
Z
zengyawen 已提交
4892 4893 4894 4895 4896 4897 4898 4899 4900 4901 4902 4903 4904
          }
      }).catch((err) => {
          console.info('promise failed');
  })
  ```


## sensor.getDirection

getDirection(rotationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void

根据旋转矩阵计算设备的方向。

C
cff-gite 已提交
4905 4906
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4907
**参数:** 
Z
zengyawen 已提交
4908

H
HelloCrease 已提交
4909 4910 4911 4912
| 参数名            | 类型                                       | 必填   | 说明                 |
| -------------- | ---------------------------------------- | ---- | ------------------ |
| rotationMatrix | Array&lt;number&gt;                      | 是    | 表示旋转矩阵。            |
| callback       | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是    | 返回围绕z、x、y轴方向的旋转角度。 |
Z
zengyawen 已提交
4913

H
HelloCrease 已提交
4914
**示例:** 
Z
zengyawen 已提交
4915

H
HelloCrease 已提交
4916
  ```js
Z
zengyawen 已提交
4917 4918
  sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data)  {
      if (err) {
H
HelloCrease 已提交
4919
          console.error('SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
Z
zengyawen 已提交
4920 4921 4922
                        err.message);
          return;
      }
H
HelloCrease 已提交
4923
      console.info("SensorJsAPI--->Successed to get getDirection interface get data: " + data);
Z
zengyawen 已提交
4924
      for (var i = 1; i < data.length; i++) {
H
HelloCrease 已提交
4925
          console.info("sensor_getDirection_callback" + data[i]);
Z
zengyawen 已提交
4926 4927 4928 4929 4930 4931 4932 4933 4934 4935 4936
      }
  })
  ```


## sensor.getDirection

getDirection(rotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;

根据旋转矩阵计算设备的方向。

C
cff-gite 已提交
4937 4938
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4939
**参数:** 
Z
zengyawen 已提交
4940

H
HelloCrease 已提交
4941 4942 4943
| 参数名            | 类型                  | 必填   | 说明      |
| -------------- | ------------------- | ---- | ------- |
| rotationMatrix | Array&lt;number&gt; | 是    | 表示旋转矩阵。 |
Z
zengyawen 已提交
4944

H
HelloCrease 已提交
4945
**返回值:** 
Z
zengyawen 已提交
4946

H
HelloCrease 已提交
4947 4948 4949
| 类型                                 | 说明                 |
| ---------------------------------- | ------------------ |
| Promise&lt;Array&lt;number&gt;&gt; | 返回围绕z、x、y轴方向的旋转角度。 |
Z
zengyawen 已提交
4950

H
HelloCrease 已提交
4951
**示例:** 
Z
zengyawen 已提交
4952

H
HelloCrease 已提交
4953
  ```js
Z
zengyawen 已提交
4954 4955
  const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]);
      promise.then((data) => {
H
HelloCrease 已提交
4956
          console.info('sensor_getAltitude_Promise success', data);
Z
zengyawen 已提交
4957
          for (var i = 1; i < data.length; i++) {
H
HelloCrease 已提交
4958
              console.info("sensor_getDirection_promise" + data[i]);
Z
zengyawen 已提交
4959 4960 4961 4962 4963 4964 4965 4966 4967 4968 4969 4970 4971
          }
      }).catch((err) => {
          console.info('promise failed');
  })
  ```


## sensor.createRotationMatrix

createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&gt;, callback: AsyncCallback&lt;RotationMatrixResponse&gt;): void

根据重力矢量和地磁矢量计算旋转矩阵。

C
cff-gite 已提交
4972 4973
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
4974
**参数:** 
Z
zengyawen 已提交
4975

H
HelloCrease 已提交
4976 4977 4978 4979 4980
| 参数名         | 类型                                       | 必填   | 说明      |
| ----------- | ---------------------------------------- | ---- | ------- |
| gravity     | Array&lt;number&gt;                      | 是    | 表示重力向量。 |
| geomagnetic | Array&lt;number&gt;                      | 是    | 表示地磁矢量。 |
| callback    | AsyncCallback&lt;[RotationMatrixResponse](#rotationmatrixresponse)&gt; | 是    | 返回旋转矩阵。 |
Z
zengyawen 已提交
4981

H
HelloCrease 已提交
4982
**示例:** 
Z
zengyawen 已提交
4983

H
HelloCrease 已提交
4984
  ```js
Z
zengyawen 已提交
4985 4986
  sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(err, data)  {
      if (err) {
L
li-yaoyao777 已提交
4987
          console.error('error code is: ' + err.code + ', message: ' + err.message);
Z
zengyawen 已提交
4988 4989
          return;
      }
L
li-yaoyao777 已提交
4990
      console.info(JSON.stringify(data));
Z
zengyawen 已提交
4991 4992 4993 4994 4995 4996 4997 4998 4999 5000
  })
  ```


## sensor.createRotationMatrix

createRotationMatrix(gravity: Array&lt;number&gt;, geomagnetic: Array&lt;number&gt;,): Promise&lt;RotationMatrixResponse&gt;

根据重力矢量和地磁矢量计算旋转矩阵。

C
cff-gite 已提交
5001 5002
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
5003
**参数:** 
Z
zengyawen 已提交
5004

H
HelloCrease 已提交
5005 5006 5007 5008
| 参数名         | 类型                  | 必填   | 说明      |
| ----------- | ------------------- | ---- | ------- |
| gravity     | Array&lt;number&gt; | 是    | 表示重力向量。 |
| geomagnetic | Array&lt;number&gt; | 是    | 表示地磁矢量。 |
Z
zengyawen 已提交
5009

H
HelloCrease 已提交
5010
**返回值:** 
Z
zengyawen 已提交
5011

H
HelloCrease 已提交
5012 5013 5014
| 类型                                       | 说明      |
| ---------------------------------------- | ------- |
| Promise&lt;[RotationMatrixResponse](#rotationmatrixresponse)&gt; | 返回旋转矩阵。 |
Z
zengyawen 已提交
5015

H
HelloCrease 已提交
5016
**示例:** 
Z
zengyawen 已提交
5017

H
HelloCrease 已提交
5018
  ```js
Z
zengyawen 已提交
5019 5020
  const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]);
      promise.then((data) => {
L
li-yaoyao777 已提交
5021
          console.info(JSON.stringify(data));
Z
zengyawen 已提交
5022
      }).catch((err) => {
H
HelloCrease 已提交
5023
          console.info('promise failed');
Z
zengyawen 已提交
5024 5025 5026
  })
  ```

C
cff-gite 已提交
5027
## sensor.getSensorList<sup>9+</sup>
C
cff-gite 已提交
5028

C
cff-gite 已提交
5029
 getSensorList(callback: AsyncCallback<Array&lt;Sensor&gt;>): void
C
cff-gite 已提交
5030 5031 5032 5033 5034 5035 5036

获取设备上的所有传感器信息。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

C
cff-gite 已提交
5037 5038 5039
| 参数名   | 类型                                           | 必填 | 说明             |
| -------- | ---------------------------------------------- | ---- | ---------------- |
| callback | AsyncCallback<Array&lt;[Sensor](#sensor9)&gt;> | 是   | 返回传感器列表。 |
C
cff-gite 已提交
5040 5041 5042

**示例:** 

C
cff-gite 已提交
5043
```js
C
cff-gite 已提交
5044
sensor.getSensorList((error, data) => {
C
cff-gite 已提交
5045
    if (error) {
C
cff-gite 已提交
5046
        console.error('getSensorList failed');
C
cff-gite 已提交
5047
    } else {
C
cff-gite 已提交
5048
        console.info("getSensorList callback in" + data.length);
C
cff-gite 已提交
5049
        for (var i = 0; i < data.length; i++) {
C
cff-gite 已提交
5050
            console.info("getSensorList " + JSON.stringify(data[i]));
C
cff-gite 已提交
5051
        }
C
cff-gite 已提交
5052 5053
    }
});
C
cff-gite 已提交
5054 5055
```

C
cff-gite 已提交
5056
## sensor.getSensorList<sup>9+</sup>
C
cff-gite 已提交
5057

C
cff-gite 已提交
5058
 getSensorList(): Promise< Array&lt;Sensor&gt;>
C
cff-gite 已提交
5059 5060 5061 5062 5063 5064 5065

获取设备上的所有传感器信息。

**系统能力**:SystemCapability.Sensors.Sensor

**返回值:** 

C
cff-gite 已提交
5066 5067 5068
| 参数名  | 类型                                     | 必填 | 说明             |
| ------- | ---------------------------------------- | ---- | ---------------- |
| promise | Promise<Array&lt;[Sensor](#sensor9)&gt;> | 是   | 返回传感器列表。 |
C
cff-gite 已提交
5069 5070 5071

**示例:** 

C
cff-gite 已提交
5072
```js
C
cff-gite 已提交
5073 5074
sensor.getSensorList().then((data) => {
    console.info("getSensorList promise in" + data.length);
C
cff-gite 已提交
5075
    for (var i = 0; i < data.length; i++) {
C
cff-gite 已提交
5076
        console.info("getSensorList " + JSON.stringify(data[i]));
C
cff-gite 已提交
5077 5078
     }
}, (error)=>{
C
cff-gite 已提交
5079
    console.error('getSensorList failed');
C
cff-gite 已提交
5080
});
C
cff-gite 已提交
5081 5082
```

C
cff-gite 已提交
5083
##  sensor.getSingleSensor<sup>9+</sup>
C
cff-gite 已提交
5084

C
cff-gite 已提交
5085
getSingleSensor(type: SensorId, callback: AsyncCallback&lt;Sensor&gt;): void
C
cff-gite 已提交
5086 5087 5088 5089 5090 5091 5092

获取指定类型的传感器信息。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

C
cff-gite 已提交
5093 5094
| 参数名   | 类型                                    | 必填 | 说明             |
| -------- | --------------------------------------- | ---- | ---------------- |
C
cff-gite 已提交
5095
| type     | SensorId                                | 是   | 传感器类型。     |
C
cff-gite 已提交
5096
| callback | AsyncCallback&lt;[Sensor](#sensor9)&gt; | 是   | 返回传感器信息。 |
C
cff-gite 已提交
5097

C
cff-gite 已提交
5098
**示例:**
C
cff-gite 已提交
5099

C
cff-gite 已提交
5100
```js
C
cff-gite 已提交
5101
 sensor.getSingleSensor(sensor.SensorId.SENSOR_TYPE_ID_ACCELEROMETER, (error, data) => {
C
cff-gite 已提交
5102
     if (error) {
C
cff-gite 已提交
5103
         console.error('getSingleSensor failed');
C
cff-gite 已提交
5104 5105 5106 5107
     } else {
         console.info("getSingleSensor " + JSON.stringify(data));
     }
});
C
cff-gite 已提交
5108 5109
```

C
cff-gite 已提交
5110
##  sensor.getSingleSensor<sup>9+</sup>
C
cff-gite 已提交
5111

C
cff-gite 已提交
5112
 getSingleSensor(type: SensorId): Promise&lt;Sensor&gt;
C
cff-gite 已提交
5113 5114 5115 5116 5117 5118 5119

获取指定类型的传感器信息。

**系统能力**:SystemCapability.Sensors.Sensor

**参数:** 

C
cff-gite 已提交
5120 5121 5122
| 参数名 | 类型     | 必填 | 说明         |
| ------ | -------- | ---- | ------------ |
| type   | SensorId | 是   | 传感器类型。 |
C
cff-gite 已提交
5123 5124 5125

**返回值:** 

C
cff-gite 已提交
5126 5127 5128
| 参数名  | 类型                              | 必填 | 说明             |
| ------- | --------------------------------- | ---- | ---------------- |
| promise | Promise&lt;[Sensor](#sensor9)&gt; | 是   | 返回传感器信息。 |
C
cff-gite 已提交
5129 5130 5131

**示例:**

C
cff-gite 已提交
5132
```js
C
cff-gite 已提交
5133
sensor.getSingleSensor(sensor.SensorId.SENSOR_TYPE_ID_ACCELEROMETER).then((data) => {
C
cff-gite 已提交
5134 5135 5136 5137
    console.info("getSingleSensor " + JSON.stringify(data));
}, (error)=>{
    console.error('getSingleSensor failed');
});
C
cff-gite 已提交
5138 5139
```

Z
zengyawen 已提交
5140
## SensorType
Z
zengyawen 已提交
5141 5142 5143

表示要订阅或取消订阅的传感器类型。

C
cff-gite 已提交
5144 5145
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5146

C
cff-gite 已提交
5147 5148 5149 5150 5151 5152 5153 5154 5155 5156 5157 5158 5159 5160 5161 5162 5163 5164 5165 5166 5167 5168 5169 5170 5171
| 名称                                                      | 默认值 | 说明                   |
| --------------------------------------------------------- | ------ | ---------------------- |
| SENSOR_TYPE_ID_ACCELEROMETER                              | 1      | 加速度传感器。         |
| SENSOR_TYPE_ID_GYROSCOPE                                  | 2      | 陀螺仪传感器。         |
| SENSOR_TYPE_ID_AMBIENT_LIGHT                              | 5      | 环境光传感器。         |
| SENSOR_TYPE_ID_MAGNETIC_FIELD                             | 6      | 磁场传感器。           |
| SENSOR_TYPE_ID_BAROMETER                                  | 8      | 气压计传感器。         |
| SENSOR_TYPE_ID_HALL                                       | 10     | 霍尔传感器。           |
| SENSOR_TYPE_ID_PROXIMITY                                  | 12     | 接近光传感器。         |
| SENSOR_TYPE_ID_HUMIDITY                                   | 13     | 湿度传感器。           |
| SENSOR_TYPE_ID_ORIENTATION                                | 256    | 方向传感器。           |
| SENSOR_TYPE_ID_GRAVITY                                    | 257    | 重力传感器。           |
| SENSOR_TYPE_ID_LINEAR_ACCELERATION<sup>(deprecated)</sup> | 258    | 线性加速度传感器。     |
| SENSOR_TYPE_ID_LINEAR_ACCELEROMETER<sup>9+</sup>          | 258    | 线性加速度传感器。     |
| SENSOR_TYPE_ID_ROTATION_VECTOR                            | 259    | 旋转矢量传感器。       |
| SENSOR_TYPE_ID_AMBIENT_TEMPERATURE                        | 260    | 环境温度传感器。       |
| SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED                | 261    | 未校准磁场传感器。     |
| SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED                     | 263    | 未校准陀螺仪传感器。   |
| SENSOR_TYPE_ID_SIGNIFICANT_MOTION                         | 264    | 有效运动传感器。       |
| SENSOR_TYPE_ID_PEDOMETER_DETECTION                        | 265    | 计步检测传感器。       |
| SENSOR_TYPE_ID_PEDOMETER                                  | 266    | 计步传感器。           |
| SENSOR_TYPE_ID_HEART_RATE<sup>(deprecated)</sup>          | 278    | 心率传感器。           |
| SENSOR_TYPE_ID_HEART_BEAT_RATE<sup>9+</sup>               | 278    | 心率传感器。           |
| SENSOR_TYPE_ID_WEAR_DETECTION                             | 280    | 佩戴检测传感器。       |
| SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED                 | 281    | 未校准加速度计传感器。 |
Z
zengyawen 已提交
5172 5173


Z
zengyawen 已提交
5174 5175 5176 5177
## Response

传感器数据的时间戳。

C
cff-gite 已提交
5178 5179
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

C
cff-gite 已提交
5180 5181 5182 5183
| 名称      | 参数类型 | 可读 | 可写 | 说明                     |
| --------- | -------- | ---- | ---- | ------------------------ |
| timestamp | number   | 是   | 是   | 传感器数据上报的时间戳。 |

C
cff-gite 已提交
5184
## Sensor<sup>9+</sup>
C
cff-gite 已提交
5185 5186 5187 5188 5189

指示传感器信息。

**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

C
cff-gite 已提交
5190 5191 5192 5193 5194
| 名称            | 参数类型 | 说明                   |
| --------------- | -------- | ---------------------- |
| venderName      | string   | 传感器供应商。         |
| firmwareVersion | string   | 传感器固件版本。       |
| hardwareVersion | string   | 传感器硬件版本。       |
C
cff-gite 已提交
5195
| sensorId        | number   | 传感器类型id。         |
C
cff-gite 已提交
5196
| maxRange        | number   | 传感器的最大测量范围。 |
C
cff-gite 已提交
5197 5198
| minSamplePeriod | number   | 允许的最小采样周期。   |
| maxSamplePeriod | number   | 允许的最大采样周期。   |
C
cff-gite 已提交
5199 5200
| precision       | number   | 传感器精度。           |
| power           | number   | 传感器电源。           |
C
cff-gite 已提交
5201

Z
zengyawen 已提交
5202
## AccelerometerResponse
Z
zengyawen 已提交
5203

Z
zengyawen 已提交
5204
加速度传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5205

C
cff-gite 已提交
5206 5207
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5208

H
HelloCrease 已提交
5209 5210 5211 5212 5213
| 名称   | 参数类型   | 可读   | 可写   | 说明                     |
| ---- | ------ | ---- | ---- | ---------------------- |
| x    | number | 是    | 是    | 施加在设备x轴的加速度,单位 : m/s2。 |
| y    | number | 是    | 是    | 施加在设备y轴的加速度,单位 : m/s2。 |
| z    | number | 是    | 是    | 施加在设备z轴的加速度,单位 : m/s2。 |
Z
zengyawen 已提交
5214 5215 5216


## LinearAccelerometerResponse
Z
zengyawen 已提交
5217

Z
zengyawen 已提交
5218
线性加速度传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5219

C
cff-gite 已提交
5220 5221
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5222

H
HelloCrease 已提交
5223 5224 5225 5226 5227
| 名称   | 参数类型   | 可读   | 可写   | 说明                       |
| ---- | ------ | ---- | ---- | ------------------------ |
| x    | number | 是    | 是    | 施加在设备x轴的线性加速度,单位 : m/s2。 |
| y    | number | 是    | 是    | 施加在设备y轴的线性加速度,单位 : m/s2。 |
| z    | number | 是    | 是    | 施加在设备z轴的线性加速度,单位 : m/s2。 |
Z
zengyawen 已提交
5228 5229 5230


## AccelerometerUncalibratedResponse
Z
zengyawen 已提交
5231

Z
zengyawen 已提交
5232
未校准加速度计传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5233

C
cff-gite 已提交
5234 5235
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5236

H
HelloCrease 已提交
5237 5238 5239 5240 5241 5242 5243 5244
| 名称    | 参数类型   | 可读   | 可写   | 说明                           |
| ----- | ------ | ---- | ---- | ---------------------------- |
| x     | number | 是    | 是    | 施加在设备x轴未校准的加速度,单位 : m/s2。    |
| y     | number | 是    | 是    | 施加在设备y轴未校准的加速度,单位 : m/s2。    |
| z     | number | 是    | 是    | 施加在设备z轴未校准的加速度,单位 : m/s2。    |
| biasX | number | 是    | 是    | 施加在设备x轴未校准的加速度偏量,单位 : m/s2。  |
| biasY | number | 是    | 是    | 施加在设备上y轴未校准的加速度偏量,单位 : m/s2。 |
| biasZ | number | 是    | 是    | 施加在设备z轴未校准的加速度偏量,单位 : m/s2。  |
Z
zengyawen 已提交
5245 5246 5247


## GravityResponse
Z
zengyawen 已提交
5248

Z
zengyawen 已提交
5249
重力传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5250

C
cff-gite 已提交
5251 5252
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5253

H
HelloCrease 已提交
5254 5255 5256 5257 5258
| 名称   | 参数类型   | 可读   | 可写   | 说明                       |
| ---- | ------ | ---- | ---- | ------------------------ |
| x    | number | 是    | 是    | 施加在设备x轴的重力加速度,单位 : m/s2。 |
| y    | number | 是    | 是    | 施加在设备y轴的重力加速度,单位 : m/s2。 |
| z    | number | 是    | 是    | 施加在设备z轴的重力加速度,单位 : m/s2。 |
Z
zengyawen 已提交
5259 5260 5261


## OrientationResponse
Z
zengyawen 已提交
5262

Z
zengyawen 已提交
5263
方向传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5264

C
cff-gite 已提交
5265 5266
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5267

H
HelloCrease 已提交
5268 5269
| 名称    | 参数类型   | 可读   | 可写   | 说明                |
| ----- | ------ | ---- | ---- | ----------------- |
5270
| alpha | number | 是    | 是    | 设备围绕Z轴的旋转角度,单位:度。 |
H
HelloCrease 已提交
5271 5272
| beta  | number | 是    | 是    | 设备围绕X轴的旋转角度,单位:度。 |
| gamma | number | 是    | 是    | 设备围绕Y轴的旋转角度,单位:度。 |
Z
zengyawen 已提交
5273 5274 5275


## RotationVectorResponse
Z
zengyawen 已提交
5276

Z
zengyawen 已提交
5277
旋转矢量传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5278

C
cff-gite 已提交
5279 5280
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5281

H
HelloCrease 已提交
5282 5283 5284 5285 5286 5287
| 名称   | 参数类型   | 可读   | 可写   | 说明        |
| ---- | ------ | ---- | ---- | --------- |
| x    | number | 是    | 是    | 旋转矢量x轴分量。 |
| y    | number | 是    | 是    | 旋转矢量y轴分量。 |
| z    | number | 是    | 是    | 旋转矢量z轴分量。 |
| w    | number | 是    | 是    | 标量。       |
Z
zengyawen 已提交
5288 5289 5290


## GyroscopeResponse
Z
zengyawen 已提交
5291

Z
zengyawen 已提交
5292
陀螺仪传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5293

C
cff-gite 已提交
5294 5295
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5296

H
HelloCrease 已提交
5297 5298 5299 5300 5301
| 名称   | 参数类型   | 可读   | 可写   | 说明                  |
| ---- | ------ | ---- | ---- | ------------------- |
| x    | number | 是    | 是    | 设备x轴的旋转角速度,单位rad/s。 |
| y    | number | 是    | 是    | 设备y轴的旋转角速度,单位rad/s。 |
| z    | number | 是    | 是    | 设备z轴的旋转角速度,单位rad/s。 |
Z
zengyawen 已提交
5302 5303 5304


## GyroscopeUncalibratedResponse
Z
zengyawen 已提交
5305

Z
zengyawen 已提交
5306
未校准陀螺仪传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5307

C
cff-gite 已提交
5308 5309
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5310

H
HelloCrease 已提交
5311 5312 5313 5314 5315 5316 5317 5318
| 名称    | 参数类型   | 可读   | 可写   | 说明                       |
| ----- | ------ | ---- | ---- | ------------------------ |
| x     | number | 是    | 是    | 设备x轴未校准的旋转角速度,单位rad/s。   |
| y     | number | 是    | 是    | 设备y轴未校准的旋转角速度,单位rad/s。   |
| z     | number | 是    | 是    | 设备z轴未校准的旋转角速度,单位rad/s。   |
| biasX | number | 是    | 是    | 设备x轴未校准的旋转角速度偏量,单位rad/s。 |
| biasY | number | 是    | 是    | 设备y轴未校准的旋转角速度偏量,单位rad/s。 |
| biasZ | number | 是    | 是    | 设备z轴未校准的旋转角速度偏量,单位rad/s。 |
Z
zengyawen 已提交
5319 5320 5321


## SignificantMotionResponse
Z
zengyawen 已提交
5322

Z
zengyawen 已提交
5323
有效运动传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5324

C
cff-gite 已提交
5325 5326
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5327

H
HelloCrease 已提交
5328 5329 5330
| 名称     | 参数类型   | 可读   | 可写   | 说明                                       |
| ------ | ------ | ---- | ---- | ---------------------------------------- |
| scalar | number | 是    | 是    | 表示剧烈运动程度。测量三个物理轴(x、y&nbsp;&nbsp;z)上,设备是否存在大幅度运动;如果取值为1则代表存在大幅度运动,取值为0则代表没有大幅度运动。 |
Z
zengyawen 已提交
5331 5332 5333


## ProximityResponse
Z
zengyawen 已提交
5334

Z
zengyawen 已提交
5335
接近光传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5336

C
cff-gite 已提交
5337 5338
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5339

H
HelloCrease 已提交
5340 5341 5342
| 名称       | 参数类型   | 可读   | 可写   | 说明                           |
| -------- | ------ | ---- | ---- | ---------------------------- |
| distance | number | 是    | 是    | 可见物体与设备显示器的接近程度。0表示接近,1表示远离。 |
Z
zengyawen 已提交
5343 5344 5345


## LightResponse
Z
zengyawen 已提交
5346

Z
zengyawen 已提交
5347
环境光传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5348

C
cff-gite 已提交
5349 5350
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5351

H
HelloCrease 已提交
5352 5353 5354
| 名称        | 参数类型   | 可读   | 可写   | 说明          |
| --------- | ------ | ---- | ---- | ----------- |
| intensity | number | 是    | 是    | 光强(单位:勒克斯)。 |
Z
zengyawen 已提交
5355 5356 5357


## HallResponse
Z
zengyawen 已提交
5358

Z
zengyawen 已提交
5359
霍尔传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5360

C
cff-gite 已提交
5361 5362
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5363

C
cff-gite 已提交
5364 5365
| 名称   | 参数类型 | 可读 | 可写 | 说明                                                         |
| ------ | -------- | ---- | ---- | ------------------------------------------------------------ |
C
cff-gite 已提交
5366
| status | number   | 是   | 是   | 显示霍尔状态。测量设备周围是否存在磁力吸引,0表示没有,大于0表示有。 |
Z
zengyawen 已提交
5367 5368 5369


## MagneticFieldResponse
Z
zengyawen 已提交
5370

Z
zengyawen 已提交
5371
磁场传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5372

C
cff-gite 已提交
5373 5374
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5375

C
cff-gite 已提交
5376 5377 5378 5379 5380
| 名称 | 参数类型 | 可读 | 可写 | 说明                         |
| ---- | -------- | ---- | ---- | ---------------------------- |
| x    | number   | 是   | 是   | x轴环境磁场强度,单位 : μT。 |
| y    | number   | 是   | 是   | y轴环境磁场强度,单位 : μT。 |
| z    | number   | 是   | 是   | z轴环境磁场强度,单位 : μT。 |
Z
zengyawen 已提交
5381 5382 5383


## MagneticFieldUncalibratedResponse
Z
zengyawen 已提交
5384

Z
zengyawen 已提交
5385
未校准磁场传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5386

C
cff-gite 已提交
5387 5388
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5389

H
HelloCrease 已提交
5390 5391 5392 5393 5394 5395 5396 5397
| 名称    | 参数类型   | 可读   | 可写   | 说明                     |
| ----- | ------ | ---- | ---- | ---------------------- |
| x     | number | 是    | 是    | x轴未校准环境磁场强度,单位 : μT。   |
| y     | number | 是    | 是    | y轴未校准环境磁场强度,单位 : μT。   |
| z     | number | 是    | 是    | z轴未校准环境磁场强度,单位 : μT。   |
| biasX | number | 是    | 是    | x轴未校准环境磁场强度偏量,单位 : μT。 |
| biasY | number | 是    | 是    | y轴未校准环境磁场强度偏量,单位 : μT。 |
| biasZ | number | 是    | 是    | z轴未校准环境磁场强度偏量,单位 : μT。 |
Z
zengyawen 已提交
5398 5399 5400


## PedometerResponse
Z
zengyawen 已提交
5401

Z
zengyawen 已提交
5402
计步传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5403

C
cff-gite 已提交
5404 5405
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5406

H
HelloCrease 已提交
5407 5408 5409
| 名称    | 参数类型   | 可读   | 可写   | 说明       |
| ----- | ------ | ---- | ---- | -------- |
| steps | number | 是    | 是    | 用户的行走步数。 |
Z
zengyawen 已提交
5410 5411 5412


## HumidityResponse
Z
zengyawen 已提交
5413

Z
zengyawen 已提交
5414
湿度传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5415

C
cff-gite 已提交
5416 5417
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5418

H
HelloCrease 已提交
5419 5420 5421
| 名称       | 参数类型   | 可读   | 可写   | 说明                                   |
| -------- | ------ | ---- | ---- | ------------------------------------ |
| humidity | number | 是    | 是    | 湿度值。测量环境的相对湿度,以百分比&nbsp;(%)&nbsp;表示。 |
Z
zengyawen 已提交
5422 5423


C
cff-gite 已提交
5424
## PedometerDetectionResponse
Z
zengyawen 已提交
5425

Z
zengyawen 已提交
5426
计步检测传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5427

C
cff-gite 已提交
5428 5429
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5430

H
HelloCrease 已提交
5431 5432 5433
| 名称     | 参数类型   | 可读   | 可写   | 说明                                       |
| ------ | ------ | ---- | ---- | ---------------------------------------- |
| scalar | number | 是    | 是    | 计步器检测。检测用户的计步动作,如果取值为1则代表用户产生了计步行走的动作,取值为0则代表用户没有发生运动。 |
Z
zengyawen 已提交
5434 5435 5436


## AmbientTemperatureResponse
Z
zengyawen 已提交
5437

Z
zengyawen 已提交
5438
温度传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5439

C
cff-gite 已提交
5440 5441
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5442

H
HelloCrease 已提交
5443 5444 5445
| 名称          | 参数类型   | 可读   | 可写   | 说明            |
| ----------- | ------ | ---- | ---- | ------------- |
| temperature | number | 是    | 是    | 环境温度(单位:摄氏度)。 |
Z
zengyawen 已提交
5446 5447 5448


## BarometerResponse
Z
zengyawen 已提交
5449

Z
zengyawen 已提交
5450
气压计传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5451

C
cff-gite 已提交
5452 5453
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5454

H
HelloCrease 已提交
5455 5456 5457
| 名称       | 参数类型   | 可读   | 可写   | 说明           |
| -------- | ------ | ---- | ---- | ------------ |
| pressure | number | 是    | 是    | 压力值(单位:帕斯卡)。 |
Z
zengyawen 已提交
5458 5459 5460


## HeartRateResponse
Z
zengyawen 已提交
5461

Z
zengyawen 已提交
5462
心率传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5463

C
cff-gite 已提交
5464 5465
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5466

H
HelloCrease 已提交
5467 5468 5469
| 名称        | 参数类型   | 可读   | 可写   | 说明                    |
| --------- | ------ | ---- | ---- | --------------------- |
| heartRate | number | 是    | 是    | 心率值。测量用户的心率数值,单位:bpm。 |
Z
zengyawen 已提交
5470 5471 5472


## WearDetectionResponse
Z
zengyawen 已提交
5473

Z
zengyawen 已提交
5474
佩戴检测传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
5475

C
cff-gite 已提交
5476 5477
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
5478

H
HelloCrease 已提交
5479 5480 5481
| 名称    | 参数类型   | 可读   | 可写   | 说明                        |
| ----- | ------ | ---- | ---- | ------------------------- |
| value | number | 是    | 是    | 表示设备是否被穿戴(1表示已穿戴,0表示未穿戴)。 |
Z
zengyawen 已提交
5482 5483 5484 5485


## Options

Z
zengyawen 已提交
5486
设置传感器上报频率。
Z
zengyawen 已提交
5487

C
cff-gite 已提交
5488 5489
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
5490 5491
| 名称       | 参数类型   | 说明                          |
| -------- | ------ | --------------------------- |
Z
zengyawen 已提交
5492 5493
| interval | number | 表示传感器的上报频率,默认值为200000000ns。 |

Z
zengyawen 已提交
5494 5495
## RotationMatrixResponse

C
cff-gite 已提交
5496 5497 5498
设置旋转矩阵响应对象。

**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor
Z
zengyawen 已提交
5499

H
HelloCrease 已提交
5500 5501 5502 5503
| 名称          | 参数类型                | 可读   | 可写   | 说明    |
| ----------- | ------------------- | ---- | ---- | ----- |
| rotation    | Array&lt;number&gt; | 是    | 是    | 旋转矩阵。 |
| inclination | Array&lt;number&gt; | 是    | 是    | 倾斜矩阵。 |
Z
zengyawen 已提交
5504 5505 5506 5507


## CoordinatesOptions

C
cff-gite 已提交
5508 5509 5510
设置坐标选项对象。

**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor
Z
zengyawen 已提交
5511

H
HelloCrease 已提交
5512 5513 5514 5515
| 名称   | 参数类型   | 可读   | 可写   | 说明     |
| ---- | ------ | ---- | ---- | ------ |
| x    | number | 是    | 是    | x坐标方向。 |
| y    | number | 是    | 是    | y坐标方向。 |
Z
zengyawen 已提交
5516

Z
zengyawen 已提交
5517 5518 5519

## GeomagneticResponse

Z
zengyawen 已提交
5520
设置地磁响应对象,继承于[Response](#response)
Z
zengyawen 已提交
5521

C
cff-gite 已提交
5522 5523
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
5524 5525 5526 5527 5528 5529 5530 5531 5532
| 名称              | 参数类型   | 可读   | 可写   | 说明                        |
| --------------- | ------ | ---- | ---- | ------------------------- |
| x               | number | 是    | 是    | 地磁场的北分量。                  |
| y               | number | 是    | 是    | 地磁场的东分量。                  |
| z               | number | 是    | 是    | 地磁场的垂直分量。                 |
| geomagneticDip  | number | 是    | 是    | 地磁倾角,即地球磁场线与水平面的夹角。       |
| deflectionAngle | number | 是    | 是    | 地磁偏角,即地磁北方向与正北方向在水平面上的角度。 |
| levelIntensity  | number | 是    | 是    | 地磁场的水平强度。                 |
| totalIntensity  | number | 是    | 是    | 地磁场的总强度。                  |
Z
zengyawen 已提交
5533 5534 5535

## LocationOptions

C
cff-gite 已提交
5536 5537 5538 5539
指示地理位置。

**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
5540 5541 5542 5543 5544
| 名称        | 参数类型   | 可读   | 可写   | 说明    |
| --------- | ------ | ---- | ---- | ----- |
| latitude  | number | 是    | 是    | 纬度。   |
| longitude | number | 是    | 是    | 经度。   |
| altitude  | number | 是    | 是    | 海拔高度。 |