Capture Trigger event that run application
# help
p
Is there a function that capture what triggered the application to run. Was it on_interval or a gpios that woke up the device? I'm trying to capture the event so I can run a specific function if the device is woke up by gpios interrupt.
f
In v2 there is https://libs.toit.io/esp32/library-summary#wakeup_cause(0%2C0%2C0%2C)
Can't remember if there is something similar in v1.
In the worst case you could start different programs with different triggers and then start the main app with a pubsub message that contains the wakeup cause.
k
If I remember correctly, it is something like this on Toit v1:
Copy code
import job
main:
  if job.trigger is job.GpioTrigger:
    print "Got started by GPIO interrupt"
We will add something similar for Artemis through https://pkg.toit.io/package/github.com%2Ftoitware%2Ftoit-artemis.
p
import job etc. works like a charm. Now I just need to make the device go to deep sleep again, and in version 1 import esp32 is not available. Do you have a library containing this function?
f
V1 (as well as Artemis) automatically go to deep sleep when no program is running and max-offline is > 0.
p
That is cool 👍 Thanks Gents!