guild icon
Toit
#Capture Trigger event that run application
Thread channel in help
PeterJ
PeterJ 06/03/2023 04:15 PM
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.
floitsch
floitsch 06/03/2023 09:43 PM
Can't remember if there is something similar in v1.
floitsch
floitsch 06/03/2023 09:44 PM
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.
bitphlipphar
bitphlipphar 06/04/2023 05:50 AM
If I remember correctly, it is something like this on Toit v1:

import job main: if job.trigger is job.GpioTrigger: print "Got started by GPIO interrupt"
(edited)
bitphlipphar
bitphlipphar 06/04/2023 05:52 AM
We will add something similar for Artemis through https://pkg.toit.io/package/github.com%2Ftoitware%2Ftoit-artemis.
PeterJ
PeterJ 06/04/2023 07:06 PM
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?
PeterJOPPeterJ
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 thi...
floitsch
floitsch 06/04/2023 08:14 PM
V1 (as well as Artemis) automatically go to deep sleep when no program is running and max-offline is > 0.
PeterJ
PeterJ 06/04/2023 08:19 PM
That is cool :👍: Thanks Gents!
👍1
9 messages in total