Hi,
I would like change on my LCD 2,4" two pages. One minutes rule 1 and one minue rule 2, pls how to set rules, timers and etc... ?
Rule will similar, but inputs different...
Anyone edit my rule... ?
Thank
On System#Boot do
tftcmd,clear,
timerSet,1,1
endon
On Rules#Timer=1 do
tftcmd,clear
tft,txtfull,5,5,4,white,black,%systm_hm%
tft,txtfull,80,55,2,white,black,out
tft,txtfull,10,80,6,red,black,"[mqtt2#Value8]"
tft,txtfull,166,85,2,white,black,°
tft,txtfull,180,85,4,white,black,C
tft,txtfull,17,185,2,white,black,well
tft,txtfull,10,210,3,white,black,"[mqtt3#Value1]cm"
timerSet,1,60
endon
RULE help
Moderators: grovkillen, Stuntteam, TD-er
Re: RULE help
Something like this:
Code: Select all
On System#Boot do
Let,1,0 // Select 1st page 0
AsyncEvent,Rules#Timer=1 // Initial page display
LoopTimerSet,1,60 // Schedule a page-switch every minute
Endon
On Rules#Timer=1 do
If %v1%=0
Let,1,1 // Next up: 2nd page
tftcmd,clear
tft,txtfull,5,5,4,white,black,%systm_hm%
tft,txtfull,80,55,2,white,black,out
tft,txtfull,10,80,6,red,black,"[mqtt2#Value8]"
tft,txtfull,166,85,2,white,black,°
tft,txtfull,180,85,4,white,black,C
tft,txtfull,17,185,2,white,black,well
tft,txtfull,10,210,3,white,black,"[mqtt3#Value1]cm"
Else
Let,1,0 // Next up: 1st page
tftcmd,clear
tft,txtfull,5,5,4,white,black,%systm_hm%
tft,txtfull,80,55,2,white,black,out
// etc. data for the second page
Endif
Endon
/Ton (PayPal.me)
Re: RULE help
Work well, thnak ! But maybe one rule will be on maximum of data, can I switch bettwen rule 1 and rule 2 sets?
Thank
Thank
Ath wrote: ↑26 Feb 2023, 22:59Something like this:Code: Select all
On System#Boot do Let,1,0 // Select 1st page 0 AsyncEvent,Rules#Timer=1 // Initial page display LoopTimerSet,1,60 // Schedule a page-switch every minute Endon On Rules#Timer=1 do If %v1%=0 Let,1,1 // Next up: 2nd page tftcmd,clear tft,txtfull,5,5,4,white,black,%systm_hm% tft,txtfull,80,55,2,white,black,out tft,txtfull,10,80,6,red,black,"[mqtt2#Value8]" tft,txtfull,166,85,2,white,black,° tft,txtfull,180,85,4,white,black,C tft,txtfull,17,185,2,white,black,well tft,txtfull,10,210,3,white,black,"[mqtt3#Value1]cm" Else Let,1,0 // Next up: 1st page tftcmd,clear tft,txtfull,5,5,4,white,black,%systm_hm% tft,txtfull,80,55,2,white,black,out // etc. data for the second page Endif Endon
Re: RULE help
If you are talking about the warning when the rules file is > 2048 bytes, then don't worry, that limit is not really 'enforced', just a remainder of a technical issue that has been solved years ago.
But if you really want to split the rules, it could be like this:
Code: Select all
On Page1 do
tftcmd,clear
tft,txtfull,5,5,4,white,black,%systm_hm%
tft,txtfull,80,55,2,white,black,out
tft,txtfull,10,80,6,red,black,"[mqtt2#Value8]"
tft,txtfull,166,85,2,white,black,°
tft,txtfull,180,85,4,white,black,C
tft,txtfull,17,185,2,white,black,well
tft,txtfull,10,210,3,white,black,"[mqtt3#Value1]cm"
Endon
On Page2 do
tftcmd,clear
tft,txtfull,5,5,4,white,black,%systm_hm%
tft,txtfull,80,55,2,white,black,out
// etc. data for the second page
Endon
On Rules#Timer=1 do
If %v1%=0
Let,1,1 // Next up: 2nd page
asyncEvent,Page1
Else
Let,1,0 // Next up: 1st page
asyncEvent,Page2
Endif
Endon
On System#Boot do
Let,1,0 // Select 1st page 0
AsyncEvent,Rules#Timer=1 // Initial page display
LoopTimerSet,1,60 // Schedule a page-switch every minute
Endon
- Rules that are executed most often should be placed first in the Rules1 file
- Because of Rules-caching this has become somewhat less important
- Rules that are only executed once, like on System#Boot do, can be moved to one of the other Rules files, to reduce the size of the Rules1 file, but effectively, these files will be parsed sequentially from Rules1..Rules4, until the requested rule is found, then scanning will stop immediately. And this scan is also performed on the cache (I expect you didn't disable that option in Tools/Advanced), and then 'jumped' to after opening the file, for speed improvements.
- On ESP32 the entire Rules files are cached in memory, for even better performance (ESP8266 doesn't have enough memory available to do that, that only caches the "on xxx do" line, with the starting-location in the file)
/Ton (PayPal.me)
Re: RULE help
Yes, I mean the "warning" Can you ask me, so what is the real limit for one rule ?
Ath wrote: ↑27 Feb 2023, 11:33If you are talking about the warning when the rules file is > 2048 bytes, then don't worry, that limit is not really 'enforced', just a remainder of a technical issue that has been solved years ago.
But if you really want to split the rules, it could be like this:
NB:Code: Select all
On Page1 do tftcmd,clear tft,txtfull,5,5,4,white,black,%systm_hm% tft,txtfull,80,55,2,white,black,out tft,txtfull,10,80,6,red,black,"[mqtt2#Value8]" tft,txtfull,166,85,2,white,black,° tft,txtfull,180,85,4,white,black,C tft,txtfull,17,185,2,white,black,well tft,txtfull,10,210,3,white,black,"[mqtt3#Value1]cm" Endon On Page2 do tftcmd,clear tft,txtfull,5,5,4,white,black,%systm_hm% tft,txtfull,80,55,2,white,black,out // etc. data for the second page Endon On Rules#Timer=1 do If %v1%=0 Let,1,1 // Next up: 2nd page asyncEvent,Page1 Else Let,1,0 // Next up: 1st page asyncEvent,Page2 Endif Endon On System#Boot do Let,1,0 // Select 1st page 0 AsyncEvent,Rules#Timer=1 // Initial page display LoopTimerSet,1,60 // Schedule a page-switch every minute Endon
- Rules that are executed most often should be placed first in the Rules1 file
- Because of Rules-caching this has become somewhat less important
- Rules that are only executed once, like on System#Boot do, can be moved to one of the other Rules files, to reduce the size of the Rules1 file, but effectively, these files will be parsed sequentially from Rules1..Rules4, until the requested rule is found, then scanning will stop immediately. And this scan is also performed on the cache (I expect you didn't disable that option in Tools/Advanced), and then 'jumped' to after opening the file, for speed improvements.
- On ESP32 the entire Rules files are cached in memory, for even better performance (ESP8266 doesn't have enough memory available to do that, that only caches the "on xxx do" line, with the starting-location in the file)
Re: RULE help
I have tested it with 12k of rules files and that was working fine.
In (really) old builds, the limit of 2k was determined by the practical max. of a HTTP POST on an ESP8266.
A few years ago, we added some JavaScript which essentially makes a call to upload a file, instead of performing a POST.
This does essentially remove the previous limit of the file.
However, rules parsing itself still takes time.
The caching of the rules is done as follows:
Each line in the rules file with "on ... do" is stored in memory, along with some index of where to find this rule.
On ESP8266 we don't keep the rest of the rules in memory, but on ESP32 we do.
So on ESP8266, this index consists of the rules file nr and the position from the start of the file.
On ESP32, this is the line nr kept in memory. (std::vector<String>)
If you have large event blocks, you may still need to parse a lot of lines each time this event is handled.
So keep this in mind when writing rules.
The array of "on ... do" lines, kept in memory, is parsed in the order they appear in the rules file(s).
So put the most frequently occuring ones at the top, but also keep in mind that the more specific ones are put first.
For example:
"on foo#bar=1 do" is more specific than "on foo#bar do", since the latter one matches all occurences of events starting with "foo#bar".
In (really) old builds, the limit of 2k was determined by the practical max. of a HTTP POST on an ESP8266.
A few years ago, we added some JavaScript which essentially makes a call to upload a file, instead of performing a POST.
This does essentially remove the previous limit of the file.
However, rules parsing itself still takes time.
The caching of the rules is done as follows:
Each line in the rules file with "on ... do" is stored in memory, along with some index of where to find this rule.
On ESP8266 we don't keep the rest of the rules in memory, but on ESP32 we do.
So on ESP8266, this index consists of the rules file nr and the position from the start of the file.
On ESP32, this is the line nr kept in memory. (std::vector<String>)
If you have large event blocks, you may still need to parse a lot of lines each time this event is handled.
So keep this in mind when writing rules.
The array of "on ... do" lines, kept in memory, is parsed in the order they appear in the rules file(s).
So put the most frequently occuring ones at the top, but also keep in mind that the more specific ones are put first.
For example:
"on foo#bar=1 do" is more specific than "on foo#bar do", since the latter one matches all occurences of events starting with "foo#bar".
Who is online
Users browsing this forum: No registered users and 1 guest