07-30-2021 09:36
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

07-30-2021 09:36
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
This may be simple, but after numerous attempts I am stumped. Is there a way to program multiple vibrations, e.g. four "bump"s in a row?
07-30-2021 10:49 - edited 07-30-2021 11:12
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

07-30-2021 10:49 - edited 07-30-2021 11:12
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
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!

07-30-2021 15:06
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

07-30-2021 15:06
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Good idea, seems logical. Didn't work. Thanks anyway.

07-30-2021 15:10
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


07-30-2021 15:10
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I wonder if you might be able to achieve this using setInterval(). Just be careful not to create an infinite loop!
Gondwana Software

07-30-2021 15:42
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

07-30-2021 15:42
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@Gondwana you can start it this way, but can you stop a setinterval() call? If so, I'd like to know because that may be useful in the future!

07-30-2021 15:43
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

07-30-2021 15:43
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
@dzawiskie if I get the chance, I'll play around and see if I can't figure something out!

07-30-2021 15:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


07-30-2021 15:47
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
clearInterval(), 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. 🙂
Gondwana Software
07-30-2021 15:49
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


07-30-2021 15:49
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Or, you could call setTimeout() for each repeat.
Gondwana Software

07-30-2021 17:07
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


07-30-2021 17:07
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
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)
Gondwana Software
07-31-2021 04:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

07-31-2021 04:53
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
This would be much simpler on a Pebble.

08-02-2021 05:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


08-02-2021 05:44
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
