You need to import the vibration function, and you can use a for loop, like so: (Reference: https://dev.fitbit.com/build/reference/device-api/haptics/)
import { vibration } from "haptics";
Then inside a function that you are wanting to run the bumps:
for(let i=0; i<4; i++){
vibration.start("bump");
}
NOTE: I have not used this before, I wrote this on the fly. So I am unsure if you need to do a 'vibration.stop("bump")' or not after the 'start'. This should get you on the right track though!
Best AnswerI wonder if you might be able to achieve this using setInterval(). Just be careful not to create an infinite loop!
Best Answer@dzawiskie if I get the chance, I'll play around and see if I can't figure something out!
Best AnswerclearInterval(), I think. You'd need to retain a variable that represents the interval timer (returned from setInterval), and another variable to keep count.
If you were being really fancy, you'd wrap it all into a nice class or object or module. 🙂
There's a small chance that something like this might work:
const vibrationRepeater = (pattern, count, interval) => {
vibration.start(pattern) // do one straight away
let counter = count - 1
let timer = setInterval(()=>{
vibration.start(pattern)
if (!--counter) clearInterval(timer)
}, interval)
}
vibrationRepeater('bump', 4, 500)
Fitbit Product Experts Alumni are retired members of the Fitbit Product Expert Program. Learn more