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/issues/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:
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
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/issues/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: