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

Best practice for showing heart rate on clock face

Howdy,

 

What's the best practice for showing the current heart rate on a clock face?

 

Should we update the visible heart rate on a tick of the Clock API with "seconds" granularity, or should we .start() a HeartRateSensor instance and update the visible heart rate whenever the onreading() callback is called (but never calling .stop() on the HeartRateSensor instance, effectively making it run forever)?

 

Alternatively, is there an even better, more efficient way of doing this?

 

Thanks,

Nick

Best Answer
0 Votes
2 REPLIES 2

I'm no authority, but I'd do a start and stop on the heart rate sensor tied to the Display API onchange event. That way you can get "real-time" heart rates, but save the battery to be best of your ability when the display goes off.

Best Answer
0 Votes

Unless you need the heart rate updated more than once a second, then it is generally better to call stop() during the onreading+onerror() callback, and then trigger another start() when you need it again.

 

Some developers call start() by hooking into the display.onchange() callback and calling stop() in the onreading+onerror() callback, meaning the result will be shown and not updated for the duration that the screen is on (minimum 10 seconds).

 

I myself prefer to call start() in clock.ontick() with "seconds" granularity but also have a time counter so that start() won't be called more than once every 2.5 seconds. That way, users can fit in 3~4 measurements of the heart rate before the screen goes off after 10 seconds.

 

Also, before calling start() you should check if (hrm.activated === true) so that you can skip calling start() because the previous call has not finished, which could occur if the watch is not on the wrist or the user pressed the screen off/on button rapidly.

Best Answer
0 Votes