Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Haptic API for 'bump' alerts

ANSWERED

If you want the fire a short 'bump' alert, to encourage a user to look at their device, but you don't need them to acknowledge or cancel it, what is the best way to do so? 

 

Looking at the API, it's the responsibility of the app to both start and stop the vibration motor.  So if you want to create a short 1 second 'bump' alert, would you suggest doing this synchronously in the watchface rendering code (with a 'wait' function) or asynchronously using the Clock tickEvent (or another event)?

 

If the latter, how do you deal with situation where the clock granularity is set to minutes or hours?

 

Are there any examples apps/code?

 

Thank you.  

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

You don't need to stop the vibrations. They just play once.

import { vibration } from "haptics";
vibration.start("bump");

View best answer in original post

Best Answer
6 REPLIES 6

You don't need to stop the vibrations. They just play once.

import { vibration } from "haptics";
vibration.start("bump");
Best Answer

I worked this out eventually 🙂

 

I understand now that certain alerts were designed to play continuously and others just once.  However the API doc doesn't make this clear.  I think the documentation could do with a bit of clarification as to which alerts will play continuously until stopped and which are 'one time'.

 

Interface: Vibration

Functions of the device's vibration motor.

Methods start()

start(pattern: VibrationPatternName)

Returns: boolean

Start a vibration pattern by name.

Available patterns:

  • "alert"
  • "bump"
  • "confirmation"
  • "confirmation-max"
  • "nudge"
  • "nudge-max"
  • "ping"
  • "ring"

stop()

Returns: void

Stop a playing vibration pattern.

If the vibration motor is currently playing a pattern, it will stop. It the vibration motor is not playing anything, this has no effect.

 

 

Best Answer
0 Votes

What is the code for 3 bump commands every 150mS followed by 5 nudge commands every 250 mS and looping that pattern till the Fitbit button is pressed?

Best Answer
0 Votes

Did you ever get this answered?  I am trying to do something similar and cannot get it to work.

Best Answer
0 Votes

I would try with setting a flag

let alertPattern = 0;
if(yourEvent) {alertPattern = 1}

switch(alertPattern){
   case 0:
      break;
  case 1:
     //first setInterval in a loop with decreasing index like (i = 3; i >= 0; i --)
     // if (i = 0) {alertPattern = 2; clearInterval}
    break;
case 2:
    // second setInterval
    // => buttonPressed => clearInterval, alertPattern = 0
   break;
default: alertPattern = 0
}

Absolutely untested, just an idea...
(No usable code, just structure)

 

Best Answer
0 Votes

@dzawiskie  Have a look at this post

You might want to factor in the weak vibrate on Sense and Versa 3, that gets weaker as the battery level declines. Whereas older models don't suffer in the same way.

Author | ch, passion for improvement.

Best Answer
0 Votes