Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
8834b47f
D
Docs
项目概览
OpenHarmony
/
Docs
1 年多 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
8834b47f
编写于
1月 28, 2022
作者:
C
cff-gite
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
修改了sensor和vibrate的用例格式、参数、命名错误。
Signed-off-by:
N
cff-gite
<
chenfeifei8@huawei.com
>
上级
9b03f4a8
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
216 addition
and
222 deletion
+216
-222
zh-cn/application-dev/reference/apis/js-apis-sensor.md
zh-cn/application-dev/reference/apis/js-apis-sensor.md
+177
-177
zh-cn/application-dev/reference/apis/js-apis-vibrator.md
zh-cn/application-dev/reference/apis/js-apis-vibrator.md
+39
-45
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-sensor.md
浏览文件 @
8834b47f
...
...
@@ -22,9 +22,9 @@ import sensor from '@ohos.sensor';
陀螺仪:ohos.permission.GYROSCOPE
## sensor.on(SensorType.SENSOR_TYPE_ID_ACCELEROMETER)
## sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_ACCELEROMETER)
on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: AsyncCallback
<
AccelerometerResponse
>
,options?: Options): void
on(type:
sensor.
SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: AsyncCallback
<
AccelerometerResponse
>
,options?: Options): void
监听加速度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
...
...
@@ -39,7 +39,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: AsyncCallback<Acc
-
示例:
```
sensor.on(
type:
SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(error,data){
sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(error,data){
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -53,9 +53,9 @@ on(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: AsyncCallback<Acc
```
## sensor.on(SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION)
## sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION)
on(type:SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:AsyncCallback
<
LinearAccelerometerResponse
>
, options?: Options): void
on(type:
sensor.
SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:AsyncCallback
<
LinearAccelerometerResponse
>
, options?: Options): void
监听线性加速度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
...
...
@@ -68,7 +68,7 @@ on(type:SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:AsyncCallback<
-
示例:
```
sensor.on(
type:SensorType.SENSOR_TYPE_ID_LINEAR_ACCELEROMETER,function(error,data){
sensor.on(
sensor.SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,function(error,data){
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -76,15 +76,15 @@ on(type:SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:AsyncCallback<
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
}
},
{interval: 10000000}
);
```
## sensor.on(SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED)
## sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED)
on(type:SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback:AsyncCallback
<
AccelerometerUncalibratedResponse
>
, options?: Options): void
on(type:
sensor.
SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback:AsyncCallback
<
AccelerometerUncalibratedResponse
>
, options?: Options): void
监听未校准加速度计传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
...
...
@@ -97,7 +97,7 @@ on(type:SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback:AsyncCallb
-
示例:
```
sensor.on(
type:
SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(error,data){
sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,function(error,data){
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -108,15 +108,15 @@ on(type:SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback:AsyncCallb
console.info('X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ);
}
},
{interval: 10000000}
);
```
## sensor.on(SensorType.SENSOR_TYPE_ID_GRAVITY)
## sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_GRAVITY)
on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: AsyncCallback
<
GravityResponse
>
,options?: Options): void
on(type:
sensor.
SensorType.SENSOR_TYPE_ID_GRAVITY, callback: AsyncCallback
<
GravityResponse
>
,options?: Options): void
监听重力传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
...
...
@@ -129,7 +129,7 @@ on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: AsyncCallback<GravityRe
-
示例:
```
sensor.on(
type:
SensorType.SENSOR_TYPE_ID_GRAVITY,function(error,data){
sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_GRAVITY,function(error,data){
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -137,15 +137,15 @@ on(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: AsyncCallback<GravityRe
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
}
},
{interval: 10000000}
);
```
## sensor.on(SensorType.SENSOR_TYPE_ID_GYROSCOPE)
## sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_GYROSCOPE)
on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: AsyncCallback
<
GyroscopeResponse
>
, options?: Options): void
on(type:
sensor.
SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: AsyncCallback
<
GyroscopeResponse
>
, options?: Options): void
监听陀螺仪传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
...
...
@@ -158,7 +158,7 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: AsyncCallback<Gyrosco
-
示例:
```
sensor.on(
type:SensorType.SENSOR_TYPE_ID_GUROSCOPE,function(error,data){
sensor.on(
sensor.SensorType.SENSOR_TYPE_ID_GYROSCOPE,function(error,data){
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -166,15 +166,15 @@ on(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: AsyncCallback<Gyrosco
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
}
},
{interval: 10000000}
);
```
## sensor.on(SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED)
## sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED)
on(type:SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:AsyncCallback
<
GyroscopeUncalibratedResponse
>
, options?: Options): void
on(type:
sensor.
SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:AsyncCallback
<
GyroscopeUncalibratedResponse
>
, options?: Options): void
监听未校准陀螺仪传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
...
...
@@ -187,7 +187,7 @@ on(type:SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:AsyncCallback&
-
示例:
```
sensor.on(
type:
SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(error,data){
sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,function(error,data){
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -198,15 +198,15 @@ on(type:SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:AsyncCallback&
console.info('X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ);
}
},
{interval: 10000000}
);
```
## sensor.on(SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION)
## sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION)
on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: AsyncCallback
<
SignificantMotionResponse
>
, options?: Options): void
on(type:
sensor.
SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: AsyncCallback
<
SignificantMotionResponse
>
, options?: Options): void
监听大幅动作传感器数据变化。如果多次调用该接口,仅最后一次调用生效。
...
...
@@ -219,21 +219,21 @@ on(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, callback: AsyncCallback&l
-
示例:
```
sensor.on(
type:
SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(error,data){
sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,function(error,data){
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
}
console.info('Scalar data: ' + data.scalar);
}
},
{interval: 10000000}
);
```
## sensor.on(SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION)
## sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION)
on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: AsyncCallback
<
PedometerDetectResponse
>
, options?: Options): void
on(type:
sensor.
SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: AsyncCallback
<
PedometerDetectResponse
>
, options?: Options): void
监听计步检测传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
...
...
@@ -246,21 +246,21 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, callback: AsyncCallback&
-
示例:
```
sensor.on(
type:
SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(error,data){
sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,function(error,data){
if (error) {
console.error("
"
Subscription failed. Error code: " + error.code + "; message: " + error.message);
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
}
console.info('Scalar data: ' + data.scalar);
}
},
{interval: 10000000}
);
```
## sensor.on(SensorType.SENSOR_TYPE_ID_PEDOMETER)
## sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_PEDOMETER)
on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: AsyncCallback
<
PedometerResponse
>
, options?: Options): void
on(type:
sensor.
SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: AsyncCallback
<
PedometerResponse
>
, options?: Options): void
监听计步传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
...
...
@@ -273,21 +273,21 @@ on(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: AsyncCallback<Pedomet
-
示例:
```
sensor.on(
type:
SensorType.SENSOR_TYPE_ID_PEDOMETER,function(error,data){
sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_PEDOMETER,function(error,data){
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
}
console.info('Steps: ' + data.steps);
}
},
{interval: 10000000}
);
```
## sensor.on(SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE)
## sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE)
on(type:SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:AsyncCallback
<
AmbientTemperatureResponse
>
, options?: Options): void
on(type:
sensor.
SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:AsyncCallback
<
AmbientTemperatureResponse
>
, options?: Options): void
监听环境温度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
...
...
@@ -300,21 +300,21 @@ on(type:SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:AsyncCallback<
-
示例:
```
sensor.on(
type:
SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,function(error,data){
sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,function(error,data){
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
}
console.info('Temperature: ' + data.temperature);
}
},
{interval: 10000000}
);
```
## sensor.on(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD)
## sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD)
on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: AsyncCallback
<
MagneticFieldResponse
>
,options?: Options): void
on(type:
sensor.
SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: AsyncCallback
<
MagneticFieldResponse
>
,options?: Options): void
监听磁场传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
...
...
@@ -327,7 +327,7 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: AsyncCallback<Ma
-
示例:
```
sensor.on(
type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,function(error,data){
sensor.on(
sensor.SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD,function(error,data){
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -335,15 +335,15 @@ on(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: AsyncCallback<Ma
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
}
},
{interval: 10000000}
);
```
## sensor.on(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED)
## sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED)
on(type:SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback:AsyncCallback
<
MagneticFieldUncalibratedResponse
>
, options: Options): void
on(type:
sensor.
SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback:AsyncCallback
<
MagneticFieldUncalibratedResponse
>
, options: Options): void
监听未校准磁场传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
...
...
@@ -356,7 +356,7 @@ on(type:SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback:AsyncCall
-
示例:
```
ensor.on(type:
SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(error,data){
sensor.on(sensor.
SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,function(error,data){
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -367,15 +367,15 @@ on(type:SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback:AsyncCall
console.info('X-coordinate bias: ' + data.biasX);
console.info('Y-coordinate bias: ' + data.biasY);
console.info('Z-coordinate bias: ' + data.biasZ);
}
{interval: 10000000} //设置数据的上报频率。
},
{interval: 10000000}
);
```
## sensor.on(SensorType.SENSOR_TYPE_ID_PROXIMITY)
## sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_PROXIMITY)
on(type:
SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: AsyncCallback
<
ProximityResponse
>
,options?: Options): void
on(type:
sensor.
SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: AsyncCallback
<
ProximityResponse
>
,options?: Options): void
监听接近光传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
...
...
@@ -388,21 +388,21 @@ on(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: AsyncCallback<Proximi
-
示例:
```
sensor.on(
type:
SensorType.SENSOR_TYPE_ID_PROXIMITY,function(error,data){
sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_PROXIMITY,function(error,data){
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
}
console.info('Distance: ' + data.distance);
}
},
{interval: 10000000}
);
```
## sensor.on(SensorType.SENSOR_TYPE_ID_HUMIDITY)
## sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_HUMIDITY)
on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: AsyncCallback
<
HumidityResponse
>
,options?: Options): void
on(type:
sensor.
SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: AsyncCallback
<
HumidityResponse
>
,options?: Options): void
监听湿度传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
...
...
@@ -415,21 +415,21 @@ on(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: AsyncCallback<Humidity
-
示例:
```
sensor.on(
type:
SensorType.SENSOR_TYPE_ID_HUMIDITY,function(error,data){
sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_HUMIDITY,function(error,data){
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
}
console.info('Humidity: ' + data.humidity);
}
},
{interval: 10000000}
);
```
## sensor.on(SensorType.SENSOR_TYPE_ID_BAROMETER)
## sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_BAROMETER)
on(type:
SensorType.SENSOR_TYPE_ID_BAROMETER, callback: AsyncCallback
<
BarometerResponse
>
,options?: Options): void
on(type:
sensor.
SensorType.SENSOR_TYPE_ID_BAROMETER, callback: AsyncCallback
<
BarometerResponse
>
,options?: Options): void
监听气压计传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
...
...
@@ -442,21 +442,21 @@ on(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: AsyncCallback<Baromet
-
示例:
```
sensor.on(
type:
SensorType.SENSOR_TYPE_ID_BAROMETER,function(error,data){
sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_BAROMETER,function(error,data){
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
}
console.info('Atmospheric pressure: ' + data.pressure);
}
},
{interval: 10000000}
);
```
## sensor.on(SensorType.SENSOR_TYPE_ID_HALL)
## sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_HALL)
on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: AsyncCallback
<
HallResponse
>
, options?: Options): void
on(type:
sensor.
SensorType.SENSOR_TYPE_ID_HALL, callback: AsyncCallback
<
HallResponse
>
, options?: Options): void
监听霍尔传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
...
...
@@ -469,21 +469,21 @@ on(type: SensorType.SENSOR_TYPE_ID_HALL, callback: AsyncCallback<HallResponse
-
示例:
```
sensor.on(
type:
SensorType.SENSOR_TYPE_ID_HALL,function(error,data){
sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_HALL,function(error,data){
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
}
console.info('Status: ' + data.status);
}
},
{interval: 10000000}
);
```
## sensor.on(SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT)
## sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT)
on(type:
SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: AsyncCallback
<
LightResponse
>
, options?: Options): void
on(type:
sensor.
SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: AsyncCallback
<
LightResponse
>
, options?: Options): void
监听环境光传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
...
...
@@ -496,21 +496,21 @@ on(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: AsyncCallback<Lig
-
示例:
```
sensor.on(
type:
SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,function(error,data){
sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT,function(error,data){
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
}
console.info('
'
Illumination: ' + data.intensity);
}
console.info('
Illumination: ' + data.intensity);
},
{interval: 10000000}
);
```
## sensor.on(SensorType.SENSOR_TYPE_ID_ORIENTATION)
## sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_ORIENTATION)
on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: AsyncCallback
<
OrientationResponse
>
, options?: Options): void
on(type:
sensor.
SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: AsyncCallback
<
OrientationResponse
>
, options?: Options): void
监听方向传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
...
...
@@ -523,7 +523,7 @@ on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: AsyncCallback<Orien
-
示例:
```
sensor.on(
type: SensorType.SENSOR_TYPE_ID_ORIENTATION,function(error,data){
sensor.on(
sensor.SensorType.SENSOR_TYPE_ID_ORIENTATION,function(error,data){
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -531,15 +531,15 @@ on(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: AsyncCallback<Orien
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
}
},
{interval: 10000000}
);
```
## sensor.on(SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR)
## sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR)
on(type:SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback:AsyncCallback
<
RotationVectorResponse
>
,options?: Options): void
on(type:
sensor.
SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback:AsyncCallback
<
RotationVectorResponse
>
,options?: Options): void
监听旋转矢量传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
...
...
@@ -552,7 +552,7 @@ on(type:SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback:AsyncCallback<Rota
-
示例:
```
sensor.on(
type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(error,data){
sensor.on(
sensor.SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,function(error,data){
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -560,15 +560,15 @@ on(type:SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR,callback:AsyncCallback<Rota
console.info('X-coordinate component: ' + data.x);
console.info('Y-coordinate component: ' + data.y);
console.info('Z-coordinate component: ' + data.z);
}
},
{interval: 10000000}
);
```
## sensor.on(SensorType.SENSOR_TYPE_ID_WEAR_DETECTION)
## sensor.on(
sensor.
SensorType.SENSOR_TYPE_ID_WEAR_DETECTION)
on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: AsyncCallback
<
WearDetectionResponse
>
,options?: Options): void
on(type:
sensor.
SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: AsyncCallback
<
WearDetectionResponse
>
,options?: Options): void
监听佩戴检测传感器的数据变化。如果多次调用该接口,仅最后一次调用生效。
...
...
@@ -581,21 +581,21 @@ on(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: AsyncCallback<We
-
示例:
```
sensor.on(
type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(error,data){
sensor.on(
sensor.SensorType.SENSOR_TYPE_ID_WEAR_DETECTION,function(error,data){
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
}
console.info('Wear status: ' + data.value);
}
},
{interval: 10000000}
);
```
## sensor.once(SensorType.SENSOR_TYPE_ID_ACCELEROMETER)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_ACCELEROMETER)
once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: AsyncCallback
<
AccelerometerResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: AsyncCallback
<
AccelerometerResponse
>
): void
监听加速度传感器的数据变化一次。
...
...
@@ -607,7 +607,7 @@ once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: AsyncCallback<A
-
示例:
```
sensor.once(
type:SensorType.SENSOR_TYPE_ID_ACCELEROMETER, function(error, data)
{
sensor.once(
sensor.SensorType.SENSOR_TYPE_ID_ACCELEROMETER,function(error,data)
{
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -620,9 +620,9 @@ once(type: SensorType.SENSOR_TYPE_ID_ACCELEROMETER, callback: AsyncCallback<A
```
## sensor.once(SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION)
once(type:SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:AsyncCallback
<
LinearAccelerometerResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:AsyncCallback
<
LinearAccelerometerResponse
>
): void
监听线性加速度传感器数据变化一次。
...
...
@@ -634,7 +634,7 @@ once(type:SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:AsyncCallback&l
-
示例:
```
sensor.once(
type:
SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, function(error, data) {
sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -647,9 +647,9 @@ once(type:SensorType.SENSOR_TYPE_ID_LINEAR_ACCELERATION,callback:AsyncCallback&l
```
## sensor.once(SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED)
once(type:SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback:AsyncCallback
<
AccelerometerUncalibratedResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback:AsyncCallback
<
AccelerometerUncalibratedResponse
>
): void
监听未校准加速度传感器的数据变化一次。
...
...
@@ -661,7 +661,7 @@ once(type:SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback:AsyncCal
-
示例:
```
sensor.once(
type:
SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, function(error, data) {
sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -677,9 +677,9 @@ once(type:SensorType.SENSOR_TYPE_ID_ACCELEROMETER_UNCALIBRATED,callback:AsyncCal
```
## sensor.once(SensorType.SENSOR_TYPE_ID_GRAVITY)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_GRAVITY)
once(type:
SensorType.SENSOR_TYPE_ID_GRAVITY, callback: AsyncCallback
<
GravityResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_GRAVITY, callback: AsyncCallback
<
GravityResponse
>
): void
监听重力传感器的数据变化一次。
...
...
@@ -691,7 +691,7 @@ once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: AsyncCallback<Gravity
-
示例:
```
sensor.once(
type:
SensorType.SENSOR_TYPE_ID_GRAVITY, function(error, data) {
sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_GRAVITY, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -704,9 +704,9 @@ once(type: SensorType.SENSOR_TYPE_ID_GRAVITY, callback: AsyncCallback<Gravity
```
## sensor.once(SensorType.SENSOR_TYPE_ID_GYROSCOPE)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_GYROSCOPE)
once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: AsyncCallback
<
GyroscopeResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: AsyncCallback
<
GyroscopeResponse
>
): void
监听陀螺仪传感器的数据变化一次。
...
...
@@ -718,7 +718,7 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: AsyncCallback<Gyros
-
示例:
```
sensor.once(
type:
SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(error, data) {
sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_GYROSCOPE, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -731,9 +731,9 @@ once(type: SensorType.SENSOR_TYPE_ID_GYROSCOPE, callback: AsyncCallback<Gyros
```
## sensor.once(SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED)
once(type:SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:AsyncCallback
<
GyroscopeUncalibratedResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:AsyncCallback
<
GyroscopeUncalibratedResponse
>
): void
监听未校准陀螺仪传感器的数据变化一次。
...
...
@@ -745,7 +745,7 @@ once(type:SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:AsyncCallbac
-
示例:
```
sensor.once(
type:
SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(error, data) {
sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -761,9 +761,9 @@ once(type:SensorType.SENSOR_TYPE_ID_GYROSCOPE_UNCALIBRATED,callback:AsyncCallbac
```
## sensor.once(SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION)
once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback:AsyncCallback
<
SignificantMotionResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback:AsyncCallback
<
SignificantMotionResponse
>
): void
监听有效运动传感器的数据变化一次。
...
...
@@ -775,7 +775,7 @@ once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback:AsyncCallback&l
-
示例:
```
sensor.once(
type:
SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(error, data) {
sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -786,9 +786,9 @@ once(type: SensorType.SENSOR_TYPE_ID_SIGNIFICANT_MOTION,callback:AsyncCallback&l
```
## sensor.once(SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION)
once(type:SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback:AsyncCallback
<
PedometerDetectResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback:AsyncCallback
<
PedometerDetectResponse
>
): void
监听计步检测传感器数据变化一次。
...
...
@@ -800,7 +800,7 @@ once(type:SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback:AsyncCallback&l
-
示例:
```
sensor.once(
type:
SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(error, data) {
sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -811,9 +811,9 @@ once(type:SensorType.SENSOR_TYPE_ID_PEDOMETER_DETECTION,callback:AsyncCallback&l
```
## sensor.once(SensorType.SENSOR_TYPE_ID_PEDOMETER)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_PEDOMETER)
once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: AsyncCallback
<
PedometerResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: AsyncCallback
<
PedometerResponse
>
): void
监听计步器传感器数据变化一次。
...
...
@@ -825,7 +825,7 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: AsyncCallback<Pedom
-
示例:
```
sensor.once(
type:
SensorType.SENSOR_TYPE_ID_PEDOMETER, function(error, data) {
sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_PEDOMETER, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -836,9 +836,9 @@ once(type: SensorType.SENSOR_TYPE_ID_PEDOMETER, callback: AsyncCallback<Pedom
```
## sensor.once(SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE)
once(type:SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:AsyncCallback
<
AmbientTemperatureResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:AsyncCallback
<
AmbientTemperatureResponse
>
): void
监听环境温度传感器数据变化一次。
...
...
@@ -850,7 +850,7 @@ once(type:SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:AsyncCallback&l
-
示例:
```
sensor.once(
type:
SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(error, data) {
sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -861,9 +861,9 @@ once(type:SensorType.SENSOR_TYPE_ID_AMBIENT_TEMPERATURE,callback:AsyncCallback&l
```
## sensor.once(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD)
once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: AsyncCallback
<
MagneticFieldResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: AsyncCallback
<
MagneticFieldResponse
>
): void
监听磁场传感器数据变化一次。
...
...
@@ -875,7 +875,7 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: AsyncCallback<
-
示例:
```
sensor.once(
type:
SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(error, data) {
sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -888,9 +888,9 @@ once(type: SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD, callback: AsyncCallback<
```
## sensor.once(SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED)
once(type:SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback:AsyncCallback
<
MagneticFieldUncalibratedResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback:AsyncCallback
<
MagneticFieldUncalibratedResponse
>
): void
监听未校准磁场传感器数据变化一次。
...
...
@@ -902,7 +902,7 @@ once(type:SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback:AsyncCa
-
示例:
```
sensor.once(
type:
SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(error, data) {
sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -918,9 +918,9 @@ once(type:SensorType.SENSOR_TYPE_ID_MAGNETIC_FIELD_UNCALIBRATED,callback:AsyncCa
```
## sensor.once(SensorType.SENSOR_TYPE_ID_PROXIMITY)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_PROXIMITY)
once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: AsyncCallback
<
ProximityResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: AsyncCallback
<
ProximityResponse
>
): void
监听接近光传感器数据变化一次。
...
...
@@ -932,7 +932,7 @@ once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: AsyncCallback<Proxi
-
示例:
```
sensor.once(
type:
SensorType.SENSOR_TYPE_ID_PROXIMITY, function(error, data) {
sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_PROXIMITY, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -943,9 +943,9 @@ once(type: SensorType.SENSOR_TYPE_ID_PROXIMITY, callback: AsyncCallback<Proxi
```
## sensor.once(SensorType.SENSOR_TYPE_ID_HUMIDITY)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_HUMIDITY)
once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: AsyncCallback
<
HumidityResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: AsyncCallback
<
HumidityResponse
>
): void
监听湿度传感器数据变化一次。
...
...
@@ -957,7 +957,7 @@ once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: AsyncCallback<Humidi
-
示例:
```
sensor.once(
type:
SensorType.SENSOR_TYPE_ID_HUMIDITY, function(error, data) {
sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_HUMIDITY, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -968,9 +968,9 @@ once(type: SensorType.SENSOR_TYPE_ID_HUMIDITY, callback: AsyncCallback<Humidi
```
## sensor.once(SensorType.SENSOR_TYPE_ID_BAROMETER)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_BAROMETER)
once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: AsyncCallback
<
BarometerResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_BAROMETER, callback: AsyncCallback
<
BarometerResponse
>
): void
监听气压计传感器数据变化一次。
...
...
@@ -982,7 +982,7 @@ once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: AsyncCallback<Barom
-
示例:
```
sensor.once(
type:
SensorType.SENSOR_TYPE_ID_BAROMETER, function(error, data) {
sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_BAROMETER, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -993,9 +993,9 @@ once(type: SensorType.SENSOR_TYPE_ID_BAROMETER, callback: AsyncCallback<Barom
```
## sensor.once(SensorType.SENSOR_TYPE_ID_HALL)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_HALL)
once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: AsyncCallback
<
HallResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_HALL, callback: AsyncCallback
<
HallResponse
>
): void
监听霍尔传感器数据变化一次。
...
...
@@ -1007,7 +1007,7 @@ once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: AsyncCallback<HallResp
-
示例:
```
sensor.once(
type:
SensorType.SENSOR_TYPE_ID_HALL, function(error, data) {
sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_HALL, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -1018,9 +1018,9 @@ once(type: SensorType.SENSOR_TYPE_ID_HALL, callback: AsyncCallback<HallResp
```
## sensor.once(SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT)
once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: AsyncCallback
<
LightResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: AsyncCallback
<
LightResponse
>
): void
监听环境光传感器数据变化一次。
...
...
@@ -1032,20 +1032,20 @@ once(type: SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, callback: AsyncCallback<L
-
示例:
```
sensor.once(
type:
SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function(error, data) {
sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_AMBIENT_LIGHT, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
}
console.info('
'
Illumination: ' + data.intensity);
console.info('
Illumination: ' + data.intensity);
}
);
```
## sensor.once(SensorType.SENSOR_TYPE_ID_ORIENTATION)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_ORIENTATION)
once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: AsyncCallback
<
OrientationResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: AsyncCallback
<
OrientationResponse
>
): void
监听方向传感器数据变化一次。
...
...
@@ -1057,7 +1057,7 @@ once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: AsyncCallback<Ori
-
示例:
```
sensor.once(
type:
SensorType.SENSOR_TYPE_ID_ORIENTATION, function(error, data) {
sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_ORIENTATION, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -1070,9 +1070,9 @@ once(type: SensorType.SENSOR_TYPE_ID_ORIENTATION, callback: AsyncCallback<Ori
```
## sensor.once(SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR)
once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: AsyncCallback
<
RotationVectorResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: AsyncCallback
<
RotationVectorResponse
>
): void
监听旋转矢量传感器数据变化一次。
...
...
@@ -1084,7 +1084,7 @@ once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: AsyncCallback<
-
示例:
```
sensor.once(
type:
SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(error, data) {
sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -1097,9 +1097,9 @@ once(type: SensorType.SENSOR_TYPE_ID_ROTATION_VECTOR, callback: AsyncCallback<
```
## sensor.once(SensorType.SENSOR_TYPE_ID_HEART_RATE)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_HEART_RATE)
once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: AsyncCallback
<
HeartRateResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: AsyncCallback
<
HeartRateResponse
>
): void
监听心率传感器数据变化一次。
...
...
@@ -1111,7 +1111,7 @@ once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: AsyncCallback<Hear
-
示例:
```
sensor.once(
type:
SensorType.SENSOR_TYPE_ID_HEART_RATE, function(error, data) {
sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_HEART_RATE, function(error, data) {
if (error) {
console.error("Subscription failed. Error code: " + error.code + "; message: " + error.message);
return;
...
...
@@ -1122,9 +1122,9 @@ once(type: SensorType.SENSOR_TYPE_ID_HEART_RATE, callback: AsyncCallback<Hear
```
## sensor.once(SensorType.SENSOR_TYPE_ID_WEAR_DETECTION)
## sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_WEAR_DETECTION)
once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: AsyncCallback
<
WearDetectionResponse
>
): void
once(type:
sensor.
SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: AsyncCallback
<
WearDetectionResponse
>
): void
监听佩戴检测传感器数据变化一次。
...
...
@@ -1136,7 +1136,7 @@ once(type: SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, callback: AsyncCallback<
-
示例:
```
sensor.once(
type:
SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function(error, data) {
sensor.once(
sensor.
SensorType.SENSOR_TYPE_ID_WEAR_DETECTION, function(error, data) {
if (error) {
console.error("Failed to register data, error code is" + error.code + ", message: " + error.message);
return;
...
...
@@ -1161,7 +1161,7 @@ off(type: SensorType, callback?: AsyncCallback<void>): void
-
示例:
```
sensor.off(
type:
SensorType.SENSOR_TYPE_ID_ACCELEROMETER, function(error) {
sensor.off(
sensor.
SensorType.SENSOR_TYPE_ID_ACCELEROMETER, function(error) {
if (error) {
console.error("Failed to unsubscribe from acceleration sensor data. Error code: " + error.code + "; message: " + error.message);
return;
...
...
zh-cn/application-dev/reference/apis/js-apis-vibrator.md
浏览文件 @
8834b47f
...
...
@@ -7,7 +7,7 @@
## 导入模块
```
import vibrat
e
from '@ohos.vibrator';
import vibrat
or
from '@ohos.vibrator';
```
...
...
@@ -16,7 +16,7 @@ import vibrate from '@ohos.vibrator';
ohos.permission.VIBRATE
## vibrat
e
.vibrate
## vibrat
or
.vibrate
vibrate(duration: number): Promise
<
void
>
...
...
@@ -37,17 +37,15 @@ vibrate(duration: number): Promise<void>
-
示例:
```
vibrator.vibrate(1000).then(error)=>{
if(error){
console.log(“error.code”+error.code+“error.message”+error.message);
}else{
console.log(“Promise returned to indicate a successful vibration.”);
}
}
vibrator.vibrate(1000).then(()=>{
console.log("Promise returned to indicate a successful vibration.");
}, (error)=>{
console.log("error.code"+error.code+"error.message"+error.message);
});
```
## vibrat
e
.vibrate
## vibrat
or
.vibrate
vibrate(duration: number, callback?: AsyncCallback
<
void
>
): void
...
...
@@ -63,15 +61,15 @@ vibrate(duration: number, callback?: AsyncCallback<void>): void
```
vibrator.vibrate(1000,function(error){
if(error){
console.log(“error.code”+error.code+“error.message”
+error.message);
console.log("error.code"+error.code+"error.message"
+error.message);
}else{
console.log(“Callback returned to indicate a successful vibration.”
);
console.log("Callback returned to indicate a successful vibration."
);
}
})
```
## vibrat
e
.vibrate
## vibrat
or
.vibrate
vibrate(effectId: EffectId): Promise
<
void
>
...
...
@@ -89,17 +87,15 @@ vibrate(effectId: EffectId): Promise<void>
-
示例:
```
vibrator.vibrate(effectId:EffectId).then(error)=>{
if(error){
console.log(“error.code”+error.code+“error.message”+error.message);
}else{
Console.log(“Promise returned to indicate a successful vibration.”);
}
}
vibrator.vibrate(vibrator.EffectId.EFFECT_CLOCK_TIMER).then(()=>{
console.log("Promise returned to indicate a successful vibration.");
}, (error)=>{
console.log("error.code"+error.code+"error.message"+error.message);
});
```
## vibrat
e
.vibrate
## vibrat
or
.vibrate
vibrate(effectId: EffectId, callback?: AsyncCallback
<
void
>
): void
...
...
@@ -113,17 +109,17 @@ vibrate(effectId: EffectId, callback?: AsyncCallback<void>): void
-
示例:
```
vibrator.vibrate(
effectId:EffectId,
function(error){
vibrator.vibrate(
vibrator.EffectId.EFFECT_CLOCK_TIMER,
function(error){
if(error){
console.log(“error.code”+error.code+“error.message”
+error.message);
console.log("error.code"+error.code+"error.message"
+error.message);
}else{
console.log(“Callback returned to indicate a successful vibration.”
);
console.log("Callback returned to indicate a successful vibration."
);
}
})
```
## vibrat
e
.stop
## vibrat
or
.stop
stop(stopMode: VibratorStopMode): Promise
<
void
>
...
...
@@ -141,17 +137,15 @@ stop(stopMode: VibratorStopMode): Promise<void>
-
示例:
```
vibrator.stop(stopMode:VibratorStopMode).then((error)=>{
if(error){
console.log(“error.code”+error.code+“error.message”+error.message);
}else{
Console.log(“Promise returned to indicate successful.”);
}
})
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then(()=>{
console.log("Promise returned to indicate a successful vibration.");
}, (error)=>{
console.log("error.code"+error.code+"error.message"+error.message);
});
```
## vibrat
e
.stop
## vibrat
or
.stop
stop(stopMode: VibratorStopMode, callback?: AsyncCallback
<
void
>
): void;
...
...
@@ -165,11 +159,11 @@ stop(stopMode: VibratorStopMode, callback?: AsyncCallback<void>): void;
-
示例:
```
vibrator.stop(
stopMode:VibratorStopMode,
function(error){
vibrator.stop(
vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET,
function(error){
if(error){
console.log(“error.code”+error.code+“error.message”
+error.message);
console.log("error.code"+error.code+"error.message"
+error.message);
}else{
Console.log(“Callback returned to indicate successful.”
);
console.log("Callback returned to indicate successful."
);
}
})
```
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录