I have code that runs endless loop:
do some work in the onInit() method, deepSleep, wake-up and over again
it works fine, but I need to be able to stop this endless loop so that I can gain access to the terminal and reset or change code.
Usually Espruino doesn't load code if a button is pressed at boot, but unfortunately it looks like on the normal ESP32 build no pin has been defined for this, so I'm not really sure there's a way.
You could always boot to the bootloader mode and then erase the first page of Storage (at 0x320000 I think?)
Any hints how to set-up a "button" pin?
I ended up checking for certain pin in my code which I short or pull up when needed.
bool buttonState = false;
buttonState = jshPinInput(BTN1_PININDEX) == BTN1_ONSTATE;
jsiInit(!buttonState); // pressing USER button skips autoload
The code is for the stm32, but it could be replicated for ESP32. Define BTN1_PININDEX (maybe jshardware.c?) and use this code. Actually it would be nice to have it in every board.
Button can be defined in board file, see other boards for BTN1. this 'check button and skip load' is there for nrf52 too so that's basically all boards except ESP. could be added here https://github.com/espruino/Espruino/blob/master/targets/esp32/main.c#L69
Don't worry about formatting, just type in the text and we'll take care of making sense of it. We will auto-convert links, and if you put asterisks around words we will make them bold.
For a full reference visit the Markdown syntax.
© Espruino, powered by microcosm.
Report a problem