Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
3902cc6c
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
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看板
未验证
提交
3902cc6c
编写于
6月 09, 2022
作者:
O
openharmony_ci
提交者:
Gitee
6月 09, 2022
浏览文件
操作
浏览文件
下载
差异文件
!5150 issue修改+示例代码修改+语言标记
Merge pull request !5150 from LiAn/OpenHarmony-3.1-Release
上级
066d124c
0b399738
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
208 addition
and
204 deletion
+208
-204
zh-cn/application-dev/device/vibrator-guidelines.md
zh-cn/application-dev/device/vibrator-guidelines.md
+11
-11
zh-cn/application-dev/reference/apis/js-apis-appAccount.md
zh-cn/application-dev/reference/apis/js-apis-appAccount.md
+1
-1
zh-cn/application-dev/reference/apis/js-apis-config-policy.md
...n/application-dev/reference/apis/js-apis-config-policy.md
+47
-45
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
+18
-17
zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md
...pplication-dev/reference/apis/js-apis-inputeventclient.md
+15
-15
zh-cn/application-dev/reference/apis/js-apis-sensor.md
zh-cn/application-dev/reference/apis/js-apis-sensor.md
+107
-107
zh-cn/application-dev/reference/apis/js-apis-vibrator.md
zh-cn/application-dev/reference/apis/js-apis-vibrator.md
+9
-8
未找到文件。
zh-cn/application-dev/device/vibrator-guidelines.md
浏览文件 @
3902cc6c
...
...
@@ -8,20 +8,20 @@
## 接口说明
| 模块
| 接口名 | 描述
|
| --------
| -------- |
-------- |
| ohos.vibrator | vibrate(duration:
number):
Promise
<
void
>
| 触发马达按照时长振动,
Promise型。
|
| ohos.vibrator | vibrate(duration:
number,
callback?:
AsyncCallback
<
void
>
):
void | 触发马达按照时长振动,
Callback型。
|
| ohos.vibrator | vibrate(effectId:
EffectId):
Promise
<
void
>
| 触发马达按照
指定字符串振动,Promise型。
|
| ohos.vibrator | vibrate(effectId:
EffectId,
callback?:
AsyncCallback
<
void
>
):
void | 触发马达按照
指定字符串振动,Callback型
。 |
| ohos.vibrator | stop(stopMode:
VibratorStopMode):
Promise
<
void
>
| 停止振动。 |
| ohos.vibrator | stop(stopMode:
VibratorStopMode,
callback?:
AsyncCallback
<
void
>
):
void | 停止振动。 |
| 模块
| 接口名 | 描述
|
| --------
----- | ---------------------------------------- | -----------------------
-------- |
| ohos.vibrator | vibrate(duration:
number):
Promise
<
void
>
| 触发马达按照时长振动,
使用Promise异步回调。
|
| ohos.vibrator | vibrate(duration:
number,
callback?:
AsyncCallback
<
void
>
):
void | 触发马达按照时长振动,
使用Callback异步回调。
|
| ohos.vibrator | vibrate(effectId:
EffectId):
Promise
<
void
>
| 触发马达按照
开发者传递效果振动,使用Promise异步回调。
|
| ohos.vibrator | vibrate(effectId:
EffectId,
callback?:
AsyncCallback
<
void
>
):
void | 触发马达按照
开发者传递效果振动,使用Callback异步回调
。 |
| ohos.vibrator | stop(stopMode:
VibratorStopMode):
Promise
<
void
>
| 停止振动。
|
| ohos.vibrator | stop(stopMode:
VibratorStopMode,
callback?:
AsyncCallback
<
void
>
):
void | 停止振动。
|
## 开发步骤
1.
控制设备上的振动器,需要在“config.json”里面进行配置请求权限。具体如下:
```
”reqPermissions“:[
{
...
...
@@ -58,7 +58,7 @@
```
2.
触发设备振动。
```
import vibrator from "@ohos.vibrator"
vibrator.vibrate(1000).then((error)=>{
...
...
@@ -71,7 +71,7 @@
```
3.
停止设备振动。
```
import vibrator from "@ohos.vibrator"
vibrator.stop(vibrator.VibratorStopMode.VIBRATOR_STOP_MODE_PRESET).then((error)=>{
...
...
zh-cn/application-dev/reference/apis/js-apis-appAccount.md
浏览文件 @
3902cc6c
...
...
@@ -26,7 +26,7 @@ createAppAccountManager(): AppAccountManager
**示例:**
```
js
var
appAccountManager
=
account
.
createAppAccountManager
();
var
appAccountManager
=
account
_appAccount
.
createAppAccountManager
();
```
## AppAccountManager
...
...
zh-cn/application-dev/reference/apis/js-apis-config-policy.md
浏览文件 @
3902cc6c
# 配置策略
>  **说明:**
> - 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> - 本模块接口均为系统接口,三方应用不支持调用。
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
> 本模块接口均为系统接口,三方应用不支持调用。
配置策略提供按预先定义的定制配置层级获取对应定制配置目录和文件路径的能力。
## 导入模块
```
```
js
import
configPolicy
from
'
@ohos.configPolicy
'
;
```
...
...
@@ -22,18 +24,18 @@ getOneCfgFile(relPath: string, callback: AsyncCallback<string>): void
**系统能力**
:SystemCapability.Customization.ConfigPolicy
**参数:**
| 参数名 | 类型 | 必填 | 说明
|
| -------- | -------- | -------- |
-------- |
| relPath | string | 是 | 配置文件名
|
| callback | AsyncCallback
<
string
>
| 是
| 异步回调,用于返回最高优先级配置文件的路径 |
| 参数名 | 类型 | 必填 | 说明
|
| -------- | --------------------------- | ---- | -------------
-------- |
| relPath | string | 是 | 配置文件名
|
| callback | AsyncCallback
<
string
>
| 是
| 异步回调,用于返回最高优先级配置文件的路径 |
**示例:**
```
```
js
configPolicy
.
getOneCfgFile
(
'
config.xml
'
,
(
error
,
value
)
=>
{
if
(
error
==
undefined
)
{
console.log(value);
console
.
log
(
"
value is
"
+
value
);
}
else
{
console.log(error);
console
.
log
(
"
error occurs
"
+
error
);
}
});
```
...
...
@@ -48,19 +50,19 @@ getOneCfgFile(relPath: string): Promise<string>
**系统能力**
:SystemCapability.Customization.ConfigPolicy
**参数:**
| 参数名 | 类型 | 必填 | 说明
|
| -------- | -------- | -------- | ---
----- |
| relPath | string | 是
| 配置文件名 |
| 参数名 | 类型 | 必填 | 说明
|
| ------- | ------ | ---- |
----- |
| relPath | string | 是
| 配置文件名 |
**返回值:**
| 类型 | 说明
|
| -------- |
-------- |
| Promise
<
string
>
| 最高优先级配置文件的路径 |
| 类型 | 说明
|
| --------------------- | ----
-------- |
| Promise
<
string
>
| 最高优先级配置文件的路径 |
**示例:**
```
```
js
configPolicy
.
getOneCfgFile
(
'
config.xml
'
).
then
(
value
=>
{
console.log(value);
console
.
log
(
"
value is
"
+
value
);
}).
catch
(
error
=>
{
console
.
log
(
"
getOneCfgFile promise
"
+
error
);
});
...
...
@@ -77,18 +79,18 @@ getCfgFiles(relPath: string, callback: AsyncCallback<Array<string>>)
**系统能力**
:SystemCapability.Customization.ConfigPolicy
**参数:**
| 参数名 | 类型 | 必填 | 说明
|
| -------- | -------- | -------- |
-------- |
| relPath | string | 是 | 配置文件名
|
| callback | AsyncCallback
<
Array
<
string
>>
| 是
| 异步回调,用于返回文件列表 |
| 参数名 | 类型 | 必填 | 说明
|
| -------- | ---------------------------------------- | ---- | -----
-------- |
| relPath | string | 是 | 配置文件名
|
| callback | AsyncCallback
<
Array
<
string
>>
| 是
| 异步回调,用于返回文件列表 |
**示例:**
```
```
js
configPolicy
.
getCfgFiles
(
'
config.xml
'
,
(
error
,
value
)
=>
{
if
(
error
==
undefined
)
{
console.log(value);
console
.
log
(
"
value is
"
+
value
);
}
else
{
console.log(error);
console
.
log
(
"
error occurs
"
+
error
);
}
});
```
...
...
@@ -103,19 +105,19 @@ getCfgFiles(relPath: string): Promise<Array<string>>
**系统能力**
:SystemCapability.Customization.ConfigPolicy
**参数:**
| 参数名 | 类型 | 必填 | 说明
|
| -------- | -------- | -------- | ---
----- |
| relPath | string | 是
| 配置文件名 |
| 参数名 | 类型 | 必填 | 说明
|
| ------- | ------ | ---- |
----- |
| relPath | string | 是
| 配置文件名 |
**返回值:**
| 类型 | 说明
|
| -------- | ----
---- |
| Promise
<
Array
<
string
>>
| 文件列表 |
| 类型 | 说明
|
| ---------------------------------- |
---- |
| Promise
<
Array
<
string
>>
| 文件列表 |
**示例:**
```
```
js
configPolicy
.
getCfgFiles
(
'
config.xml
'
).
then
(
value
=>
{
console.log(value);
console
.
log
(
"
value is
"
+
value
);
}).
catch
(
error
=>
{
console
.
log
(
"
getCfgFiles promise
"
+
error
);
});
...
...
@@ -131,17 +133,17 @@ getCfgDirList(callback: AsyncCallback<Array<string>>): void
**系统能力**
:SystemCapability.Customization.ConfigPolicy
**参数:**
| 参数名 | 类型 | 必填 | 说明
|
| -------- | -------- | -------- |
-------- |
| callback | AsyncCallback
<
Array
<
string
>>
| 是
| 异步回调,用于返回配置层级目录列表 |
| 参数名 | 类型 | 必填 | 说明
|
| -------- | ---------------------------------------- | ---- | ---------
-------- |
| callback | AsyncCallback
<
Array
<
string
>>
| 是
| 异步回调,用于返回配置层级目录列表 |
**示例:**
```
```
js
configPolicy
.
getCfgDirList
((
error
,
value
)
=>
{
if
(
error
==
undefined
)
{
console.log(value);
console
.
log
(
"
value is
"
+
value
);
}
else
{
console.log(error);
console
.
log
(
"
error occurs
"
+
error
);
}
});
```
...
...
@@ -156,14 +158,14 @@ getCfgDirList(): Promise<Array<string>>
**系统能力**
:SystemCapability.Customization.ConfigPolicy
**返回值:**
| 类型 | 说明
|
|
-------- | -------- |
| Promise
<
Array
<
string
>>
| 配置层级目录列表 |
| 类型 | 说明
|
| --------------------------
-------- | -------- |
| Promise
<
Array
<
string
>>
| 配置层级目录列表 |
**示例:**
```
```
js
configPolicy
.
getCfgDirList
().
then
(
value
=>
{
console.log(value);
console
.
log
(
"
value is
"
+
value
);
}).
catch
(
error
=>
{
console
.
log
(
"
getCfgDirList promise
"
+
error
);
});
...
...
zh-cn/application-dev/reference/apis/js-apis-inputdevice.md
浏览文件 @
3902cc6c
...
...
@@ -4,14 +4,15 @@
输入设备管理模块,用于监听输入设备连接、断开和变化,并查看输入设备相关信息。比如监听鼠标插拔,并获取鼠标的id、name和指针移动速度等信息。
>  **说明:**
> **说明:**
>
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
## 导入模块
```
```
js
import
inputDevice
from
'
@ohos.multimodalInput.inputDevice
'
;
```
...
...
@@ -33,7 +34,7 @@ getDeviceIds(callback: AsyncCallback<Array<number>>): void
**示例:**
```
```
js
export
default
{
data
:
{
deviceIds
:
Array
,
...
...
@@ -65,7 +66,7 @@ function getDeviceIds(): Promise<Array<number>>
**示例:**
```
```
js
export
default
{
testGetDeviceIds
:
function
()
{
console
.
info
(
"
InputDeviceJsTest---start---testGetDeviceIds
"
);
...
...
@@ -100,7 +101,7 @@ getDevice(deviceId: number, callback: AsyncCallback<InputDeviceData>): voi
**示例:**
```
```
js
export
default
{
InputDeviceData
:
{
deviceId
:
0
,
...
...
@@ -136,7 +137,7 @@ function getDevice(deviceId: number): Promise<InputDeviceData>
**示例:**
```
```
js
export
default
{
InputDeviceData
:
{
deviceId
:
0
,
...
...
@@ -165,18 +166,18 @@ export default {
**系统能力:**
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputDevice
| 名称
| 参数类型 | 说明
|
| ---------- | -------------------------------------- | ----------------------------------------
--------------------
|
| id | number | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。 |
| name | string | 输入设备的名字。
|
| 名称
| 参数类型 | 说明
|
| ---------- | -------------------------------------- | ---------------------------------------- |
| id | number | 输入设备的唯一标识,同一个物理设备反复插拔,其设备id会发生变化。
|
| name | string | 输入设备的名字。 |
| sources | Array
<
[SourceType](#sourcetype)
>
| 输入设备支持的源类型。比如有的键盘上附带触摸板,则此设备有keyboard和touchpad两种输入源。 |
| axisRanges | Array
<
[axisRanges](#axisrange)
>
| 输入设备的轴信息。
|
| bus | number | 输入设备的总线类型。
|
| product | number | 输入设备的产品信息。
|
| vendor | number | 输入设备的厂商信息。
|
| version | number | 输入设备的版本信息。
|
| phys | string | 输入设备的物理地址。
|
| uniq | string | 输入设备的唯一标识。
|
| axisRanges | Array
<
[axisRanges](#axisrange)
>
| 输入设备的轴信息。 |
| bus | number | 输入设备的总线类型。 |
| product | number | 输入设备的产品信息。 |
| vendor | number | 输入设备的厂商信息。 |
| version | number | 输入设备的版本信息。 |
| phys | string | 输入设备的物理地址。 |
| uniq | string | 输入设备的唯一标识。 |
## AxisType
...
...
zh-cn/application-dev/reference/apis/js-apis-inputeventclient.md
浏览文件 @
3902cc6c
# 注入按键
>

**说明:**
> **说明:**
>
>
-
本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
> 本模块首批接口从API version 8开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
>
>
-
本模块接口均为系统接口,三方应用不支持调用。
> 本模块接口均为系统接口,三方应用不支持调用。
## 导入模块
```
```
js
import
inputEventClient
from
'
@ohos.multimodalInput.inputEventClient
'
;
```
...
...
@@ -26,20 +26,20 @@ injectEvent({KeyEvent: KeyEvent}): void
**参数:**
| 参数
| 类型 | 必填 | 说明
|
| -------- | --------
| -------- |
-------- |
| KeyEvent |
[
KeyEvent
](
#keyevent
)
| 是 | 注入按键的描述信息 |
| 参数
| 类型 | 必填 | 说明
|
| -------- | --------
------------- | ---- | -
-------- |
| KeyEvent |
[
KeyEvent
](
#keyevent
)
| 是
| 注入按键的描述信息 |
**示例:**
```
```
js
let
keyEvent
=
{
isPressed
:
true
,
keyCode
:
2
,
keyDownDuration
:
0
,
isIntercepted
:
false
}
res = inputEventClient.injectEvent({KeyEvent: keyEvent});
let
res
=
inputEventClient
.
injectEvent
({
KeyEvent
:
keyEvent
});
```
...
...
@@ -49,9 +49,9 @@ res = inputEventClient.injectEvent({KeyEvent: keyEvent});
**系统能力:**
以下各项对应的系统能力均为SystemCapability.MultimodalInput.Input.InputSimulator
| 参数
| 类型 | 必填 | 说明
|
| --------
| -------- | -------- |
-------- |
| isPressed
| boolean | 是 | 按键是否按下
|
| keyCode
| Number | 是 | 按键键值
|
| keyDownDuration | boolean | 是
| 按键按下持续时间
|
| isIntercepted
| Number | 是
| 按键是否可以被拦截 |
| 参数
| 类型 | 必填 | 说明
|
| --------
------- | ------- | ---- | -
-------- |
| isPressed
| boolean | 是 | 按键是否按下
|
| keyCode
| Number | 是 | 按键键值
|
| keyDownDuration | boolean | 是
| 按键按下持续时间
|
| isIntercepted
| Number | 是
| 按键是否可以被拦截 |
zh-cn/application-dev/reference/apis/js-apis-sensor.md
浏览文件 @
3902cc6c
# 传感器
>

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