09-30-2021 11:37
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

09-30-2021 11:37
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I'm working on a metronome app for my Fitbit Sense, and I want the watch to vibrate at regular intervals. It works great while the display is on, or while the developer bridge is enabled. Once the display turns off, however, the interval fires unreliably (e.g., when set to 500 ms, it only fires once a second or so).
This is a trivial reproducer:
import { vibration } from "haptics";
setInterval(() => vibration.start("nudge-max"), 500);
Sideload this, then disable the developer bridge in settings, then start the app. While the display is on, it will vibrate twice a second. Once the display turns off, it will be sporadic.
The Fitbit Sense doesn't seem to allow display.autoOff = false, so I can't use that as a workaround. setTimeout() seems to suffer from the same issue.
I found a similar issue, but it had no solution. So, I'll ask again: how can I use setInterval() reliably while the display is off?
Answered! Go to the Best Answer.
Accepted Solutions
10-18-2021 10:41
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

10-18-2021 10:41
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
In the end, I got it to work by adding a delayed vibration.stop:
import { vibration } from "haptics";
setInterval(() => {
vibration.start("nudge-max");
setTimeout(vibration.stop, 150);
}, 500);
I still don't understand why this workaround is only needed when the display is off.

09-30-2021 13:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

09-30-2021 13:58
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Based on another post and my own testing, it looks like the intervals themselves are actually firing. It's the vibration that doesn't go through. vibration.start() is returning false. I don't understand why this only happens when the screen is off, since that return value isn't documented.

09-30-2021 21:35
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


09-30-2021 21:35
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Try display.poke every 7 seconds.
This will keep the display on permanently and it should be reliable enough.
Author | ch, passion for improvement.

10-01-2021 11:23 - edited 10-01-2021 11:24
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

SunsetRunner
10-01-2021 11:23 - edited 10-01-2021 11:24
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
I wonder, whether the problem might be, that the call itself "consumes" and so might produce a delay on device ... (just a thought)

10-18-2021 10:41
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

10-18-2021 10:41
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
In the end, I got it to work by adding a delayed vibration.stop:
import { vibration } from "haptics";
setInterval(() => {
vibration.start("nudge-max");
setTimeout(vibration.stop, 150);
}, 500);
I still don't understand why this workaround is only needed when the display is off.

