• 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();

  • Hi - there's nothing at the moment. I think right now the listener is probably the best way...

  • 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(power­On)");
        Bangle.removeListener('HRM', onHRM);
        Bangle.setHRMPower(1);
        Bangle.on('HRM', onHRM);
      } else {
        this.log_debug("HRM.toggleHRMPower(power­Off)");
        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);
    }
    
    
  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

Is there are way to retrieve heart rate bpm and confidence by calling a function rather than using a listenner ?

Posted by Avatar for HughB @HughB

Actions