You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Wow, thanks for narrowing this down!

    I know what the problem is now. It's because the heart rate monitor uses the ADC (analog to digital converter) from an interrupt, and the E.getBattery is using it in the main event loop.

    Occasionally you can get in a state where getBattery starts the ADC and waits, but then the HRM jumps in and tries to use it, and I imagine at some point one or other of them gets confused.

    I just filed a bug for it at https://github.com/espruino/Espruino/iss­ues/1861 but I'm off this week so unlikely to get it fixed during that time. I think realistically it's going to need a firmware fix, but you may be able to work around it with:

    Bangle._setHRMPower = Bangle.setHRMPower;
    Bangle.setHRMPower = function(p) {
      Bangle._HRM = p;
      Bangle._setHRMPower(p);
    };
    E._getBattery = E.getBattery();
    E.getBattery = function() {
      Bangle._setHRMPower(0);
      var b = E._getBattery();
      Bangle._setHRMPower(Bangle._HRM);
      return b;
    }
    
About

Avatar for Gordon @Gordon started