I notice @benoit that enterBatteryCheckState() is called during "run" when any of the switchxRising/Falling() code is executed. What is the load that is seen by analogRead() and by the display update? Does the current drop after the five second timeout?
Try commenting your some of the nested setTimout() sections as there is a lot going on there.
Divide and conquer as @Gordon suggested. This is going to be fun! Keep us posted on what is discovered.
© Espruino, powered by microcosm.
Report a problem