Skip to main content
Version: v1.0

VIBRATE

Creating Sensors​

const vibrate = hmSensor.createSensor(hmSensor.id.VIBRATE)

VIBRATE instance​

caution

Pages can only create one instance of the VIBRATE sensor and cannot be created more than once

vibrate: object​

PropertiesDescriptionType
scenevibration scene settingnumber

scene: number​

ValueDescription
23Light vibration intensity and short time (20ms)
24Medium vibration intensity, short time (20ms)
25High vibration intensity and short time (20ms)
27High vibration intensity, lasting 1000ms
28High vibration intensity, lasting 600ms
0Two short, continuous vibrations, consistent with the watch message notification vibration feedback
1High vibration intensity, single vibration twice in 500ms, continuous vibration, need to manually stop before it will stop, consistent with the watch call vibration feedback
5High vibration intensity, single long vibration 500ms, continuous vibration, need to manually stop before stopping, consistent with the watch alarm clock, countdown vibration feedback
9High vibration intensity, four vibrations in 1200ms, can be used for stronger reminders

vibrate.start​

vibrate instance starts the scene vibration, after calling start you must call stop after the vibration is finished, otherwise the next call to start will not vibrate

vibrate.start()

vibrate.stop​

Example of stopping a scene from vibrating

vibrate.stop()

Code example​

const vibrate = hmSensor.createSensor(hmSensor.id.VIBRATE)

function click() {
vibrate.stop()
vibrate.scene = 25
vibrate.start()
}

click()

Page({
onDestroy() {
vibrate && vibrate.stop()
}
})