Ooo clever, so even though the once per minute timeout call is recursive it checks for an existing timeout and clears it, then updates the advertising interval when it updates the sensor values based on if the button is pressed or not. I assume we have to clear the existing timeout or it only runs the once?
The code I have at the moment is very similar btw but I'm not being that clever with the ternary statement I was just setting it to a hard 20ms in the setAdvertising(options) object and using a once a minute timer.
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.
Ooo clever, so even though the once per minute timeout call is recursive it checks for an existing timeout and clears it, then updates the advertising interval when it updates the sensor values based on if the button is pressed or not. I assume we have to clear the existing timeout or it only runs the once?
The code I have at the moment is very similar btw but I'm not being that clever with the ternary statement I was just setting it to a hard 20ms in the setAdvertising(options) object and using a once a minute timer.