However, when I modify the code to enable sleep after performing some action, the Puck lights up all 3 LEDs and my function does not work again. Here is a sample pseudo code -
var locked = 0;
setWatch(function(){
NRF.wake();
digitalPulse(LED2, 1, 50);
/*
do something here
*/
setTimeout(() => NRF.sleep(), 1000); // turns on all 3 LEDs briefly and resets.
}, BTN, {repeat:true, edge:"rising", debounce:50});
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 have an application where the Puck sends data through BLE write on another device.
To reduce power consumption even more, I tried turning off NRF by NRF.sleep() (The example here works https://github.com/espruino/EspruinoDocs/blob/master/puck/Puck.js%20Security.md#disable-bluetooth)
However, when I modify the code to enable sleep after performing some action, the Puck lights up all 3 LEDs and my function does not work again. Here is a sample pseudo code -
var locked = 0;
setWatch(function(){
NRF.wake();
digitalPulse(LED2, 1, 50);
/*
do something here
*/
setTimeout(() => NRF.sleep(), 1000); // turns on all 3 LEDs briefly and resets.
}, BTN, {repeat:true, edge:"rising", debounce:50});
Any suggestions why is this happening ?