I've decided to go with:
E.getBattery = function() { const lo=0.255,hi=0.293; var b=Math.max(lo,Math.min(hi,analogRead(D3))); return Math.round((b-lo)*100/(hi-lo)); };
and saved it as "getbattery.boot.js". Adjust "hi" and "lo" as required.
@andrewg_oz started
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.
I've decided to go with:
and saved it as "getbattery.boot.js". Adjust "hi" and "lo" as required.