11-24-2017 02:07
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-24-2017 02:07
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
If I just want to display the heart rate casually with no intention of displaying it real-time, how do I do that?
Can I create the HeartRateSensor object, but not call start/stop and just read the numerical data?
var hrm = new HeartRateSensor();
clock.granularity = "minute";
clock.ontick = () => {
$("heart").text = hrm.heartRate;
}
Will that value be updated without calling start()?
If I have to call start(), what is the consensus: should I call start+stop() every second in the clock.ontick() event or call start() on display-on event and stop() on display-off event?
Answered! Go to the Best Answer.

Accepted Solutions
11-24-2017 05:51
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-24-2017 05:51
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
If you look at the Sensors example you will see that you can use
setInterval(someFunction, timeInMilliseconds);
to make a function run periodically outside of ontick().
Here is code from my bell schedule watchface where I update the heartreat, step data, and period info a few times a minute.
clock.ontick = () => updateClock(); setInterval(updateClockData, 3000); setInterval(updatePeriodData, 15000);
Full source code: https://github.com/cmspooner/Kearsarge-Time-for-Fitbit-Ionic

11-24-2017 05:51
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

11-24-2017 05:51
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
If you look at the Sensors example you will see that you can use
setInterval(someFunction, timeInMilliseconds);
to make a function run periodically outside of ontick().
Here is code from my bell schedule watchface where I update the heartreat, step data, and period info a few times a minute.
clock.ontick = () => updateClock(); setInterval(updateClockData, 3000); setInterval(updatePeriodData, 15000);
Full source code: https://github.com/cmspooner/Kearsarge-Time-for-Fitbit-Ionic

