Doing something while waking up from sleep

Hi,
I want do be able to blink an LED or play tone() while my electron is waking up from sleep .
Right now it takes 20 seconds or so before it is ‘awoken’ and only then I am able to flash some LEDs or play a tune… Is there a function like STARTUP for waking from sleep ? (I am using an electron with 0.5.3)

You’d need to chose a better SYSTEM_MODE() and consider the use of SYSTEM_THREAD(ENABLED) too.

BTW, STARTUP will only be executed when waking from deep sleep, not from Stop Mode sleep.

2 Likes

so If I use SYSTEM_THREAD(ENABLED) i will win some time? (Or do i need a manual system mode so the startup is faster and then do somehting first before connecting to the cloud ?)
I need to go to sleep for indefinite amount of time and then wake from a pin. so Deep sleep is not an option i think

With a dedicated thread for the cloud tasks your own app code will start running immediately without needing to wait for the cloud connection.
But for that reason you might want to check for an active connection before doing cloud-dependent stuff.

Choosing the right SYSTEM_MODE() will then just help the system thread not to waste time on cloud stuff when you won’t need/want it anyway.