-
• #2
Hi - there's nothing at the moment. I think right now the listener is probably the best way...
-
• #3
Here's the kind of thing I have started doing so I can turn an event driven interface into a polling interface.
***************************************************************************** Heart Rate Monitor ******************************************************************************/ function HRM() { this.bpm = 0; this.confidence = 0; } HRM.prototype.log_debug = function(o) { console.log(o); } HRM.prototype.toggleHRMPower = function() { this.log_debug("HRM.toggleHRMPower()"); if (!Bangle.isHRMOn) return; // old firmware if (!Bangle.isHRMOn()) { this.log_debug("HRM.toggleHRMPower(powerOn)"); Bangle.removeListener('HRM', onHRM); Bangle.setHRMPower(1); Bangle.on('HRM', onHRM); } else { this.log_debug("HRM.toggleHRMPower(powerOff)"); Bangle.removeListener('HRM', onHRM); Bangle.setHRMPower(0); } // poke the hrt widget indicator to change if (WIDGETS.widhrt !== undefined) { WIDGETS.widhrt.draw(); } } HRM.prototype.getBpm = function() { return this.bpm; } HRM.prototype.getConfidence = function() { return this.getConfidence; } HRM.prototype.onHRM = function(hrm) { this.bpm = hrm.bpm; this.confidence = hrm.confidence; this.log_debug("onHRM:(bpm)" + this.bpm); this.log_debug("onHRM:(conf) " + this.confidence); } let hrmObj = new HRM(); function onHRM(hrm) { hrmObj.onHRM(hrm); }
I am wondering if there is a way to retrieve the heart bpm and confidence values by polling rather than using a listenner. In a multiclock format - the problem for me is variables being out of scope when the listenner gets called. I can do it with a listenner (as I have done with GPS fixes that I wanted to share between two multiclock watch faces) but it would be much simpler if I could just do
`
let bpm = HRM.getBpm(); let confidence = HRM.getConfidence();