From 69b6689d49cfd2cb62827ea536017e75c63a3821 Mon Sep 17 00:00:00 2001 From: wuzhihuitmac Date: Fri, 26 Aug 2022 08:48:19 +0000 Subject: [PATCH 1/3] add interface of vibrate on api9 Signed-off-by: wuzhihuitmac Change-Id: Ib189507acf00bf72eba4ec5bd6f85e26f2416232 --- api/@ohos.vibrator.d.ts | 47 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) mode change 100755 => 100644 api/@ohos.vibrator.d.ts diff --git a/api/@ohos.vibrator.d.ts b/api/@ohos.vibrator.d.ts old mode 100755 new mode 100644 index e8f1bece16..69ba4d2143 --- a/api/@ohos.vibrator.d.ts +++ b/api/@ohos.vibrator.d.ts @@ -50,6 +50,17 @@ declare namespace vibrator { function vibrate(effectId: EffectId): Promise; function vibrate(effectId: EffectId, callback?: AsyncCallback): void; + /** + * 马达振动接口,根据传入的参数进行振动. + * @param effect 马达振动效果, {@code effect}. + * @param attribute 马达振动属性, {@code effect}. + * @syscap SystemCapability.Sensors.MiscDevice + * @permission ohos.permission.VIBRATE + * @since 9 + */ + function vibrate(effect: VibrateEffect, attribute: VibrateAttribute, callback: AsyncCallback): void; + function vibrate(effect: VibrateEffect, attribute: VibrateAttribute): Promise; + /** * Stop the motor from vibrating. * @param stopMode Indicate the stop mode in which the motor vibrates, {@code VibratorStopMode}. @@ -81,6 +92,42 @@ declare namespace vibrator { /* Indicates the mode of stopping a preset vibration effect.*/ VIBRATOR_STOP_MODE_PRESET = "preset", } + + /** + * 马达使用场景. 选项如下: + * @syscap SystemCapability.Sensors.MiscDevice + * @since 9 + */ + type Usage = "unknown" | "alarm" | "ring" | "notification" | "communication" | + "touch" | "media" | "physicalFeedback" | "simulateReality"; + + /** + * 马达振动效果. 选项如下: + * @syscap SystemCapability.Sensors.MiscDevice + * @since 9 + */ + type VibrateEffect = VibrateTime | VibratePreset; + + /** + * 定义马达振动时长. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 9 + */ + interface VibrateTime { + type: "time"; + duration: number; /** 马达振动时长, 单位ms */ + } + + /** + * 定义马达预置振动类型. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 9 + */ + interface VibratePreset { + type: "preset"; + effectId: string; /** 调整定时器时振动器的振动效果 */ + count: number; /** 马达重复振动次数 */ + } } export default vibrator; \ No newline at end of file -- Gitee From 8c1e2265c04fc02453d7a8f0955be94716f2da8f Mon Sep 17 00:00:00 2001 From: wuzhihuitmac Date: Fri, 26 Aug 2022 10:26:03 +0000 Subject: [PATCH 2/3] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=A3=80=E8=A7=86?= =?UTF-8?q?=E6=84=8F=E8=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wuzhihuitmac Change-Id: I3e6d41cbb85fec371fb31259456c99c78e184ddd --- api/@ohos.vibrator.d.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/api/@ohos.vibrator.d.ts b/api/@ohos.vibrator.d.ts index 69ba4d2143..0d508a8dd3 100644 --- a/api/@ohos.vibrator.d.ts +++ b/api/@ohos.vibrator.d.ts @@ -51,7 +51,7 @@ declare namespace vibrator { function vibrate(effectId: EffectId, callback?: AsyncCallback): void; /** - * 马达振动接口,根据传入的参数进行振动. + * 启动马达振动. * @param effect 马达振动效果, {@code effect}. * @param attribute 马达振动属性, {@code effect}. * @syscap SystemCapability.Sensors.MiscDevice @@ -94,7 +94,7 @@ declare namespace vibrator { } /** - * 马达使用场景. 选项如下: + * 马达振动场景. * @syscap SystemCapability.Sensors.MiscDevice * @since 9 */ @@ -102,14 +102,14 @@ declare namespace vibrator { "touch" | "media" | "physicalFeedback" | "simulateReality"; /** - * 马达振动效果. 选项如下: + * 马达振动效果. * @syscap SystemCapability.Sensors.MiscDevice * @since 9 */ type VibrateEffect = VibrateTime | VibratePreset; /** - * 定义马达振动时长. + * 马达振动时长. * @syscap SystemCapability.Sensors.MiscDevice * @since 9 */ @@ -119,14 +119,14 @@ declare namespace vibrator { } /** - * 定义马达预置振动类型. + * 马达预置振动类型. * @syscap SystemCapability.Sensors.MiscDevice * @since 9 */ interface VibratePreset { type: "preset"; - effectId: string; /** 调整定时器时振动器的振动效果 */ - count: number; /** 马达重复振动次数 */ + effectId: string; /** 预置的振动效果ID */ + count: number; /** 重复振动的次数 */ } } -- Gitee From 1be817367dee6c52914c35709479309ea6d814e9 Mon Sep 17 00:00:00 2001 From: wuzhihuitmac Date: Mon, 29 Aug 2022 06:39:42 +0000 Subject: [PATCH 3/3] =?UTF-8?q?=E6=A3=80=E8=A7=86=E6=84=8F=E8=A7=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: wuzhihuitmac Change-Id: I035f17dea5c276bf8623de412f1c1d69246a8daf --- api/@ohos.vibrator.d.ts | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/api/@ohos.vibrator.d.ts b/api/@ohos.vibrator.d.ts index 0d508a8dd3..13911f22c2 100644 --- a/api/@ohos.vibrator.d.ts +++ b/api/@ohos.vibrator.d.ts @@ -51,9 +51,9 @@ declare namespace vibrator { function vibrate(effectId: EffectId, callback?: AsyncCallback): void; /** - * 启动马达振动. - * @param effect 马达振动效果, {@code effect}. - * @param attribute 马达振动属性, {@code effect}. + * Trigger vibrator vibration. + * @param effect Describes the effect of vibration. + * @param attribute The attribute of vibration. * @syscap SystemCapability.Sensors.MiscDevice * @permission ohos.permission.VIBRATE * @since 9 @@ -94,7 +94,7 @@ declare namespace vibrator { } /** - * 马达振动场景. + * The use of vibration. * @syscap SystemCapability.Sensors.MiscDevice * @since 9 */ @@ -102,31 +102,41 @@ declare namespace vibrator { "touch" | "media" | "physicalFeedback" | "simulateReality"; /** - * 马达振动效果. + * The attribute of vibration. + * @syscap SystemCapability.Sensors.MiscDevice + * @since 9 + */ + interface VibrateAttribute { + id?: number, /** Vibrator id, default is 0. */ + usage: Usage, /** The use of vibration. */ + } + + /** + * Describes the effect of vibration. * @syscap SystemCapability.Sensors.MiscDevice * @since 9 */ type VibrateEffect = VibrateTime | VibratePreset; - /** - * 马达振动时长. + /** + * Specifies the duration of the vibration effect. * @syscap SystemCapability.Sensors.MiscDevice * @since 9 */ interface VibrateTime { type: "time"; - duration: number; /** 马达振动时长, 单位ms */ + duration: number; /** The duration of the vibration, in ms */ } /** - * 马达预置振动类型. + * Preset vibration type vibration effect. * @syscap SystemCapability.Sensors.MiscDevice * @since 9 */ interface VibratePreset { type: "preset"; - effectId: string; /** 预置的振动效果ID */ - count: number; /** 重复振动的次数 */ + effectId: string; /** Preset type vibration */ + count: number; /** The number of vibration repetitions */ } } -- Gitee