System event that is only triggered by coldboot

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

System event that is only triggered by coldboot

#1 Post by chromo23 » 22 Jul 2022, 21:58

Is there a way to determine whenever there is a wake from sleep or a coldboot?
It seems that system#wake and system#boot are triggered either way.

I wanted to prevent a deepsleep via rules by setting a variable only after a coldboot instead of using a pin.

I thought about something like this:

Code: Select all

On System#Wake Do
	Let,1,0
Endon 

On Rules#Timer=1 Do
	If [var#1]=1
		DeepSleep,60
	Else
		TimerSet,1,30
		Let,3,1
	Endif
Endon

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: System event that is only triggered by coldboot

#2 Post by chromo23 » 22 Jul 2022, 22:02

Code: Select all

On System#Wake Do
When i look at this event it seems counterintuitive to use it but it is triggered before System#Boot right?

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: System event that is only triggered by coldboot

#3 Post by TD-er » 22 Jul 2022, 22:06

You can add a dummy task and set a value in that dummy using taskvalueset.

Since it is a task value, it will be kept in RTC memory and restored on a warm boot.

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: System event that is only triggered by coldboot

#4 Post by chromo23 » 22 Jul 2022, 22:16

Of course...had a knot in my head... :roll:

Working code:

Code: Select all

On Rules#Timer=1 do
	If [boot#isboot]=1
		DeepSleep,30
	Else
		TimerSet,1,30
		TaskValueSet,boot,1,1
	Endif
Endon

User avatar
Ath
Normal user
Posts: 3416
Joined: 10 Jun 2018, 12:06
Location: NL

Re: System event that is only triggered by coldboot

#5 Post by Ath » 22 Jul 2022, 23:28

Setting var#1 to zero on wake isn't any helpful, as it will also be 0 on system#boot/cold boot :shock: ;)
/Ton (PayPal.me)

User avatar
chromo23
Normal user
Posts: 821
Joined: 10 Sep 2020, 16:02
Location: germany

Re: System event that is only triggered by coldboot

#6 Post by chromo23 » 23 Jul 2022, 00:02

I knooooow but i didn´t want to take any chances to mess up with deepsleep and i somehow was afraid, that if i don´t declare it, i will be in a undefined state :shock:
(It´s a kind of hardwarethinking where a pin behaves unpredictable when you don’t pull it up or down)...

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 25 guests