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

C
cff-gite 已提交
3
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
Z
zengyawen 已提交
4
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
Z
zengyawen 已提交
5

Z
zengyawen 已提交
6 7

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

C
cff-gite 已提交
9
```
Z
zengyawen 已提交
10 11 12
import sensor from '@ohos.sensor';
```

Z
zengyawen 已提交
13

C
cff-gite 已提交
14
## sensor.on(SensorType.SENSOR_TYPE_ID_ACCELEROMETER)
Z
zengyawen 已提交
15

C
cff-gite 已提交
16
on(type:  SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback<AccelerometerResponse>,options?: Options): void
Z
zengyawen 已提交
17 18 19

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

C
cff-gite 已提交
20 21 22 23
**需要权限**:ohos.permission.ACCELEROMETER ,该权限为系统权限

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

Z
zengyawen 已提交
24

H
HelloCrease 已提交
25 26 27 28 29 30
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 |
| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是    | 注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
31

H
HelloCrease 已提交
32
**示例:** 
C
cff-gite 已提交
33
  ```
C
cff-gite 已提交
34
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
35
      console.info('X-coordinate component: ' + data.x);
Z
zengyawen 已提交
36 37
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
38 39
  },
      {interval: 10000000}
Z
zengyawen 已提交
40 41
  );
  ```
Z
zengyawen 已提交
42

C
cff-gite 已提交
43 44

## sensor.on(SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION)
Z
zengyawen 已提交
45

C
cff-gite 已提交
46
on(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<LinearAccelerometerResponse>, options?: Options): void
Z
zengyawen 已提交
47

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

C
cff-gite 已提交
50 51 52 53
**需要权限**:ohos.permission.ACCELEROMETER ,该权限为系统权限

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

H
HelloCrease 已提交
54 55 56 57 58 59
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 |
| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是    | 注册线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
60

H
HelloCrease 已提交
61
**示例:** 
C
cff-gite 已提交
62
  ```
C
cff-gite 已提交
63
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,function(data){
Z
zengyawen 已提交
64 65 66
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
67 68
  },
      {interval: 10000000}
Z
zengyawen 已提交
69 70
  );
  ```
Z
zengyawen 已提交
71

C
cff-gite 已提交
72 73

## sensor.on(SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED)
Z
zengyawen 已提交
74

C
cff-gite 已提交
75
on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback<AccelerometerUncalibratedResponse>, options?: Options): void
Z
zengyawen 已提交
76

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

C
cff-gite 已提交
79 80 81 82
**需要权限**:ohos.permission.ACCELEROMETER ,该权限为系统权限

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

H
HelloCrease 已提交
83
**参数:** 
C
cff-gite 已提交
84

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

H
HelloCrease 已提交
91
**示例:** 
C
cff-gite 已提交
92
  ```
C
cff-gite 已提交
93
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(data){
Z
zengyawen 已提交
94 95 96 97 98 99
      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);
100 101
  },
      {interval: 10000000}
Z
zengyawen 已提交
102 103
  );
  ```
Z
zengyawen 已提交
104

C
cff-gite 已提交
105 106

## sensor.on(SensorType.SENSOR_TYPE_ID_GRAVITY)
Z
zengyawen 已提交
107

C
cff-gite 已提交
108
on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback<GravityResponse>,options?: Options): void
Z
zengyawen 已提交
109

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

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

H
HelloCrease 已提交
114 115 116 117 118 119
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                    |
| -------- | ---------------------------------------- | ---- | ------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的重力传感器类型为SENSOR_TYPE_ID_GRAVITY。   |
| callback | Callback<[GravityResponse](#gravityresponse)> | 是    | 注册重力传感器的回调函数,上报的数据类型为GravityResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。        |
Z
zengyawen 已提交
120

H
HelloCrease 已提交
121
**示例:** 
C
cff-gite 已提交
122
  ```
C
cff-gite 已提交
123
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY,function(data){
124
      console.info('X-coordinate component: ' + data.x);
Z
zengyawen 已提交
125 126
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
127 128
  },
      {interval: 10000000}
Z
zengyawen 已提交
129 130
  );
  ```
Z
zengyawen 已提交
131

C
cff-gite 已提交
132 133

## sensor.on(SensorType.SENSOR_TYPE_ID_GYROSCOPE)
Z
zengyawen 已提交
134

C
cff-gite 已提交
135
on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback<GyroscopeResponse>, options?: Options): void
Z
zengyawen 已提交
136

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

C
cff-gite 已提交
139
**需要权限**:ohos.permission.GYROSCOPE ,该权限为系统权限
C
cff-gite 已提交
140 141 142

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

H
HelloCrease 已提交
143 144 145 146 147 148
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。   |
| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是    | 注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
149

H
HelloCrease 已提交
150
**示例:** 
C
cff-gite 已提交
151
  ```
C
cff-gite 已提交
152
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,function(data){
153
      console.info('X-coordinate component: ' + data.x);
Z
zengyawen 已提交
154 155
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
156 157
  },
      {interval: 10000000}
Z
zengyawen 已提交
158 159
  );
  ```
Z
zengyawen 已提交
160

C
cff-gite 已提交
161 162

## sensor.on(SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED)
Z
zengyawen 已提交
163

C
cff-gite 已提交
164
on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:Callback<GyroscopeUncalibratedResponse>, options?: Options): void
Z
zengyawen 已提交
165

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

C
cff-gite 已提交
168
**需要权限**:ohos.permission.GYROSCOPE ,该权限为系统权限
C
cff-gite 已提交
169 170 171

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

H
HelloCrease 已提交
172 173 174 175 176 177
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 |
| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是    | 注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率。                           |
Z
zengyawen 已提交
178

H
HelloCrease 已提交
179
**示例:** 
C
cff-gite 已提交
180
  ```
C
cff-gite 已提交
181
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(data){
182
      console.info('X-coordinate component: ' + data.x);
Z
zengyawen 已提交
183 184
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
185
      console.info('X-coordinate bias: ' + data.biasX);
Z
zengyawen 已提交
186 187
      console.info('Y-coordinate bias: ' + data.biasY);
      console.info('Z-coordinate bias: ' + data.biasZ);
188 189
  },
      {interval: 10000000}
Z
zengyawen 已提交
190 191
  );
  ```
Z
zengyawen 已提交
192

C
cff-gite 已提交
193 194

## sensor.on(SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION)
Z
zengyawen 已提交
195

C
cff-gite 已提交
196
on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: Callback<SignificantMotionResponse>, options?: Options): void
Z
zengyawen 已提交
197

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

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

H
HelloCrease 已提交
202 203 204 205 206 207
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的大幅动作传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 |
| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是    | 注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
208

H
HelloCrease 已提交
209
**示例:** 
C
cff-gite 已提交
210
  ```
C
cff-gite 已提交
211
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(data){
Z
zengyawen 已提交
212
      console.info('Scalar data: ' + data.scalar);
213 214
  },
      {interval: 10000000}
Z
zengyawen 已提交
215 216
  );
  ```
Z
zengyawen 已提交
217

C
cff-gite 已提交
218 219

## sensor.on(SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION)
Z
zengyawen 已提交
220

C
cff-gite 已提交
221
on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: Callback<PedometerDetectionResponse>, options?: Options): void
Z
zengyawen 已提交
222

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

C
cff-gite 已提交
225
**需要权限**:ohos.permission.ACTIVITY_MOTION
C
cff-gite 已提交
226 227 228

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

H
HelloCrease 已提交
229 230 231 232 233 234
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 |
| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是    | 注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
235

H
HelloCrease 已提交
236
**示例:** 
C
cff-gite 已提交
237
  ```
C
cff-gite 已提交
238
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(data){
Z
zengyawen 已提交
239
      console.info('Scalar data: ' + data.scalar);
240 241
  },
      {interval: 10000000}
Z
zengyawen 已提交
242 243
  );
  ```
Z
zengyawen 已提交
244

C
cff-gite 已提交
245 246

## sensor.on(SensorType.SENSOR_TYPE_ID_PEDOMETER)
Z
zengyawen 已提交
247

C
cff-gite 已提交
248
on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback<PedometerResponse>, options?: Options): void
Z
zengyawen 已提交
249

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

C
cff-gite 已提交
252
**需要权限**:ohos.permission.ACTIVITY_MOTION 
C
cff-gite 已提交
253 254 255

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

H
HelloCrease 已提交
256 257 258 259 260 261
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                      |
| -------- | ---------------------------------------- | ---- | --------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。   |
| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是    | 注册计步传感器的回调函数,上报的数据类型为PedometerResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。          |
Z
zengyawen 已提交
262

H
HelloCrease 已提交
263
**示例:** 
C
cff-gite 已提交
264
  ```
C
cff-gite 已提交
265
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER,function(data){
Z
zengyawen 已提交
266
      console.info('Steps: ' + data.steps);
267 268
  },
      {interval: 10000000}
Z
zengyawen 已提交
269 270
  );
  ```
Z
zengyawen 已提交
271

C
cff-gite 已提交
272 273

## sensor.on(SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE)
Z
zengyawen 已提交
274

C
cff-gite 已提交
275
on(type:SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:Callback<AmbientTemperatureResponse>,  options?: Options): void
Z
zengyawen 已提交
276

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

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

H
HelloCrease 已提交
281 282 283 284 285 286
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 |
| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是    | 注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
287

H
HelloCrease 已提交
288
**示例:** 
C
cff-gite 已提交
289
  ```
C
cff-gite 已提交
290
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,function(data){
Z
zengyawen 已提交
291
      console.info('Temperature: ' + data.temperature);
292 293
  },
      {interval: 10000000}
Z
zengyawen 已提交
294 295
  );
  ```
Z
zengyawen 已提交
296

C
cff-gite 已提交
297 298

## sensor.on(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD)
Z
zengyawen 已提交
299

C
cff-gite 已提交
300
on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback<MagneticFieldResponse>,options?: Options): void
Z
zengyawen 已提交
301

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

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

H
HelloCrease 已提交
306 307 308 309 310 311
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 |
| callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是    | 注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
312

H
HelloCrease 已提交
313
**示例:** 
C
cff-gite 已提交
314
  ```
C
cff-gite 已提交
315
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,function(data){
Z
zengyawen 已提交
316 317 318
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
319 320
  },
      {interval: 10000000}
Z
zengyawen 已提交
321 322
  );
  ```
Z
zengyawen 已提交
323

C
cff-gite 已提交
324 325

## sensor.on(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED)
Z
zengyawen 已提交
326

H
HelloCrease 已提交
327
on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback<MagneticFieldUncalibratedResponse>, options?: Options): void
Z
zengyawen 已提交
328

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

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

H
HelloCrease 已提交
333 334 335 336 337 338
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 |
| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是    | 注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
339

H
HelloCrease 已提交
340
**示例:** 
C
cff-gite 已提交
341
  ```
C
cff-gite 已提交
342
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(data){
343 344 345 346
      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 已提交
347 348
      console.info('Y-coordinate bias: ' + data.biasY);
      console.info('Z-coordinate bias: ' + data.biasZ);
349 350
  },
      {interval: 10000000}
Z
zengyawen 已提交
351 352
  );
  ```
Z
zengyawen 已提交
353

C
cff-gite 已提交
354 355

## sensor.on(SensorType.SENSOR_TYPE_ID_PROXIMITY)
Z
zengyawen 已提交
356

C
cff-gite 已提交
357
on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback<ProximityResponse>,options?: Options): void
Z
zengyawen 已提交
358

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

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

H
HelloCrease 已提交
363 364 365 366 367 368
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。   |
| callback | Callback<[ProximityResponse](#proximityresponse)> | 是    | 注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
369

H
HelloCrease 已提交
370
**示例:** 
C
cff-gite 已提交
371
  ```
C
cff-gite 已提交
372
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY,function(data){
Z
zengyawen 已提交
373
      console.info('Distance: ' + data.distance);
374 375
  },
      {interval: 10000000}
Z
zengyawen 已提交
376 377
  );
  ```
Z
zengyawen 已提交
378

C
cff-gite 已提交
379 380

## sensor.on(SensorType.SENSOR_TYPE_ID_HUMIDITY)
Z
zengyawen 已提交
381

C
cff-gite 已提交
382
on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback<HumidityResponse>,options?: Options): void
Z
zengyawen 已提交
383

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

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

H
HelloCrease 已提交
388 389 390 391 392 393
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                     |
| -------- | ---------------------------------------- | ---- | -------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。   |
| callback | Callback<[HumidityResponse](#humidityresponse)> | 是    | 注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。         |
Z
zengyawen 已提交
394

H
HelloCrease 已提交
395
**示例:** 
C
cff-gite 已提交
396
  ```
C
cff-gite 已提交
397
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY,function(data){
Z
zengyawen 已提交
398
      console.info('Humidity: ' + data.humidity);
399 400
  },
      {interval: 10000000}
Z
zengyawen 已提交
401 402
  );
  ```
Z
zengyawen 已提交
403

C
cff-gite 已提交
404 405

## sensor.on(SensorType.SENSOR_TYPE_ID_BAROMETER)
Z
zengyawen 已提交
406

C
cff-gite 已提交
407
on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback<BarometerResponse>,options?: Options): void
Z
zengyawen 已提交
408

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

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

H
HelloCrease 已提交
413 414 415 416 417 418
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。   |
| callback | Callback<[BarometerResponse](#barometerresponse)> | 是    | 注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
419

H
HelloCrease 已提交
420
**示例:** 
C
cff-gite 已提交
421
  ```
C
cff-gite 已提交
422
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER,function(data){
Z
zengyawen 已提交
423
      console.info('Atmospheric pressure: ' + data.pressure);
424 425
  },
      {interval: 10000000}
Z
zengyawen 已提交
426 427
  );
  ```
Z
zengyawen 已提交
428

C
cff-gite 已提交
429 430

## sensor.on(SensorType.SENSOR_TYPE_ID_HALL)
Z
zengyawen 已提交
431

C
cff-gite 已提交
432
on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback<HallResponse>, options?: Options): void
Z
zengyawen 已提交
433

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

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

H
HelloCrease 已提交
438 439 440 441 442 443
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的霍尔传感器类型为SENSOR_TYPE_ID_HALL。         |
| callback | Callback<[HallResponse](#hallresponse)> | 是    | 注册霍尔传感器的回调函数,上报的数据类型为 HallResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
444

H
HelloCrease 已提交
445
**示例:** 
C
cff-gite 已提交
446 447

  ```
C
cff-gite 已提交
448
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HALL,function(data){
Z
zengyawen 已提交
449
      console.info('Status: ' + data.status);
450 451
  },
      {interval: 10000000}
Z
zengyawen 已提交
452 453
  );
  ```
Z
zengyawen 已提交
454

C
cff-gite 已提交
455 456

## sensor.on(SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT)
Z
zengyawen 已提交
457

C
cff-gite 已提交
458
on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback<LightResponse>, options?: Options): void
Z
zengyawen 已提交
459

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

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

H
HelloCrease 已提交
464 465 466 467 468 469
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 |
| callback | Callback<[LightResponse](#lightresponse)> | 是    | 注册环境光传感器的回调函数,上报的数据类型为LightResponse。     |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
470

H
HelloCrease 已提交
471
**示例:** 
C
cff-gite 已提交
472
  ```
C
cff-gite 已提交
473
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,function(data){
474 475 476
      console.info(' Illumination: ' + data.intensity);
  },
      {interval: 10000000}
Z
zengyawen 已提交
477 478
  );
  ```
Z
zengyawen 已提交
479

C
cff-gite 已提交
480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505
## sensor.on(SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE)

on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,  callback: Callback<AmbientTemperatureResponse>, options?: Options): void

订阅传感器数据,如果 API 被多次调用,则最后一次调用生效

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

**参数:**

| 参数名   | 类型                                                         | 必填 | 说明                                                         |
| -------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| type     | [SensorType](#sensortype)                                    | 是   | 环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。     |
| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是   | 注册一次环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 |

**示例:** 

```
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(data) {
      console.info('Temperature: ' + data.temperature);
  }
      {interval: 10000000}
);
```

## sensor.on(SensorType.SENSOR_TYPE_ID_ORIENTATION)
Z
zengyawen 已提交
506

C
cff-gite 已提交
507
on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback<OrientationResponse>, options?: Options): void
Z
zengyawen 已提交
508

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

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

H
HelloCrease 已提交
513
**参数:** 
C
cff-gite 已提交
514

H
HelloCrease 已提交
515 516 517 518 519
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的方向传感器类型为SENSOR_TYPE_ID_ORIENTATION   |
| callback | Callback<[OrientationResponse](#orientationresponse)> | 是    | 注册方向传感器的回调函数,上报的数据类型为OrientationResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
520

H
HelloCrease 已提交
521
**示例:** 
C
cff-gite 已提交
522 523

  ```
C
cff-gite 已提交
524
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,function(data){
C
cff-gite 已提交
525 526 527
      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);
528 529
  },
      {interval: 10000000}
Z
zengyawen 已提交
530 531
  );
  ```
Z
zengyawen 已提交
532

C
cff-gite 已提交
533
## sensor.on(SensorType.SENSOR_TYPE_ID_HEART_RATE)
C
cff-gite 已提交
534

C
cff-gite 已提交
535
on(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback<HeartRateResponse>, options?: Options): void
C
cff-gite 已提交
536 537 538 539 540 541 542

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

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

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

H
HelloCrease 已提交
543
**参数:** 
C
cff-gite 已提交
544

H
HelloCrease 已提交
545 546 547 548
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。   |
| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是    | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 |
C
cff-gite 已提交
549

H
HelloCrease 已提交
550
**示例:** 
C
cff-gite 已提交
551

C
cff-gite 已提交
552
```
C
cff-gite 已提交
553 554 555 556 557 558
sensor.on(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE,function(data){
    console.info("Heart rate: " + data.heartRate);
},
    {interval: 10000000}
);
```
Z
zengyawen 已提交
559

C
cff-gite 已提交
560
## sensor.on(SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR)
Z
zengyawen 已提交
561

C
cff-gite 已提交
562
on(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback: Callback<RotationVectorResponse>,options?: Options): void
Z
zengyawen 已提交
563

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

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

H
HelloCrease 已提交
568 569 570 571 572 573
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 |
| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是    | 注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
574

H
HelloCrease 已提交
575
**示例:** 
C
cff-gite 已提交
576
  ```
C
cff-gite 已提交
577
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(data){
Z
zengyawen 已提交
578 579 580
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
C
cff-gite 已提交
581
      console.info('Scalar quantity: ' + data.w);
582 583
  },
      {interval: 10000000}
Z
zengyawen 已提交
584 585
  );
  ```
Z
zengyawen 已提交
586

C
cff-gite 已提交
587 588

## sensor.on(SensorType.SENSOR_TYPE_ID_WEAR_DETECTION)
Z
zengyawen 已提交
589

C
cff-gite 已提交
590
on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback<WearDetectionResponse>,options?: Options): void
Z
zengyawen 已提交
591

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

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

H
HelloCrease 已提交
596 597 598 599 600 601
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要订阅的佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 |
| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是    | 注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 |
| options  | [Options](#options)                      | 否    | 可选参数列表,设置上报频率,默认值为200000000ns。           |
Z
zengyawen 已提交
602

H
HelloCrease 已提交
603
**示例:** 
C
cff-gite 已提交
604
  ```
C
cff-gite 已提交
605
  sensor.on(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(data){
Z
zengyawen 已提交
606
      console.info('Wear status: ' + data.value);
607 608
  },
      {interval: 10000000}
Z
zengyawen 已提交
609 610
  );
  ```
Z
zengyawen 已提交
611 612


C
cff-gite 已提交
613
## sensor.once(SensorType.SENSOR_TYPE_ID_ACCELEROMETER)
Z
zengyawen 已提交
614

C
cff-gite 已提交
615
once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: Callback<AccelerometerResponse>): void
Z
zengyawen 已提交
616

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

C
cff-gite 已提交
619 620 621 622
**需要权限**:ohos.permission.ACCELEROMETER ,该权限为系统权限

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

H
HelloCrease 已提交
623 624 625 626 627
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。   |
| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是    | 注册一次加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 |
Z
zengyawen 已提交
628

H
HelloCrease 已提交
629
**示例:** 
C
cff-gite 已提交
630
  ```
C
cff-gite 已提交
631
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(data){
Z
zengyawen 已提交
632 633 634
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
Z
zengyawen 已提交
635
    }
Z
zengyawen 已提交
636 637
  );
  ```
Z
zengyawen 已提交
638

C
cff-gite 已提交
639 640

## sensor.once(SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION)
Z
zengyawen 已提交
641

C
cff-gite 已提交
642
once(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:Callback<LinearAccelerometerResponse>): void
Z
zengyawen 已提交
643

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

C
cff-gite 已提交
646 647 648 649
**需要权限**:ohos.permission.ACCELEROMETER ,该权限为系统权限

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

H
HelloCrease 已提交
650 651 652 653 654
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 |
| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是    | 注册一次线性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 |
Z
zengyawen 已提交
655

H
HelloCrease 已提交
656
**示例:** 
C
cff-gite 已提交
657
  ```
C
cff-gite 已提交
658
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, function(data) {
Z
zengyawen 已提交
659 660 661
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
Z
zengyawen 已提交
662
    }
Z
zengyawen 已提交
663 664
  );
  ```
Z
zengyawen 已提交
665

C
cff-gite 已提交
666 667

## sensor.once(SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED)
Z
zengyawen 已提交
668

C
cff-gite 已提交
669
once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback: Callback<AccelerometerUncalibratedResponse>): void
Z
zengyawen 已提交
670

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

C
cff-gite 已提交
673 674 675 676
**需要权限**:ohos.permission.ACCELEROMETER ,该权限为系统权限

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

H
HelloCrease 已提交
677 678 679 680 681
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 未校准加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 |
| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是    | 注册一次未校准加速度传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 |
Z
zengyawen 已提交
682

H
HelloCrease 已提交
683
**示例:** 
Z
zengyawen 已提交
684
  ```
C
cff-gite 已提交
685
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, function(data) {
Z
zengyawen 已提交
686 687 688 689 690 691
      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 已提交
692
    }
Z
zengyawen 已提交
693 694
  );
  ```
Z
zengyawen 已提交
695

C
cff-gite 已提交
696 697

## sensor.once(SensorType.SENSOR_TYPE_ID_GRAVITY)
Z
zengyawen 已提交
698

C
cff-gite 已提交
699
once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: Callback<GravityResponse>): void
Z
zengyawen 已提交
700

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

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

H
HelloCrease 已提交
705 706 707 708 709
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                      |
| -------- | ---------------------------------------- | ---- | --------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 重力传感器类型为SENSOR_TYPE_ID_GRAVITY。         |
| callback | Callback<[GravityResponse](#gravityresponse)> | 是    | 注册一次重力传感器的回调函数,上报的数据类型为GravityResponse。 |
Z
zengyawen 已提交
710

H
HelloCrease 已提交
711
**示例:** 
C
cff-gite 已提交
712
  ```
C
cff-gite 已提交
713
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GRAVITY, function(data) {
Z
zengyawen 已提交
714 715 716
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
Z
zengyawen 已提交
717
    }
Z
zengyawen 已提交
718 719
  );
  ```
Z
zengyawen 已提交
720

C
cff-gite 已提交
721 722

## sensor.once(SensorType.SENSOR_TYPE_ID_GYROSCOPE)
Z
zengyawen 已提交
723

C
cff-gite 已提交
724
once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: Callback<GyroscopeResponse>): void
Z
zengyawen 已提交
725

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

C
cff-gite 已提交
728 729 730 731
**需要权限**:ohos.permission.GYROSCOPE ,该权限为系统权限

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

H
HelloCrease 已提交
732 733 734 735 736
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。       |
| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是    | 注册一次陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 |
Z
zengyawen 已提交
737

H
HelloCrease 已提交
738
**示例:** 
C
cff-gite 已提交
739
  ```
C
cff-gite 已提交
740
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(data) {
Z
zengyawen 已提交
741 742 743
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
Z
zengyawen 已提交
744
    }
Z
zengyawen 已提交
745 746
  );
  ```
Z
zengyawen 已提交
747

C
cff-gite 已提交
748 749

## sensor.once(SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED)
Z
zengyawen 已提交
750

C
cff-gite 已提交
751
once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback: Callback<GyroscopeUncalibratedResponse>): void
Z
zengyawen 已提交
752

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

C
cff-gite 已提交
755 756 757 758
**需要权限**:ohos.permission.GYROSCOPE ,该权限为系统权限

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

H
HelloCrease 已提交
759 760 761 762 763
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 |
| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是    | 注册一次未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 |
Z
zengyawen 已提交
764

H
HelloCrease 已提交
765
**示例:** 
C
cff-gite 已提交
766
  ```
C
cff-gite 已提交
767
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(data) {
Z
zengyawen 已提交
768 769 770 771 772 773
      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 已提交
774
    }
Z
zengyawen 已提交
775 776
  );
  ```
Z
zengyawen 已提交
777

C
cff-gite 已提交
778 779

## sensor.once(SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION)
Z
zengyawen 已提交
780

C
cff-gite 已提交
781
once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback: Callback<SignificantMotionResponse>): void
Z
zengyawen 已提交
782

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

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

H
HelloCrease 已提交
787 788 789 790 791
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 有效运动传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 |
| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是    | 注册一次有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 |
Z
zengyawen 已提交
792

H
HelloCrease 已提交
793
**示例:** 
C
cff-gite 已提交
794
  ```
C
cff-gite 已提交
795
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(data) {
Z
zengyawen 已提交
796
      console.info('Scalar data: ' + data.scalar);
Z
zengyawen 已提交
797
    }
Z
zengyawen 已提交
798 799
  );
  ```
Z
zengyawen 已提交
800

C
cff-gite 已提交
801 802

## sensor.once(SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION)
Z
zengyawen 已提交
803

C
cff-gite 已提交
804
once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback: Callback<PedometerDetectionResponse>): void
Z
zengyawen 已提交
805

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

C
cff-gite 已提交
808
**需要权限**:ohos.permission.ACTIVITY_MOTION
C
cff-gite 已提交
809 810 811

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

H
HelloCrease 已提交
812 813 814 815 816
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 |
| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是    | 注册一次计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 |
Z
zengyawen 已提交
817

H
HelloCrease 已提交
818
**示例:** 
C
cff-gite 已提交
819
  ```
C
cff-gite 已提交
820
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(data) {
Z
zengyawen 已提交
821
      console.info('Scalar data: ' + data.scalar);
Z
zengyawen 已提交
822
    }
Z
zengyawen 已提交
823 824
  );
  ```
Z
zengyawen 已提交
825

C
cff-gite 已提交
826 827

## sensor.once(SensorType.SENSOR_TYPE_ID_PEDOMETER)
Z
zengyawen 已提交
828

C
cff-gite 已提交
829
once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: Callback<PedometerResponse>): void
Z
zengyawen 已提交
830

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

C
cff-gite 已提交
833
**需要权限**:ohos.permission.ACTIVITY_MOTION
C
cff-gite 已提交
834 835 836

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

H
HelloCrease 已提交
837 838 839 840 841
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。        |
| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是    | 注册一次计步传感器的回调函数,上报的数据类型为PedometerResponse。 |
Z
zengyawen 已提交
842

H
HelloCrease 已提交
843
**示例:** 
C
cff-gite 已提交
844
  ```
C
cff-gite 已提交
845
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, function(data) {
Z
zengyawen 已提交
846
      console.info('Steps: ' + data.steps);
Z
zengyawen 已提交
847
    }
Z
zengyawen 已提交
848 849
  );
  ```
Z
zengyawen 已提交
850

C
cff-gite 已提交
851 852

## sensor.once(SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE)
Z
zengyawen 已提交
853

C
cff-gite 已提交
854
once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback: Callback<AmbientTemperatureResponse>): void
Z
zengyawen 已提交
855

Z
zengyawen 已提交
856
监听环境温度传感器数据变化一次。
Z
zengyawen 已提交
857

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

H
HelloCrease 已提交
860 861 862 863 864
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 |
| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是    | 注册一次环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 |
Z
zengyawen 已提交
865

H
HelloCrease 已提交
866
**示例:** 
C
cff-gite 已提交
867
  ```
C
cff-gite 已提交
868
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(data) {
Z
zengyawen 已提交
869
      console.info('Temperature: ' + data.temperature);
Z
zengyawen 已提交
870
    }
Z
zengyawen 已提交
871 872
  );
  ```
Z
zengyawen 已提交
873

C
cff-gite 已提交
874 875

## sensor.once(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD)
Z
zengyawen 已提交
876

C
cff-gite 已提交
877
once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: Callback<MagneticFieldResponse>): void
Z
zengyawen 已提交
878

Z
zengyawen 已提交
879
监听磁场传感器数据变化一次。
Z
zengyawen 已提交
880

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

H
HelloCrease 已提交
883 884 885 886 887
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。   |
| callback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是    | 注册一次磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 |
Z
zengyawen 已提交
888

H
HelloCrease 已提交
889
**示例:** 
C
cff-gite 已提交
890
  ```
C
cff-gite 已提交
891
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(data) {
Z
zengyawen 已提交
892 893 894
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
Z
zengyawen 已提交
895
    }
Z
zengyawen 已提交
896 897
  );
  ```
Z
zengyawen 已提交
898

C
cff-gite 已提交
899 900

## sensor.once(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED)
Z
zengyawen 已提交
901

C
cff-gite 已提交
902
once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback: Callback<MagneticFieldUncalibratedResponse>): void
Z
zengyawen 已提交
903

Z
zengyawen 已提交
904
监听未校准磁场传感器数据变化一次。
Z
zengyawen 已提交
905

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

H
HelloCrease 已提交
908 909 910 911 912
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 |
| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是    | 注册一次未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 |
Z
zengyawen 已提交
913

H
HelloCrease 已提交
914
**示例:** 
C
cff-gite 已提交
915
  ```
C
cff-gite 已提交
916
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(data) {
Z
zengyawen 已提交
917 918 919 920 921 922
      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 已提交
923
    }
Z
zengyawen 已提交
924 925
  );
  ```
Z
zengyawen 已提交
926

C
cff-gite 已提交
927 928

## sensor.once(SensorType.SENSOR_TYPE_ID_PROXIMITY)
Z
zengyawen 已提交
929

C
cff-gite 已提交
930
once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: Callback<ProximityResponse>): void
Z
zengyawen 已提交
931

Z
zengyawen 已提交
932
监听接近光传感器数据变化一次。
Z
zengyawen 已提交
933

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

H
HelloCrease 已提交
936 937 938 939 940
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。       |
| callback | Callback<[ProximityResponse](#proximityresponse)> | 是    | 注册一次接近光传感器的回调函数,上报的数据类型为ProximityResponse。 |
Z
zengyawen 已提交
941

H
HelloCrease 已提交
942
**示例:** 
C
cff-gite 已提交
943
  ```
944
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, function(error, data) {
Z
zengyawen 已提交
945 946 947 948 949
      if (error) {
          console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
          return;
      }
      console.info('Distance: ' + data.distance);
Z
zengyawen 已提交
950
    }
Z
zengyawen 已提交
951 952
  );
  ```
Z
zengyawen 已提交
953

C
cff-gite 已提交
954 955

## sensor.once(SensorType.SENSOR_TYPE_ID_HUMIDITY)
Z
zengyawen 已提交
956

C
cff-gite 已提交
957
once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: Callback<HumidityResponse>): void
Z
zengyawen 已提交
958

Z
zengyawen 已提交
959
监听湿度传感器数据变化一次。
Z
zengyawen 已提交
960

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

H
HelloCrease 已提交
963 964 965 966 967
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。         |
| callback | Callback<[HumidityResponse](#humidityresponse)> | 是    | 注册一次湿度传感器的回调函数,上报的数据类型为HumidityResponse。 |
Z
zengyawen 已提交
968

H
HelloCrease 已提交
969
**示例:** 
C
cff-gite 已提交
970
  ```
C
cff-gite 已提交
971
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, function(data) {
Z
zengyawen 已提交
972
      console.info('Humidity: ' + data.humidity);
Z
zengyawen 已提交
973
    }
Z
zengyawen 已提交
974 975
  );
  ```
Z
zengyawen 已提交
976

C
cff-gite 已提交
977 978

## sensor.once(SensorType.SENSOR_TYPE_ID_BAROMETER)
Z
zengyawen 已提交
979

C
cff-gite 已提交
980
once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: Callback<BarometerResponse>): void
Z
zengyawen 已提交
981

Z
zengyawen 已提交
982
监听气压计传感器数据变化一次。
Z
zengyawen 已提交
983

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

H
HelloCrease 已提交
986 987 988 989 990
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。       |
| callback | Callback<[BarometerResponse](#barometerresponse)> | 是    | 注册一次气压计传感器的回调函数,上报的数据类型为BarometerResponse。 |
Z
zengyawen 已提交
991

H
HelloCrease 已提交
992
**示例:** 
C
cff-gite 已提交
993
  ```
C
cff-gite 已提交
994
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, function(data) {
Z
zengyawen 已提交
995
      console.info('Atmospheric pressure: ' + data.pressure);
Z
zengyawen 已提交
996
    }
Z
zengyawen 已提交
997 998
  );
  ```
Z
zengyawen 已提交
999

C
cff-gite 已提交
1000 1001

## sensor.once(SensorType.SENSOR_TYPE_ID_HALL)
Z
zengyawen 已提交
1002

C
cff-gite 已提交
1003
once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: Callback<HallResponse>): void
Z
zengyawen 已提交
1004

Z
zengyawen 已提交
1005
监听霍尔传感器数据变化一次。
Z
zengyawen 已提交
1006

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

H
HelloCrease 已提交
1009 1010 1011 1012 1013
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                   |
| -------- | ---------------------------------------- | ---- | ------------------------------------ |
| type     | [SensorType](#sensortype)                | 是    | 霍尔传感器类型为SENSOR_TYPE_ID_HALL。         |
| callback | Callback<[HallResponse](#hallresponse)> | 是    | 注册一次霍尔传感器的回调函数,上报的数据类型为HallResponse。 |
Z
zengyawen 已提交
1014

H
HelloCrease 已提交
1015
**示例:** 
C
cff-gite 已提交
1016
  ```
C
cff-gite 已提交
1017
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HALL, function(data) {
Z
zengyawen 已提交
1018
      console.info('Status: ' + data.status);
Z
zengyawen 已提交
1019
    }
Z
zengyawen 已提交
1020 1021
  );
  ```
Z
zengyawen 已提交
1022

C
cff-gite 已提交
1023 1024

## sensor.once(SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT)
Z
zengyawen 已提交
1025

C
cff-gite 已提交
1026
once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: Callback<LightResponse>): void
Z
zengyawen 已提交
1027

Z
zengyawen 已提交
1028
监听环境光传感器数据变化一次。
Z
zengyawen 已提交
1029

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

H
HelloCrease 已提交
1032 1033 1034 1035 1036
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                     |
| -------- | ---------------------------------------- | ---- | -------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 |
| callback | Callback<[LightResponse](#lightresponse)> | 是    | 注册一次环境光传感器的回调函数,上报的数据类型为LightResponse。 |
Z
zengyawen 已提交
1037

H
HelloCrease 已提交
1038
**示例:** 
C
cff-gite 已提交
1039
  ```
C
cff-gite 已提交
1040
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function(data) {
1041
      console.info(' Illumination: ' + data.intensity);
Z
zengyawen 已提交
1042
    }
Z
zengyawen 已提交
1043 1044
  );
  ```
Z
zengyawen 已提交
1045

C
cff-gite 已提交
1046 1047

## sensor.once(SensorType.SENSOR_TYPE_ID_ORIENTATION)
Z
zengyawen 已提交
1048

C
cff-gite 已提交
1049
once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: Callback<OrientationResponse>): void
Z
zengyawen 已提交
1050

Z
zengyawen 已提交
1051
监听方向传感器数据变化一次。
Z
zengyawen 已提交
1052

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

H
HelloCrease 已提交
1055 1056 1057 1058 1059
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 方向传感器类型为SENSOR_TYPE_ID_ORIENTATION。      |
| callback | Callback<[OrientationResponse](#orientationresponse)> | 是    | 注册一次方向传感器的回调函数,上报的数据类型为OrientationResponse。 |
Z
zengyawen 已提交
1060

H
HelloCrease 已提交
1061
**示例:** 
C
cff-gite 已提交
1062
  ```
C
cff-gite 已提交
1063
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, function(data) {
C
cff-gite 已提交
1064 1065 1066
      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 已提交
1067
    }
Z
zengyawen 已提交
1068 1069
  );
  ```
Z
zengyawen 已提交
1070

C
cff-gite 已提交
1071 1072

## sensor.once(SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR)
Z
zengyawen 已提交
1073

C
cff-gite 已提交
1074
once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: Callback<RotationVectorResponse>): void
Z
zengyawen 已提交
1075

Z
zengyawen 已提交
1076
监听旋转矢量传感器数据变化一次。
Z
zengyawen 已提交
1077

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

H
HelloCrease 已提交
1080 1081 1082 1083 1084
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 |
| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是    | 注册一次旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 |
Z
zengyawen 已提交
1085

H
HelloCrease 已提交
1086
**示例:** 
C
cff-gite 已提交
1087
  ```
C
cff-gite 已提交
1088
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(data) {
Z
zengyawen 已提交
1089 1090 1091
      console.info('X-coordinate component: ' + data.x);
      console.info('Y-coordinate component: ' + data.y);
      console.info('Z-coordinate component: ' + data.z);
C
cff-gite 已提交
1092
      console.info('Scalar quantity: ' + data.w);
Z
zengyawen 已提交
1093
    }
Z
zengyawen 已提交
1094 1095
  );
  ```
Z
zengyawen 已提交
1096

C
cff-gite 已提交
1097 1098

## sensor.once(SensorType.SENSOR_TYPE_ID_HEART_RATE)
Z
zengyawen 已提交
1099

C
cff-gite 已提交
1100
once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: Callback<HeartRateResponse>): void
Z
zengyawen 已提交
1101

Z
zengyawen 已提交
1102
监听心率传感器数据变化一次。
Z
zengyawen 已提交
1103

C
cff-gite 已提交
1104
**需要权限**:ohos.permission.READ_HEALTH_DATA 
C
cff-gite 已提交
1105 1106 1107

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

H
HelloCrease 已提交
1108 1109 1110 1111 1112
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。       |
| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是    | 注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 |
Z
zengyawen 已提交
1113

H
HelloCrease 已提交
1114
**示例:** 
C
cff-gite 已提交
1115
  ```
C
cff-gite 已提交
1116
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, function(data) {
Z
zengyawen 已提交
1117
      console.info("Heart rate: " + data.heartRate);
Z
zengyawen 已提交
1118
    }
Z
zengyawen 已提交
1119 1120
  );
  ```
Z
zengyawen 已提交
1121

C
cff-gite 已提交
1122 1123

## sensor.once(SensorType.SENSOR_TYPE_ID_WEAR_DETECTION)
Z
zengyawen 已提交
1124

C
cff-gite 已提交
1125
once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: Callback<WearDetectionResponse>): void
Z
zengyawen 已提交
1126

Z
zengyawen 已提交
1127
监听佩戴检测传感器数据变化一次。
Z
zengyawen 已提交
1128

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

H
HelloCrease 已提交
1131 1132 1133 1134 1135
**参数:** 
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 |
| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是    | 注册一次穿戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 |
Z
zengyawen 已提交
1136

H
HelloCrease 已提交
1137
**示例:** 
C
cff-gite 已提交
1138
  ```
C
cff-gite 已提交
1139
  sensor.once(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function(data) {
Z
zengyawen 已提交
1140
      console.info("Wear status: "+ data.value);
Z
zengyawen 已提交
1141
    }
Z
zengyawen 已提交
1142 1143
  );
  ```
Z
zengyawen 已提交
1144

C
cff-gite 已提交
1145
## sensor.off(SensorType.SENSOR_TYPE_ID_ACCELEROMETER)
Z
zengyawen 已提交
1146

C
cff-gite 已提交
1147
off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback?: Callback<AccelerometerResponse>): void
C
cff-gite 已提交
1148 1149

取消订阅传感器数据。
Z
zengyawen 已提交
1150

C
cff-gite 已提交
1151 1152 1153 1154
**需要权限**:ohos.permission.ACCELEROMETER, 该权限为系统权限

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

H
HelloCrease 已提交
1155
**参数:** 
C
cff-gite 已提交
1156

H
HelloCrease 已提交
1157 1158 1159 1160
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的加速度传感器类型为SENSOR_TYPE_ID_ACCELEROMETER。 |
| callback | Callback<[AccelerometerResponse](#accelerometerresponse)> | 是    | 取消注册加速度传感器的回调函数,上报的数据类型为AccelerometerResponse。 |
C
cff-gite 已提交
1161

H
HelloCrease 已提交
1162
**示例:** 
C
cff-gite 已提交
1163

C
cff-gite 已提交
1164
```
C
cff-gite 已提交
1165 1166 1167 1168 1169 1170 1171 1172
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 已提交
1173
## sensor.off(SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED)
C
cff-gite 已提交
1174

C
cff-gite 已提交
1175
off(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, callback?: Callback<AccelerometerUncalibratedResponse>): void
Z
zengyawen 已提交
1176

Z
zengyawen 已提交
1177
取消订阅传感器数据。
Z
zengyawen 已提交
1178

C
cff-gite 已提交
1179 1180
**需要权限**:ohos.permission.ACCELEROMETER, 该权限为系统权限

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

H
HelloCrease 已提交
1183
**参数:** 
C
cff-gite 已提交
1184

H
HelloCrease 已提交
1185 1186 1187 1188
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的未校准加速度计传感器类型为SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED。 |
| callback | Callback<[AccelerometerUncalibratedResponse](#accelerometeruncalibratedresponse)> | 是    | 取消注册未校准加速度计传感器的回调函数,上报的数据类型为AccelerometerUncalibratedResponse。 |
Z
zengyawen 已提交
1189

H
HelloCrease 已提交
1190
**示例:** 
C
cff-gite 已提交
1191

C
cff-gite 已提交
1192
```
C
cff-gite 已提交
1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203
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 已提交
1204
## sensor.off(SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT)
C
cff-gite 已提交
1205

C
cff-gite 已提交
1206
off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback?: Callback<LightResponse>): void
C
cff-gite 已提交
1207 1208 1209 1210 1211

取消订阅传感器数据。

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

H
HelloCrease 已提交
1212
**参数:** 
C
cff-gite 已提交
1213

H
HelloCrease 已提交
1214 1215 1216 1217
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的环境光传感器类型为SENSOR_TYPE_ID_AMBIENT_LIGHT。 |
| callback | Callback<[LightResponse](#lightresponse)> | 是    | 取消注册环境光传感器的回调函数,上报的数据类型为LightResponse。   |
C
cff-gite 已提交
1218

H
HelloCrease 已提交
1219
**示例:** 
C
cff-gite 已提交
1220

C
cff-gite 已提交
1221
```
C
cff-gite 已提交
1222 1223 1224 1225 1226 1227
function callback(data) {
    console.info(' Illumination: ' + data.intensity);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback);
```

C
cff-gite 已提交
1228
## sensor.off(SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE)
C
cff-gite 已提交
1229

C
cff-gite 已提交
1230
off(type: SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback?: Callback<AmbientTemperatureResponse>): void
C
cff-gite 已提交
1231 1232 1233 1234 1235

取消订阅传感器数据。

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

H
HelloCrease 已提交
1236
**参数:** 
C
cff-gite 已提交
1237

H
HelloCrease 已提交
1238 1239 1240 1241
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的环境温度传感器类型为SENSOR_TYPE_ID_AMBIENT_TEMPERATURE。 |
| callback | Callback<[AmbientTemperatureResponse](#ambienttemperatureresponse)> | 是    | 取消注册环境温度传感器的回调函数,上报的数据类型为AmbientTemperatureResponse。 |
C
cff-gite 已提交
1242

H
HelloCrease 已提交
1243
**示例:** 
C
cff-gite 已提交
1244

C
cff-gite 已提交
1245
```
C
cff-gite 已提交
1246 1247 1248 1249 1250 1251
function callback(data) {
     console.info('Temperature: ' + data.temperature);
}
sensor.off( sensor.SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, callback);
```

C
cff-gite 已提交
1252
## sensor.off(SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE)
C
cff-gite 已提交
1253

C
cff-gite 已提交
1254
off(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback?: Callback<BarometerResponse>): void
C
cff-gite 已提交
1255 1256 1257 1258 1259

取消订阅传感器数据。

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

H
HelloCrease 已提交
1260
**参数:** 
C
cff-gite 已提交
1261

H
HelloCrease 已提交
1262 1263 1264 1265
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的气压计传感器类型为SENSOR_TYPE_ID_BAROMETER。 |
| callback | Callback<[BarometerResponse](#barometerresponse)> | 是    | 取消注册气压计传感器的回调函数,上报的数据类型为BarometerResponse。 |
C
cff-gite 已提交
1266

H
HelloCrease 已提交
1267
**示例:** 
C
cff-gite 已提交
1268

C
cff-gite 已提交
1269
```
C
cff-gite 已提交
1270 1271 1272 1273 1274 1275
function callback(data) {
     console.info('Atmospheric pressure: ' + data.pressure);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_BAROMETER, callback);
```

C
cff-gite 已提交
1276
## sensor.off(SensorType.SENSOR_TYPE_ID_GRAVITY)
C
cff-gite 已提交
1277

C
cff-gite 已提交
1278
off(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback?: Callback<GravityResponse>): void
C
cff-gite 已提交
1279 1280 1281 1282 1283

取消订阅传感器数据。

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

H
HelloCrease 已提交
1284
**参数:** 
C
cff-gite 已提交
1285

H
HelloCrease 已提交
1286 1287 1288 1289
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的重力传感器类型为SENSOR_TYPE_ID_GRAVITY。    |
| callback | Callback<[GravityResponse](#gravityresponse)> | 是    | 取消注册注册重力传感器的回调函数,上报的数据类型为GravityResponse。 |
C
cff-gite 已提交
1290

H
HelloCrease 已提交
1291
**示例:** 
C
cff-gite 已提交
1292

C
cff-gite 已提交
1293
```
C
cff-gite 已提交
1294 1295 1296 1297 1298 1299 1300 1301
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 已提交
1302
## sensor.off(SensorType.SENSOR_TYPE_ID_GYROSCOPE)
C
cff-gite 已提交
1303

C
cff-gite 已提交
1304
off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback?: Callback<GyroscopeResponse>): void
C
cff-gite 已提交
1305 1306 1307 1308 1309 1310 1311

取消订阅传感器数据。

**需要权限**:ohos.permission.GYROSCOPE, 该权限为系统权限

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

H
HelloCrease 已提交
1312
**参数:** 
C
cff-gite 已提交
1313

H
HelloCrease 已提交
1314 1315 1316 1317
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE。 |
| callback | Callback<[GyroscopeResponse](#gyroscoperesponse)> | 是    | 取消注册陀螺仪传感器的回调函数,上报的数据类型为GyroscopeResponse。 |
C
cff-gite 已提交
1318

H
HelloCrease 已提交
1319
**示例:** 
C
cff-gite 已提交
1320

C
cff-gite 已提交
1321
```
C
cff-gite 已提交
1322 1323 1324 1325 1326 1327 1328 1329
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 已提交
1330
## sensor.off(SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED)
C
cff-gite 已提交
1331

H
HelloCrease 已提交
1332
off(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, callback?: Callback<GyroscopeUncalibratedResponse>): void
C
cff-gite 已提交
1333 1334 1335 1336 1337 1338 1339

取消订阅传感器数据。

**需要权限**:ohos.permission.GYROSCOPE, 该权限为系统权限

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

H
HelloCrease 已提交
1340
**参数:** 
C
cff-gite 已提交
1341

H
HelloCrease 已提交
1342 1343 1344 1345
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的未校准陀螺仪传感器类型为SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED。 |
| callback | Callback<[GyroscopeUncalibratedResponse](#gyroscopeuncalibratedresponse)> | 是    | 取消注册未校准陀螺仪传感器的回调函数,上报的数据类型为GyroscopeUncalibratedResponse。 |
C
cff-gite 已提交
1346

H
HelloCrease 已提交
1347
**示例:** 
C
cff-gite 已提交
1348

C
cff-gite 已提交
1349
```
C
cff-gite 已提交
1350 1351 1352 1353 1354 1355 1356 1357
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 已提交
1358
## sensor.off(SensorType.SENSOR_TYPE_ID_HALL)
C
cff-gite 已提交
1359

C
cff-gite 已提交
1360
off(type: SensorType.SENSOR_TYPE_ID_HALL, callback?: Callback<HallResponse>): void
C
cff-gite 已提交
1361 1362 1363 1364 1365

取消订阅传感器数据。

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

H
HelloCrease 已提交
1366
**参数:** 
C
cff-gite 已提交
1367

H
HelloCrease 已提交
1368 1369 1370 1371
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的霍尔传感器类型为SENSOR_TYPE_ID_HALL。       |
| callback | Callback<[HallResponse](#hallresponse)> | 是    | 取消注册霍尔传感器的回调函数,上报的数据类型为 HallResponse。 |
C
cff-gite 已提交
1372

H
HelloCrease 已提交
1373
**示例:** 
C
cff-gite 已提交
1374

C
cff-gite 已提交
1375
```
C
cff-gite 已提交
1376 1377 1378 1379 1380 1381
function callback(data) {
    console.info('Status: ' + data.status);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HALL, callback);
```

C
cff-gite 已提交
1382
## sensor.off(SensorType.SENSOR_TYPE_ID_HEART_RATE)
C
cff-gite 已提交
1383

C
cff-gite 已提交
1384
off(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback?: Callback<HeartRateResponse>): void
C
cff-gite 已提交
1385 1386 1387 1388 1389 1390 1391

取消订阅传感器数据。

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

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

H
HelloCrease 已提交
1392
**参数:** 
C
cff-gite 已提交
1393

H
HelloCrease 已提交
1394 1395 1396 1397
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)[SensorType](#sensortype) | 是    | 要取消订阅的心率传感器类型为SENSOR_TYPE_ID_HEART_RATE。 |
| callback | Callback<[HeartRateResponse](#heartrateresponse)> | 是    | 取消注册一次心率传感器的回调函数,上报的数据类型为HeartRateResponse。 |
C
cff-gite 已提交
1398

H
HelloCrease 已提交
1399
**示例:** 
C
cff-gite 已提交
1400

C
cff-gite 已提交
1401
```
C
cff-gite 已提交
1402 1403 1404 1405 1406 1407
function callback(data) {
    console.info("Heart rate: " + data.heartRate);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HEART_RATE, callback);
```

C
cff-gite 已提交
1408
## sensor.off(SensorType.SENSOR_TYPE_ID_HUMIDITY)
C
cff-gite 已提交
1409

C
cff-gite 已提交
1410
off(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback?: Callback<HumidityResponse>): void
C
cff-gite 已提交
1411 1412 1413 1414 1415

取消订阅传感器数据。

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

H
HelloCrease 已提交
1416
**参数:** 
C
cff-gite 已提交
1417

H
HelloCrease 已提交
1418 1419 1420 1421
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的湿度传感器类型为SENSOR_TYPE_ID_HUMIDITY。   |
| callback | Callback<[HumidityResponse](#humidityresponse)> | 是    | 取消注册湿度传感器的回调函数,上报的数据类型为HumidityResponse。 |
C
cff-gite 已提交
1422

H
HelloCrease 已提交
1423
**示例:** 
C
cff-gite 已提交
1424

C
cff-gite 已提交
1425
```
C
cff-gite 已提交
1426 1427 1428 1429 1430 1431
function callback(data) {
    console.info('Humidity: ' + data.humidity);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_HUMIDITY, callback);
```

C
cff-gite 已提交
1432
## sensor.off(SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION)
C
cff-gite 已提交
1433

C
cff-gite 已提交
1434
off(type: SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, callback?: Callback<LinearAccelerometerResponse>): void
C
cff-gite 已提交
1435 1436 1437 1438 1439 1440 1441

取消订阅传感器数据。

**需要权限**:ohos.permission.ACCELEROMETER,该权限为系统权限

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

H
HelloCrease 已提交
1442
**参数:** 
C
cff-gite 已提交
1443

H
HelloCrease 已提交
1444 1445 1446 1447
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的线性加速度传感器类型为SENSOR_TYPE_ID_LINEAR_ACCELERATION。 |
| callback | Callback<[LinearAccelerometerResponse](#linearaccelerometerresponse)> | 是    | 取消注册性加速度传感器的回调函数,上报的数据类型为LinearAccelerometerResponse。 |
C
cff-gite 已提交
1448

H
HelloCrease 已提交
1449
**示例:** 
C
cff-gite 已提交
1450

C
cff-gite 已提交
1451
```
C
cff-gite 已提交
1452 1453 1454 1455 1456 1457 1458 1459
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_ACCELERATION, callback);
```

C
cff-gite 已提交
1460
## sensor.off(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD)
C
cff-gite 已提交
1461

C
cff-gite 已提交
1462
 off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback?: Callback<MagneticFieldResponse>): void
C
cff-gite 已提交
1463 1464 1465 1466 1467

取消订阅传感器数据。

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

H
HelloCrease 已提交
1468
**参数:** 
C
cff-gite 已提交
1469

H
HelloCrease 已提交
1470 1471 1472 1473
| 参数名              | 类型                                       | 必填   | 说明                                       |
| ---------------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type             | [SensorType](#sensortype)                | 是    | 要取消订阅的磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD。 |
| callbackcallback | Callback<[MagneticFieldResponse](#magneticfieldresponse)> | 是    | 取消注册磁场传感器的回调函数,上报的数据类型为MagneticFieldResponse。 |
C
cff-gite 已提交
1474

H
HelloCrease 已提交
1475
**示例:** 
C
cff-gite 已提交
1476

C
cff-gite 已提交
1477
```
C
cff-gite 已提交
1478 1479 1480 1481 1482 1483 1484 1485
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 已提交
1486
## sensor.off(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED)
C
cff-gite 已提交
1487

C
cff-gite 已提交
1488
 off(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, callback?: Callback<MagneticFieldUncalibratedResponse>): void
C
cff-gite 已提交
1489 1490 1491 1492 1493

取消订阅传感器数据。

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

H
HelloCrease 已提交
1494
**参数:** 
C
cff-gite 已提交
1495

H
HelloCrease 已提交
1496 1497 1498 1499
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的未校准磁场传感器类型为SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED。 |
| callback | Callback<[MagneticFieldUncalibratedResponse](#magneticfielduncalibratedresponse)> | 是    | 取消注册未校准磁场传感器的回调函数,上报的数据类型为MagneticFieldUncalibratedResponse。 |
C
cff-gite 已提交
1500

H
HelloCrease 已提交
1501
**示例:** 
C
cff-gite 已提交
1502

C
cff-gite 已提交
1503
```
C
cff-gite 已提交
1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514
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 已提交
1515
## sensor.off(SensorType.SENSOR_TYPE_ID_ORIENTATION)
C
cff-gite 已提交
1516

C
cff-gite 已提交
1517
 off(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback?: Callback<OrientationResponse>): void
C
cff-gite 已提交
1518 1519 1520 1521 1522

取消订阅传感器数据。

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

H
HelloCrease 已提交
1523
**参数:** 
C
cff-gite 已提交
1524

C
cff-gite 已提交
1525 1526 1527 1528
| 参数名   | 类型                                                        | 必填 | 说明                                                         |
| -------- | ----------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| type     | [SensorType](#sensortype)                                   | 是   | 要取消订阅的方向传感器类型为SENSOR_TYPE_ID_ORIENTATION。     |
| callback | Callback<[OrientationResponse](#orientationresponse)> | 是   | 取消注册方向传感器的回调函数,上报的数据类型为OrientationResponse。 |
C
cff-gite 已提交
1529

H
HelloCrease 已提交
1530
**示例:** 
C
cff-gite 已提交
1531

C
cff-gite 已提交
1532
```
C
cff-gite 已提交
1533
function callback(data) {
C
cff-gite 已提交
1534 1535 1536
    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 已提交
1537 1538 1539 1540
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION, callback);
```

C
cff-gite 已提交
1541
## sensor.off(SensorType.SENSOR_TYPE_ID_PEDOMETER)
C
cff-gite 已提交
1542

C
cff-gite 已提交
1543
off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback?: Callback<PedometerResponse>): void
C
cff-gite 已提交
1544 1545 1546

取消订阅传感器数据。

C
cff-gite 已提交
1547 1548
**需要权限**:ohos.permission.ACTIVITY_MOTION,该权限为系统权限

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

H
HelloCrease 已提交
1551
**参数:** 
C
cff-gite 已提交
1552

H
HelloCrease 已提交
1553 1554 1555 1556
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的计步传感器类型为SENSOR_TYPE_ID_PEDOMETER。  |
| callback | Callback<[PedometerResponse](#pedometerresponse)> | 是    | 取消注册计步传感器的回调函数,上报的数据类型为PedometerResponse。 |
C
cff-gite 已提交
1557

C
cff-gite 已提交
1558
**返回值:** ;
C
cff-gite 已提交
1559

C
cff-gite 已提交
1560
```
C
cff-gite 已提交
1561 1562 1563 1564 1565 1566
function callback(data) {
    console.info('Steps: ' + data.steps);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER, callback);
```

C
cff-gite 已提交
1567
## sensor.off(SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION)
C
cff-gite 已提交
1568

C
cff-gite 已提交
1569
off(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback?: Callback<PedometerDetectionResponse>): void
C
cff-gite 已提交
1570 1571 1572 1573 1574 1575 1576

取消订阅传感器数据。

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

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

H
HelloCrease 已提交
1577
**参数:** 
C
cff-gite 已提交
1578

H
HelloCrease 已提交
1579 1580 1581 1582
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的计步检测传感器类型为SENSOR_TYPE_ID_PEDOMETER_DETECTION。 |
| callback | Callback<[PedometerDetectionResponse](#pedometerdetectionresponse)> | 是    | 取消注册计步检测传感器的回调函数,上报的数据类型为PedometerDetectionResponse。 |
C
cff-gite 已提交
1583

H
HelloCrease 已提交
1584
**示例:** 
C
cff-gite 已提交
1585

C
cff-gite 已提交
1586
```
C
cff-gite 已提交
1587 1588 1589 1590 1591 1592
function callback(data) {
    console.info('Scalar data: ' + data.scalar);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback);
```

C
cff-gite 已提交
1593
## sensor.off(SensorType.SENSOR_TYPE_ID_PROXIMITY)
C
cff-gite 已提交
1594

C
cff-gite 已提交
1595
off(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback?: Callback<ProximityResponse>): void
C
cff-gite 已提交
1596 1597 1598 1599 1600

取消订阅传感器数据。

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

H
HelloCrease 已提交
1601
**参数:** 
C
cff-gite 已提交
1602

H
HelloCrease 已提交
1603 1604 1605 1606
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的接近光传感器类型为SENSOR_TYPE_ID_PROXIMITY。 |
| callback | Callback<[ProximityResponse](#proximityresponse)> | 是    | 取消注册接近光传感器的回调函数,上报的数据类型为ProximityResponse。 |
C
cff-gite 已提交
1607

H
HelloCrease 已提交
1608
**示例:** 
C
cff-gite 已提交
1609

C
cff-gite 已提交
1610
```
C
cff-gite 已提交
1611 1612 1613 1614 1615 1616
function callback(data) {
    console.info('Distance: ' + data.distance);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_PROXIMITY, callback);
```

C
cff-gite 已提交
1617
## sensor.off(SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR)
C
cff-gite 已提交
1618

C
cff-gite 已提交
1619
off(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback?: Callback<RotationVectorResponse>): void
C
cff-gite 已提交
1620 1621 1622 1623 1624

取消订阅传感器数据。

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

H
HelloCrease 已提交
1625
**参数:** 
C
cff-gite 已提交
1626

H
HelloCrease 已提交
1627 1628 1629 1630
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的旋转矢量传感器类型为SENSOR_TYPE_ID_ROTATION_VECTOR。 |
| callback | Callback<[RotationVectorResponse](#rotationvectorresponse)> | 是    | 取消注册旋转矢量传感器的回调函数,上报的数据类型为RotationVectorResponse。 |
C
cff-gite 已提交
1631

H
HelloCrease 已提交
1632
**示例:** 
C
cff-gite 已提交
1633

C
cff-gite 已提交
1634
```
C
cff-gite 已提交
1635 1636 1637 1638
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 已提交
1639
    console.info('Scalar quantity: ' + data.w);
C
cff-gite 已提交
1640 1641 1642 1643
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback);
```

C
cff-gite 已提交
1644
## sensor.off(SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION)
C
cff-gite 已提交
1645

C
cff-gite 已提交
1646
off(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback?: Callback<SignificantMotionResponse>): void
C
cff-gite 已提交
1647 1648 1649 1650 1651

取消订阅传感器数据。

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

H
HelloCrease 已提交
1652
**参数:** 
C
cff-gite 已提交
1653

H
HelloCrease 已提交
1654 1655 1656 1657
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的大幅动作传感器类型为SENSOR_TYPE_ID_SIGNIFICANT_MOTION。 |
| callback | Callback<[SignificantMotionResponse](#significantmotionresponse)> | 是    | 取消注册有效运动传感器的回调函数,上报的数据类型为SignificantMotionResponse。 |
C
cff-gite 已提交
1658

H
HelloCrease 已提交
1659
**示例:** 
C
cff-gite 已提交
1660

C
cff-gite 已提交
1661
```
C
cff-gite 已提交
1662 1663 1664 1665 1666 1667
function callback(data) {
    console.info('Scalar data: ' + data.scalar);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback);
```

C
cff-gite 已提交
1668
## sensor.off(SensorType.SENSOR_TYPE_ID_WEAR_DETECTION)
C
cff-gite 已提交
1669

C
cff-gite 已提交
1670
off(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback?: Callback<WearDetectionResponse>): void
C
cff-gite 已提交
1671 1672 1673 1674 1675

取消订阅传感器数据。

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

H
HelloCrease 已提交
1676
**参数:** 
C
cff-gite 已提交
1677

H
HelloCrease 已提交
1678 1679 1680 1681
| 参数名      | 类型                                       | 必填   | 说明                                       |
| -------- | ---------------------------------------- | ---- | ---------------------------------------- |
| type     | [SensorType](#sensortype)                | 是    | 要取消订阅的佩戴检测传感器类型为SENSOR_TYPE_ID_WEAR_DETECTION。 |
| callback | Callback<[WearDetectionResponse](#weardetectionresponse)> | 是    | 取消注册佩戴检测传感器的回调函数,上报的数据类型为WearDetectionResponse。 |
C
cff-gite 已提交
1682

H
HelloCrease 已提交
1683
**示例:** 
C
cff-gite 已提交
1684

C
cff-gite 已提交
1685
```
C
cff-gite 已提交
1686 1687 1688 1689 1690
function accCallback(data) {
    console.info('Wear status: ' + data.value);
}
sensor.off(sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, accCallback);
```
Z
zengyawen 已提交
1691

Z
zengyawen 已提交
1692 1693 1694 1695 1696 1697
## sensor.transformCoordinateSystem

transformCoordinateSystem(inRotationVector: Array<number>, coordinates: CoordinatesOptions, callback: AsyncCallback<Array<number>>): void

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

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

H
HelloCrease 已提交
1700
**参数:** 
Z
zengyawen 已提交
1701

H
HelloCrease 已提交
1702 1703 1704 1705 1706
| 参数名              | 类型                                       | 必填   | 说明          |
| ---------------- | ---------------------------------------- | ---- | ----------- |
| inRotationVector | Array<number>                      | 是    | 表示旋转矩阵。     |
| coordinates      | [CoordinatesOptions](#coordinatesoptions) | 是    | 表示坐标系方向。    |
| callback         | AsyncCallback<Array<number>> | 是    | 返回转换后的旋转矩阵。 |
Z
zengyawen 已提交
1707

H
HelloCrease 已提交
1708
**示例:** 
Z
zengyawen 已提交
1709

C
cff-gite 已提交
1710 1711
```
sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3}, function(err, data) {
H
HelloCrease 已提交
1712 1713 1714 1715
    if (err) {
        console.error("Operation failed. Error code: " + err.code + ", message: " + err.message);
        return;
    }
C
cff-gite 已提交
1716
    console.info("Operation successed. Data obtained: " + data.x);
H
HelloCrease 已提交
1717 1718 1719 1720 1721
    for (var i=0; i < data.length; i++) {
        console.info("transformCoordinateSystem data[ " + i + "] = " + data[i]);
    }
 })
```
Z
zengyawen 已提交
1722 1723 1724 1725 1726 1727
## sensor.transformCoordinateSystem

transformCoordinateSystem(inRotationVector: Array&lt;number&gt;, coordinates: CoordinatesOptions): Promise&lt;Array&lt;number&gt;&gt;

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

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

H
HelloCrease 已提交
1730
**参数:** 
Z
zengyawen 已提交
1731

H
HelloCrease 已提交
1732 1733 1734 1735
| 参数名              | 类型                                       | 必填   | 说明       |
| ---------------- | ---------------------------------------- | ---- | -------- |
| inRotationVector | Array&lt;number&gt;                      | 是    | 表示旋转矩阵。  |
| coordinates      | [CoordinatesOptions](#coordinatesoptions) | 是    | 表示坐标系方向。 |
Z
zengyawen 已提交
1736

H
HelloCrease 已提交
1737
**返回值:** 
Z
zengyawen 已提交
1738

H
HelloCrease 已提交
1739 1740 1741
| 类型                                 | 说明          |
| ---------------------------------- | ----------- |
| Promise&lt;Array&lt;number&gt;&gt; | 返回转换后的旋转矩阵。 |
Z
zengyawen 已提交
1742

H
HelloCrease 已提交
1743
**示例:** 
Z
zengyawen 已提交
1744

C
cff-gite 已提交
1745 1746
```
const promise = sensor.transformCoordinateSystem([1, 0, 0, 0, 1, 0, 0, 0, 1], {'axisX':2, 'axisY':3});
H
HelloCrease 已提交
1747 1748 1749 1750 1751 1752 1753 1754 1755
    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 已提交
1756

Z
zengyawen 已提交
1757
## sensor.getGeomagneticField
Z
zengyawen 已提交
1758

Z
zengyawen 已提交
1759
getGeomagneticField(locationOptions: LocationOptions, timeMillis: number, callback: AsyncCallback&lt;GeomagneticResponse&gt;): void
Z
zengyawen 已提交
1760

Z
zengyawen 已提交
1761
获取地球上特定位置的地磁场。
Z
zengyawen 已提交
1762

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

H
HelloCrease 已提交
1765 1766 1767 1768 1769 1770
**参数:** 
| 参数名             | 类型                                       | 必填   | 说明                |
| --------------- | ---------------------------------------- | ---- | ----------------- |
| locationOptions | [LocationOptions](#locationoptions)      | 是    | 地理位置。             |
| timeMillis      | number                                   | 是    | 表示获取磁偏角的时间,单位为毫秒。 |
| callback        | AsyncCallback&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 是    | 返回磁场信息。           |
Z
zengyawen 已提交
1771

H
HelloCrease 已提交
1772
**示例:** 
C
cff-gite 已提交
1773 1774
```
sensor.getGeomagneticField([80, 0, 0], 1580486400000, function(err, data)  {
H
HelloCrease 已提交
1775 1776 1777 1778 1779 1780 1781 1782 1783
    if (err) {
        console.error('Operation failed. Error code: ' + err.code + '; message: ' + err.message);
        return;
    }
    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 已提交
1784 1785 1786 1787 1788 1789
## sensor.getGeomagneticField

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

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

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

H
HelloCrease 已提交
1792 1793 1794 1795 1796
**参数:** 
| 参数名             | 类型                                  | 必填   | 说明                |
| --------------- | ----------------------------------- | ---- | ----------------- |
| locationOptions | [LocationOptions](#locationoptions) | 是    | 地理位置。             |
| timeMillis      | number                              | 是    | 表示获取磁偏角的时间,单位为毫秒。 |
Z
zengyawen 已提交
1797

H
HelloCrease 已提交
1798 1799 1800 1801
**返回值:** 
| 类型                                       | 说明      |
| ---------------------------------------- | ------- |
| Promise&lt;[GeomagneticResponse](#geomagneticresponse)&gt; | 返回磁场信息。 |
Z
zengyawen 已提交
1802

C
cff-gite 已提交
1803 1804 1805
**返回值:** 
  ```
  const promise = sensor.getGeomagneticField([80, 0, 0], 1580486400000);
Z
zengyawen 已提交
1806
      promise.then((data) => {
Z
zengyawen 已提交
1807 1808 1809
          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 已提交
1810
      }).catch((reason) => {
Z
zengyawen 已提交
1811 1812
          console.info('Operation failed.');
  })
Z
zengyawen 已提交
1813 1814
  ```

Z
zengyawen 已提交
1815 1816 1817 1818 1819 1820
## sensor.getAltitude

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

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

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

H
HelloCrease 已提交
1823
**参数:** 
Z
zengyawen 已提交
1824

H
HelloCrease 已提交
1825 1826 1827 1828 1829
| 参数名             | 类型                          | 必填   | 说明                   |
| --------------- | --------------------------- | ---- | -------------------- |
| seaPressure     | number                      | 是    | 表示海平面气压值,单位为hPa。     |
| currentPressure | number                      | 是    | 表示设备所在高度的气压值,单位为hPa。 |
| callback        | AsyncCallback&lt;number&gt; | 是    | 返回设备所在的海拔高度,单位为米。    |
Z
zengyawen 已提交
1830

C
cff-gite 已提交
1831
**返回值:** 
Z
zengyawen 已提交
1832

C
cff-gite 已提交
1833
  ```
Z
zengyawen 已提交
1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849
  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 已提交
1850 1851
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
1852
**参数:** 
Z
zengyawen 已提交
1853

H
HelloCrease 已提交
1854 1855 1856 1857
| 参数名             | 类型     | 必填   | 说明                   |
| --------------- | ------ | ---- | -------------------- |
| seaPressure     | number | 是    | 表示海平面气压值,单位为hPa。     |
| currentPressure | number | 是    | 表示设备所在高度的气压值,单位为hPa。 |
Z
zengyawen 已提交
1858

H
HelloCrease 已提交
1859
**返回值:** 
Z
zengyawen 已提交
1860

H
HelloCrease 已提交
1861 1862 1863
| 类型                    | 说明                 |
| --------------------- | ------------------ |
| Promise&lt;number&gt; | 返回设备所在的海拔高度(单位:米)。 |
Z
zengyawen 已提交
1864

C
cff-gite 已提交
1865
**返回值:** 
Z
zengyawen 已提交
1866

C
cff-gite 已提交
1867
  ```
Z
zengyawen 已提交
1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882
  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 已提交
1883 1884
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
1885
**参数:** 
Z
zengyawen 已提交
1886

H
HelloCrease 已提交
1887 1888 1889 1890
| 参数名               | 类型                          | 必填   | 说明             |
| ----------------- | --------------------------- | ---- | -------------- |
| inclinationMatrix | Array&lt;number&gt;         | 是    | 表示倾斜矩阵。        |
| callback          | AsyncCallback&lt;number&gt; | 是    | 返回地磁倾斜角,单位为弧度。 |
Z
zengyawen 已提交
1891

C
cff-gite 已提交
1892
**返回值:** 
Z
zengyawen 已提交
1893

C
cff-gite 已提交
1894
  ```
Z
zengyawen 已提交
1895 1896
  sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data)  {
      if (err) {
C
cff-gite 已提交
1897
          console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + 
Z
zengyawen 已提交
1898 1899 1900
                        err.message);
          return;
      }
H
HelloCrease 已提交
1901
          console.info("Successed to get getGeomagneticDip interface get data: " + data);
Z
zengyawen 已提交
1902 1903 1904 1905 1906 1907 1908 1909 1910
  })
  ```

## sensor.getGeomagneticDip

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

根据倾斜矩阵计算地磁倾斜角。

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

H
HelloCrease 已提交
1913
**参数:** 
Z
zengyawen 已提交
1914

H
HelloCrease 已提交
1915 1916 1917
| 参数名               | 类型                  | 必填   | 说明      |
| ----------------- | ------------------- | ---- | ------- |
| inclinationMatrix | Array&lt;number&gt; | 是    | 表示倾斜矩阵。 |
Z
zengyawen 已提交
1918

H
HelloCrease 已提交
1919
**返回值:** 
Z
zengyawen 已提交
1920

H
HelloCrease 已提交
1921 1922 1923
| 类型                    | 说明             |
| --------------------- | -------------- |
| Promise&lt;number&gt; | 返回地磁倾斜角,单位为弧度。 |
Z
zengyawen 已提交
1924

C
cff-gite 已提交
1925
**返回值:** 
Z
zengyawen 已提交
1926

C
cff-gite 已提交
1927
  ```
Z
zengyawen 已提交
1928 1929 1930 1931 1932 1933 1934 1935 1936 1937
  const promise = sensor.getGeomagneticDip([1, 0, 0, 0, 1, 0, 0, 0, 1]);
      promise.then((data) => {
          console.info(' getGeomagneticDip_promise successed', data);
      }).catch((err) => {
           console.error("Operation failed");
  })
  ```

## sensor. getAngleModify

H
HelloCrease 已提交
1938
getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Array&lt;number&gt;, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void
Z
zengyawen 已提交
1939 1940 1941

获取两个旋转矩阵之间的角度变化。

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

H
HelloCrease 已提交
1944
**参数:** 
Z
zengyawen 已提交
1945

H
HelloCrease 已提交
1946 1947 1948 1949 1950
| 参数名                   | 类型                                       | 必填   | 说明                 |
| --------------------- | ---------------------------------------- | ---- | ------------------ |
| currentRotationMatrix | Array&lt;number&gt;                      | 是    | 表示当前旋转矩阵。          |
| preRotationMatrix     | Array&lt;number&gt;                      | 是    | 表示旋转矩阵。            |
| callback              | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是    | 返回z、x、y轴方向的旋转角度变化。 |
Z
zengyawen 已提交
1951

C
cff-gite 已提交
1952
**返回值:** 
Z
zengyawen 已提交
1953

C
cff-gite 已提交
1954
  ```
Z
zengyawen 已提交
1955 1956
  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) {
C
cff-gite 已提交
1957
          console.error(LABEL + 'Failed to register data, error code is: ' + err.code + ', message: ' + 
Z
zengyawen 已提交
1958 1959 1960 1961 1962
                        err.message);
          return;
      }
      console.info("SensorJsAPI--->Successed to get  getAngleModifiy interface get data: " + data.x);
      for (var i=0; i < data.length; i++) {
C
cff-gite 已提交
1963
          console.info(LABEL + "data[" + i + "]: " + data[i]);
Z
zengyawen 已提交
1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974
      }
  })
  ```


## sensor. getAngleModify

getAngleModify(currentRotationMatrix: Array&lt;number&gt;, preRotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;

获取两个旋转矩阵之间的角度变化。

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

H
HelloCrease 已提交
1977
**参数:** 
Z
zengyawen 已提交
1978

H
HelloCrease 已提交
1979 1980 1981 1982
| 参数名                   | 类型                  | 必填   | 说明        |
| --------------------- | ------------------- | ---- | --------- |
| currentRotationMatrix | Array&lt;number&gt; | 是    | 表示当前旋转矩阵。 |
| preRotationMatrix     | Array&lt;number&gt; | 是    | 表示旋转矩阵。   |
Z
zengyawen 已提交
1983

H
HelloCrease 已提交
1984
**返回值:** 
Z
zengyawen 已提交
1985

H
HelloCrease 已提交
1986 1987 1988
| 类型                                 | 说明                 |
| ---------------------------------- | ------------------ |
| Promise&lt;Array&lt;number&gt;&gt; | 返回z、x、y轴方向的旋转角度变化。 |
Z
zengyawen 已提交
1989

C
cff-gite 已提交
1990
**返回值:** 
Z
zengyawen 已提交
1991

C
cff-gite 已提交
1992
  ```
Z
zengyawen 已提交
1993 1994
  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) => {
C
cff-gite 已提交
1995
          console.info(LABEL + 'getAngleModifiy_promise success');
Z
zengyawen 已提交
1996
          for (var i=0; i < data.length; i++) {
C
cff-gite 已提交
1997
              console.info(LABEL + "data[" + i + "]: " + data[i]);
Z
zengyawen 已提交
1998 1999
          }
      }).catch((reason) => {
C
cff-gite 已提交
2000
          console.info(LABEL + "promise::catch", reason);
Z
zengyawen 已提交
2001 2002 2003 2004 2005 2006 2007 2008 2009 2010
  })
  ```


## sensor.createRotationMatrix

createRotationMatrix(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void

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

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

H
HelloCrease 已提交
2013
**参数:** 
Z
zengyawen 已提交
2014

H
HelloCrease 已提交
2015 2016 2017 2018
| 参数名            | 类型                                       | 必填   | 说明      |
| -------------- | ---------------------------------------- | ---- | ------- |
| rotationVector | Array&lt;number&gt;                      | 是    | 表示旋转矢量。 |
| callback       | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是    | 返回旋转矩阵。 |
Z
zengyawen 已提交
2019

C
cff-gite 已提交
2020
**返回值:** 
Z
zengyawen 已提交
2021

C
cff-gite 已提交
2022
  ```
Z
zengyawen 已提交
2023 2024
  sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data) {
      if (err) {
C
cff-gite 已提交
2025
          console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + 
Z
zengyawen 已提交
2026 2027 2028 2029 2030
                        err.message);
          return;
      }
      console.info("SensorJsAPI--->Successed to get createRotationMatrix interface get data: " + data.x);
      for (var i=0; i < data.length; i++) {
C
cff-gite 已提交
2031
          console.info(LABEL + "data[" + i + "]: " + data[i]);
Z
zengyawen 已提交
2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042
      }
  })
  ```


## sensor.createRotationMatrix

createRotationMatrix(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;

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

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

H
HelloCrease 已提交
2045
**参数:** 
Z
zengyawen 已提交
2046

H
HelloCrease 已提交
2047 2048 2049
| 参数名            | 类型                  | 必填   | 说明      |
| -------------- | ------------------- | ---- | ------- |
| rotationVector | Array&lt;number&gt; | 是    | 表示旋转矢量。 |
Z
zengyawen 已提交
2050

H
HelloCrease 已提交
2051
**返回值:** 
Z
zengyawen 已提交
2052

H
HelloCrease 已提交
2053 2054 2055
| 类型                                 | 说明      |
| ---------------------------------- | ------- |
| Promise&lt;Array&lt;number&gt;&gt; | 返回旋转矩阵。 |
Z
zengyawen 已提交
2056

C
cff-gite 已提交
2057
**返回值:** 
Z
zengyawen 已提交
2058

C
cff-gite 已提交
2059
  ```
Z
zengyawen 已提交
2060 2061
  const promise = sensor.createRotationMatrix([0.20046076, 0.21907, 0.73978853, 0.60376877]);
      promise.then((data) => {
C
cff-gite 已提交
2062
          console.info(LABEL + 'createRotationMatrix_promise success');
Z
zengyawen 已提交
2063
          for (var i=0; i < data.length; i++) {
C
cff-gite 已提交
2064
              console.info(LABEL + "data[" + i + "]: " + data[i]);
Z
zengyawen 已提交
2065 2066
          }
      }).catch((reason) => {
C
cff-gite 已提交
2067
          console.info(LABEL + "promise::catch", reason);
Z
zengyawen 已提交
2068 2069 2070 2071 2072 2073 2074 2075 2076 2077
  })	
  ```


## sensor.createQuaternion

createQuaternion(rotationVector: Array&lt;number&gt;, callback: AsyncCallback&lt;Array&lt;number&gt;&gt;): void

将旋转矢量转换为四元数。

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

H
HelloCrease 已提交
2080
**参数:** 
Z
zengyawen 已提交
2081

H
HelloCrease 已提交
2082 2083 2084 2085
| 参数名            | 类型                                       | 必填   | 说明      |
| -------------- | ---------------------------------------- | ---- | ------- |
| rotationVector | Array&lt;number&gt;                      | 是    | 表示旋转矢量。 |
| callback       | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是    | 返回四元数。  |
Z
zengyawen 已提交
2086

C
cff-gite 已提交
2087
**返回值:** 
Z
zengyawen 已提交
2088

C
cff-gite 已提交
2089
  ```
Z
zengyawen 已提交
2090 2091
  sensor.createQuaternion([0.20046076, 0.21907, 0.73978853, 0.60376877], function(err, data)  {
      if (err) {
C
cff-gite 已提交
2092
          console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' + 
Z
zengyawen 已提交
2093 2094 2095 2096 2097
                        err.message);
          return;
      }
      console.info("SensorJsAPI--->Successed to get  createQuaternion interface get data: " + data.x);
      for (var i=0; i < data.length; i++) {
C
cff-gite 已提交
2098
          console.info(LABEL + "data[" + i + "]: " + data[i]);
Z
zengyawen 已提交
2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109
      }
  })
  ```


## sensor.createQuaternion

createQuaternion(rotationVector: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;

将旋转矢量转换为四元数。

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

H
HelloCrease 已提交
2112
**参数:** 
Z
zengyawen 已提交
2113

H
HelloCrease 已提交
2114 2115 2116
| 参数名            | 类型                  | 必填   | 说明      |
| -------------- | ------------------- | ---- | ------- |
| rotationVector | Array&lt;number&gt; | 是    | 表示旋转矢量。 |
Z
zengyawen 已提交
2117

H
HelloCrease 已提交
2118
**返回值:** 
Z
zengyawen 已提交
2119

H
HelloCrease 已提交
2120 2121 2122
| 类型                                 | 说明     |
| ---------------------------------- | ------ |
| Promise&lt;Array&lt;number&gt;&gt; | 返回四元数。 |
Z
zengyawen 已提交
2123

C
cff-gite 已提交
2124
**返回值:** 
Z
zengyawen 已提交
2125

C
cff-gite 已提交
2126
  ```
Z
zengyawen 已提交
2127 2128 2129 2130
  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++) {
C
cff-gite 已提交
2131
              console.info(LABEL + "data[" + i + "]: " + data[i]);
Z
zengyawen 已提交
2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144
          }
      }).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 已提交
2145 2146
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
2147
**参数:** 
Z
zengyawen 已提交
2148

H
HelloCrease 已提交
2149 2150 2151 2152
| 参数名            | 类型                                       | 必填   | 说明                 |
| -------------- | ---------------------------------------- | ---- | ------------------ |
| rotationMatrix | Array&lt;number&gt;                      | 是    | 表示旋转矩阵。            |
| callback       | AsyncCallback&lt;Array&lt;number&gt;&gt; | 是    | 返回围绕z、x、y轴方向的旋转角度。 |
Z
zengyawen 已提交
2153

C
cff-gite 已提交
2154
**返回值:** 
Z
zengyawen 已提交
2155

C
cff-gite 已提交
2156
  ```
Z
zengyawen 已提交
2157 2158
  sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1], function(err, data)  {
      if (err) {
C
cff-gite 已提交
2159
          console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
Z
zengyawen 已提交
2160 2161 2162
                        err.message);
          return;
      }
C
cff-gite 已提交
2163
      console.info(LABEL + "SensorJsAPI--->Successed to get getDirection interface get data: " + data.x);
Z
zengyawen 已提交
2164
      for (var i = 1; i < data.length; i++) {
C
cff-gite 已提交
2165
          console.info(TAG +"sensor_getDirection_callback" + data[i]);
Z
zengyawen 已提交
2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176
      }
  })
  ```


## sensor.getDirection

getDirection(rotationMatrix: Array&lt;number&gt;): Promise&lt;Array&lt;number&gt;&gt;

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

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

H
HelloCrease 已提交
2179
**参数:** 
Z
zengyawen 已提交
2180

H
HelloCrease 已提交
2181 2182 2183
| 参数名            | 类型                  | 必填   | 说明      |
| -------------- | ------------------- | ---- | ------- |
| rotationMatrix | Array&lt;number&gt; | 是    | 表示旋转矩阵。 |
Z
zengyawen 已提交
2184

H
HelloCrease 已提交
2185
**返回值:** 
Z
zengyawen 已提交
2186

H
HelloCrease 已提交
2187 2188 2189
| 类型                                 | 说明                 |
| ---------------------------------- | ------------------ |
| Promise&lt;Array&lt;number&gt;&gt; | 返回围绕z、x、y轴方向的旋转角度。 |
Z
zengyawen 已提交
2190

C
cff-gite 已提交
2191
**返回值:** 
Z
zengyawen 已提交
2192

C
cff-gite 已提交
2193
  ```
Z
zengyawen 已提交
2194 2195
  const promise = sensor.getDirection([1, 0, 0, 0, 1, 0, 0, 0, 1]);
      promise.then((data) => {
C
cff-gite 已提交
2196
          console.info(' sensor_getAltitude_Promise success', data.x);
Z
zengyawen 已提交
2197
          for (var i = 1; i < data.length; i++) {
C
cff-gite 已提交
2198
              console.info(TAG +"sensor_getDirection_promise" + data[i]);
Z
zengyawen 已提交
2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211
          }
      }).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 已提交
2212 2213
**系统能力**:SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
2214
**参数:** 
Z
zengyawen 已提交
2215

H
HelloCrease 已提交
2216 2217 2218 2219 2220
| 参数名         | 类型                                       | 必填   | 说明      |
| ----------- | ---------------------------------------- | ---- | ------- |
| gravity     | Array&lt;number&gt;                      | 是    | 表示重力向量。 |
| geomagnetic | Array&lt;number&gt;                      | 是    | 表示地磁矢量。 |
| callback    | AsyncCallback&lt;[RotationMatrixResponse](#rotationmatrixresponse)&gt; | 是    | 返回旋转矩阵。 |
Z
zengyawen 已提交
2221

C
cff-gite 已提交
2222
**返回值:** 
Z
zengyawen 已提交
2223

C
cff-gite 已提交
2224
  ```
Z
zengyawen 已提交
2225 2226
  sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444], function(err, data)  {
      if (err) {
C
cff-gite 已提交
2227
          console.error(LABEL + 'SensorJsAPI--->Failed to register data, error code is: ' + err.code + ', message: ' +
Z
zengyawen 已提交
2228 2229 2230 2231 2232
                        err.message);
          return;
      }
      console.info("SensorJsAPI--->Successed to get createRotationMatrix interface get data: " + data.x);
      for (var i=0; i < data.length; i++) {
C
cff-gite 已提交
2233
          console.info(LABEL + "data[" + i + "]: " + data[i])
Z
zengyawen 已提交
2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244
      }
  })
  ```


## sensor.createRotationMatrix

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

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

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

H
HelloCrease 已提交
2247
**参数:** 
Z
zengyawen 已提交
2248

H
HelloCrease 已提交
2249 2250 2251 2252
| 参数名         | 类型                  | 必填   | 说明      |
| ----------- | ------------------- | ---- | ------- |
| gravity     | Array&lt;number&gt; | 是    | 表示重力向量。 |
| geomagnetic | Array&lt;number&gt; | 是    | 表示地磁矢量。 |
Z
zengyawen 已提交
2253

H
HelloCrease 已提交
2254
**返回值:** 
Z
zengyawen 已提交
2255

H
HelloCrease 已提交
2256 2257 2258
| 类型                                       | 说明      |
| ---------------------------------------- | ------- |
| Promise&lt;[RotationMatrixResponse](#rotationmatrixresponse)&gt; | 返回旋转矩阵。 |
Z
zengyawen 已提交
2259

C
cff-gite 已提交
2260
**返回值:** 
Z
zengyawen 已提交
2261

C
cff-gite 已提交
2262
  ```
Z
zengyawen 已提交
2263 2264
  const promise = sensor.createRotationMatrix([-0.27775216, 0.5351276, 9.788099], [210.87253, -78.6096, -111.44444]);
      promise.then((data) => {
C
cff-gite 已提交
2265
          console.info(LABEL + 'createRotationMatrix_promise successed');
Z
zengyawen 已提交
2266
          for (var i=0; i < data.length; i++) {
C
cff-gite 已提交
2267
              console.info(LABEL + "data[" + i + "]: " + data[i]);
Z
zengyawen 已提交
2268 2269
          }
      }).catch((err) => {
C
cff-gite 已提交
2270
          console.info(LABEL + 'promise failed');
Z
zengyawen 已提交
2271 2272 2273
  })
  ```

Z
zengyawen 已提交
2274

Z
zengyawen 已提交
2275
## SensorType
Z
zengyawen 已提交
2276 2277 2278

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

C
cff-gite 已提交
2279 2280
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2281

H
HelloCrease 已提交
2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304
| 名称                                       | 默认值  | 说明          |
| ---------------------------------------- | ---- | ----------- |
| 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       | 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                | 278  | 心率传感器。      |
| SENSOR_TYPE_ID_WEAR_DETECTION            | 280  | 佩戴检测传感器。    |
| SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED | 281  | 未校准加速度计传感器。 |
Z
zengyawen 已提交
2305 2306


Z
zengyawen 已提交
2307 2308 2309 2310
## Response

传感器数据的时间戳。

C
cff-gite 已提交
2311 2312
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
2313 2314 2315
| 名称        | 参数类型   | 可读   | 可写   | 说明           |
| --------- | ------ | ---- | ---- | ------------ |
| timestamp | number | 是    | 是    | 传感器数据上报的时间戳。 |
Z
zengyawen 已提交
2316 2317


Z
zengyawen 已提交
2318
## AccelerometerResponse
Z
zengyawen 已提交
2319

Z
zengyawen 已提交
2320
加速度传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2321

C
cff-gite 已提交
2322 2323
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2324

H
HelloCrease 已提交
2325 2326 2327 2328 2329
| 名称   | 参数类型   | 可读   | 可写   | 说明                     |
| ---- | ------ | ---- | ---- | ---------------------- |
| x    | number | 是    | 是    | 施加在设备x轴的加速度,单位 : m/s2。 |
| y    | number | 是    | 是    | 施加在设备y轴的加速度,单位 : m/s2。 |
| z    | number | 是    | 是    | 施加在设备z轴的加速度,单位 : m/s2。 |
Z
zengyawen 已提交
2330 2331 2332


## LinearAccelerometerResponse
Z
zengyawen 已提交
2333

Z
zengyawen 已提交
2334
线性加速度传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2335

C
cff-gite 已提交
2336 2337
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2338

H
HelloCrease 已提交
2339 2340 2341 2342 2343
| 名称   | 参数类型   | 可读   | 可写   | 说明                       |
| ---- | ------ | ---- | ---- | ------------------------ |
| x    | number | 是    | 是    | 施加在设备x轴的线性加速度,单位 : m/s2。 |
| y    | number | 是    | 是    | 施加在设备y轴的线性加速度,单位 : m/s2。 |
| z    | number | 是    | 是    | 施加在设备z轴的线性加速度,单位 : m/s2。 |
Z
zengyawen 已提交
2344 2345 2346


## AccelerometerUncalibratedResponse
Z
zengyawen 已提交
2347

Z
zengyawen 已提交
2348
未校准加速度计传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2349

C
cff-gite 已提交
2350 2351
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2352

H
HelloCrease 已提交
2353 2354 2355 2356 2357 2358 2359 2360
| 名称    | 参数类型   | 可读   | 可写   | 说明                           |
| ----- | ------ | ---- | ---- | ---------------------------- |
| 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 已提交
2361 2362 2363


## GravityResponse
Z
zengyawen 已提交
2364

Z
zengyawen 已提交
2365
重力传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2366

C
cff-gite 已提交
2367 2368
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2369

H
HelloCrease 已提交
2370 2371 2372 2373 2374
| 名称   | 参数类型   | 可读   | 可写   | 说明                       |
| ---- | ------ | ---- | ---- | ------------------------ |
| x    | number | 是    | 是    | 施加在设备x轴的重力加速度,单位 : m/s2。 |
| y    | number | 是    | 是    | 施加在设备y轴的重力加速度,单位 : m/s2。 |
| z    | number | 是    | 是    | 施加在设备z轴的重力加速度,单位 : m/s2。 |
Z
zengyawen 已提交
2375 2376 2377


## OrientationResponse
Z
zengyawen 已提交
2378

Z
zengyawen 已提交
2379
方向传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2380

C
cff-gite 已提交
2381 2382
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2383

C
cff-gite 已提交
2384 2385
| 名称    | 参数类型   | 可读   | 可写   | 说明                       |
| ----- | ------ | ---- | ---- | ------------------------ |
2386
| alpha | number | 是    | 是    | 设备围绕Z轴的旋转角度,单位:度。 |
C
cff-gite 已提交
2387 2388
| beta  | number | 是    | 是    | 设备围绕X轴的旋转角度,单位:度。  |
| gamma | number | 是    | 是    | 设备围绕Y轴的旋转角度,单位:度。  |
Z
zengyawen 已提交
2389 2390 2391


## RotationVectorResponse
Z
zengyawen 已提交
2392

Z
zengyawen 已提交
2393
旋转矢量传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2394

C
cff-gite 已提交
2395 2396
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2397

H
HelloCrease 已提交
2398 2399 2400 2401 2402 2403
| 名称   | 参数类型   | 可读   | 可写   | 说明        |
| ---- | ------ | ---- | ---- | --------- |
| x    | number | 是    | 是    | 旋转矢量x轴分量。 |
| y    | number | 是    | 是    | 旋转矢量y轴分量。 |
| z    | number | 是    | 是    | 旋转矢量z轴分量。 |
| w    | number | 是    | 是    | 标量。       |
Z
zengyawen 已提交
2404 2405 2406


## GyroscopeResponse
Z
zengyawen 已提交
2407

Z
zengyawen 已提交
2408
陀螺仪传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2409

C
cff-gite 已提交
2410 2411
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2412

H
HelloCrease 已提交
2413 2414 2415 2416 2417
| 名称   | 参数类型   | 可读   | 可写   | 说明                  |
| ---- | ------ | ---- | ---- | ------------------- |
| x    | number | 是    | 是    | 设备x轴的旋转角速度,单位rad/s。 |
| y    | number | 是    | 是    | 设备y轴的旋转角速度,单位rad/s。 |
| z    | number | 是    | 是    | 设备z轴的旋转角速度,单位rad/s。 |
Z
zengyawen 已提交
2418 2419 2420


## GyroscopeUncalibratedResponse
Z
zengyawen 已提交
2421

Z
zengyawen 已提交
2422
未校准陀螺仪传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2423

C
cff-gite 已提交
2424 2425
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2426

H
HelloCrease 已提交
2427 2428 2429 2430 2431 2432 2433 2434
| 名称    | 参数类型   | 可读   | 可写   | 说明                       |
| ----- | ------ | ---- | ---- | ------------------------ |
| 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 已提交
2435 2436 2437


## SignificantMotionResponse
Z
zengyawen 已提交
2438

Z
zengyawen 已提交
2439
有效运动传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2440

C
cff-gite 已提交
2441 2442
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2443

H
HelloCrease 已提交
2444 2445 2446
| 名称     | 参数类型   | 可读   | 可写   | 说明                                       |
| ------ | ------ | ---- | ---- | ---------------------------------------- |
| scalar | number | 是    | 是    | 表示剧烈运动程度。测量三个物理轴(x、y&nbsp;&nbsp;z)上,设备是否存在大幅度运动;如果取值为1则代表存在大幅度运动,取值为0则代表没有大幅度运动。 |
Z
zengyawen 已提交
2447 2448 2449


## ProximityResponse
Z
zengyawen 已提交
2450

Z
zengyawen 已提交
2451
接近光传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2452

C
cff-gite 已提交
2453 2454
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2455

H
HelloCrease 已提交
2456 2457 2458
| 名称       | 参数类型   | 可读   | 可写   | 说明                           |
| -------- | ------ | ---- | ---- | ---------------------------- |
| distance | number | 是    | 是    | 可见物体与设备显示器的接近程度。0表示接近,1表示远离。 |
Z
zengyawen 已提交
2459 2460 2461


## LightResponse
Z
zengyawen 已提交
2462

Z
zengyawen 已提交
2463
环境光传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2464

C
cff-gite 已提交
2465 2466
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2467

H
HelloCrease 已提交
2468 2469 2470
| 名称        | 参数类型   | 可读   | 可写   | 说明          |
| --------- | ------ | ---- | ---- | ----------- |
| intensity | number | 是    | 是    | 光强(单位:勒克斯)。 |
Z
zengyawen 已提交
2471 2472 2473


## HallResponse
Z
zengyawen 已提交
2474

Z
zengyawen 已提交
2475
霍尔传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2476

C
cff-gite 已提交
2477 2478
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2479

H
HelloCrease 已提交
2480 2481 2482
| 名称     | 参数类型   | 可读   | 可写   | 说明                                |
| ------ | ------ | ---- | ---- | --------------------------------- |
| status | number | 是    | 是    | 显示霍尔状态。测量设备周围是否存在磁力吸引,0表示有,1表示没有。 |
Z
zengyawen 已提交
2483 2484 2485


## MagneticFieldResponse
Z
zengyawen 已提交
2486

Z
zengyawen 已提交
2487
磁场传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2488

C
cff-gite 已提交
2489 2490
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2491

H
HelloCrease 已提交
2492 2493 2494 2495 2496
| 名称   | 参数类型   | 可读   | 可写   | 说明                 |
| ---- | ------ | ---- | ---- | ------------------ |
| x    | number | 是    | 是    | x轴环境磁场强度,单位 : μT。  |
| y    | number | 是    | 是    | y轴环境磁场强度,单位 : μT。  |
| z    | number | 是    | 是    | z轴环境磁场强度,单位 : μT。。 |
Z
zengyawen 已提交
2497 2498 2499


## MagneticFieldUncalibratedResponse
Z
zengyawen 已提交
2500

Z
zengyawen 已提交
2501
未校准磁场传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2502

C
cff-gite 已提交
2503 2504
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2505

H
HelloCrease 已提交
2506 2507 2508 2509 2510 2511 2512 2513
| 名称    | 参数类型   | 可读   | 可写   | 说明                     |
| ----- | ------ | ---- | ---- | ---------------------- |
| 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 已提交
2514 2515 2516


## PedometerResponse
Z
zengyawen 已提交
2517

Z
zengyawen 已提交
2518
计步传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2519

C
cff-gite 已提交
2520 2521
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2522

H
HelloCrease 已提交
2523 2524 2525
| 名称    | 参数类型   | 可读   | 可写   | 说明       |
| ----- | ------ | ---- | ---- | -------- |
| steps | number | 是    | 是    | 用户的行走步数。 |
Z
zengyawen 已提交
2526 2527 2528


## HumidityResponse
Z
zengyawen 已提交
2529

Z
zengyawen 已提交
2530
湿度传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2531

C
cff-gite 已提交
2532 2533
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2534

H
HelloCrease 已提交
2535 2536 2537
| 名称       | 参数类型   | 可读   | 可写   | 说明                                   |
| -------- | ------ | ---- | ---- | ------------------------------------ |
| humidity | number | 是    | 是    | 湿度值。测量环境的相对湿度,以百分比&nbsp;(%)&nbsp;表示。 |
Z
zengyawen 已提交
2538 2539


C
cff-gite 已提交
2540
## PedometerDetectionResponse
Z
zengyawen 已提交
2541

Z
zengyawen 已提交
2542
计步检测传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2543

C
cff-gite 已提交
2544 2545
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2546

H
HelloCrease 已提交
2547 2548 2549
| 名称     | 参数类型   | 可读   | 可写   | 说明                                       |
| ------ | ------ | ---- | ---- | ---------------------------------------- |
| scalar | number | 是    | 是    | 计步器检测。检测用户的计步动作,如果取值为1则代表用户产生了计步行走的动作,取值为0则代表用户没有发生运动。 |
Z
zengyawen 已提交
2550 2551 2552


## AmbientTemperatureResponse
Z
zengyawen 已提交
2553

Z
zengyawen 已提交
2554
温度传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2555

C
cff-gite 已提交
2556 2557
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2558

H
HelloCrease 已提交
2559 2560 2561
| 名称          | 参数类型   | 可读   | 可写   | 说明            |
| ----------- | ------ | ---- | ---- | ------------- |
| temperature | number | 是    | 是    | 环境温度(单位:摄氏度)。 |
Z
zengyawen 已提交
2562 2563 2564


## BarometerResponse
Z
zengyawen 已提交
2565

Z
zengyawen 已提交
2566
气压计传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2567

C
cff-gite 已提交
2568 2569
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2570

H
HelloCrease 已提交
2571 2572 2573
| 名称       | 参数类型   | 可读   | 可写   | 说明           |
| -------- | ------ | ---- | ---- | ------------ |
| pressure | number | 是    | 是    | 压力值(单位:帕斯卡)。 |
Z
zengyawen 已提交
2574 2575 2576


## HeartRateResponse
Z
zengyawen 已提交
2577

Z
zengyawen 已提交
2578
心率传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2579

C
cff-gite 已提交
2580 2581
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2582

H
HelloCrease 已提交
2583 2584 2585
| 名称        | 参数类型   | 可读   | 可写   | 说明                    |
| --------- | ------ | ---- | ---- | --------------------- |
| heartRate | number | 是    | 是    | 心率值。测量用户的心率数值,单位:bpm。 |
Z
zengyawen 已提交
2586 2587 2588


## WearDetectionResponse
Z
zengyawen 已提交
2589

Z
zengyawen 已提交
2590
佩戴检测传感器数据,继承于[Response](#response)
Z
zengyawen 已提交
2591

C
cff-gite 已提交
2592 2593
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

Z
zengyawen 已提交
2594

H
HelloCrease 已提交
2595 2596 2597
| 名称    | 参数类型   | 可读   | 可写   | 说明                        |
| ----- | ------ | ---- | ---- | ------------------------- |
| value | number | 是    | 是    | 表示设备是否被穿戴(1表示已穿戴,0表示未穿戴)。 |
Z
zengyawen 已提交
2598 2599 2600 2601


## Options

Z
zengyawen 已提交
2602
设置传感器上报频率。
Z
zengyawen 已提交
2603

C
cff-gite 已提交
2604 2605
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
2606 2607
| 名称       | 参数类型   | 说明                          |
| -------- | ------ | --------------------------- |
Z
zengyawen 已提交
2608 2609
| interval | number | 表示传感器的上报频率,默认值为200000000ns。 |

Z
zengyawen 已提交
2610 2611
## RotationMatrixResponse

C
cff-gite 已提交
2612 2613 2614
设置旋转矩阵响应对象。

**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor
Z
zengyawen 已提交
2615

H
HelloCrease 已提交
2616 2617 2618 2619
| 名称          | 参数类型                | 可读   | 可写   | 说明    |
| ----------- | ------------------- | ---- | ---- | ----- |
| rotation    | Array&lt;number&gt; | 是    | 是    | 旋转矩阵。 |
| inclination | Array&lt;number&gt; | 是    | 是    | 倾斜矩阵。 |
Z
zengyawen 已提交
2620 2621 2622 2623


## CoordinatesOptions

C
cff-gite 已提交
2624 2625 2626
设置坐标选项对象。

**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor
Z
zengyawen 已提交
2627

H
HelloCrease 已提交
2628 2629 2630 2631
| 名称   | 参数类型   | 可读   | 可写   | 说明     |
| ---- | ------ | ---- | ---- | ------ |
| x    | number | 是    | 是    | x坐标方向。 |
| y    | number | 是    | 是    | y坐标方向。 |
Z
zengyawen 已提交
2632

Z
zengyawen 已提交
2633 2634 2635

## GeomagneticResponse

Z
zengyawen 已提交
2636
设置地磁响应对象,继承于[Response](#response)
Z
zengyawen 已提交
2637

C
cff-gite 已提交
2638 2639
**系统能力**:以下各项对应的系统能力均为SystemCapability.Sensors.Sensor

H
HelloCrease 已提交
2640 2641 2642 2643 2644 2645 2646 2647 2648
| 名称              | 参数类型   | 可读   | 可写   | 说明                        |
| --------------- | ------ | ---- | ---- | ------------------------- |
| x               | number | 是    | 是    | 地磁场的北分量。                  |
| y               | number | 是    | 是    | 地磁场的东分量。                  |
| z               | number | 是    | 是    | 地磁场的垂直分量。                 |
| geomagneticDip  | number | 是    | 是    | 地磁倾角,即地球磁场线与水平面的夹角。       |
| deflectionAngle | number | 是    | 是    | 地磁偏角,即地磁北方向与正北方向在水平面上的角度。 |
| levelIntensity  | number | 是    | 是    | 地磁场的水平强度。                 |
| totalIntensity  | number | 是    | 是    | 地磁场的总强度。                  |
Z
zengyawen 已提交
2649 2650 2651

## LocationOptions

C
cff-gite 已提交
2652 2653 2654 2655
指示地理位置。

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

H
HelloCrease 已提交
2656 2657 2658 2659 2660
| 名称        | 参数类型   | 可读   | 可写   | 说明    |
| --------- | ------ | ---- | ---- | ----- |
| latitude  | number | 是    | 是    | 纬度。   |
| longitude | number | 是    | 是    | 经度。   |
| altitude  | number | 是    | 是    | 海拔高度。 |