Thanks ....
so all rules sets are finally one big programm-area...
this is a big difference to Tasmota ... BUT EspEasy a a very nice stuff ... much to huge for my old brain ... THANKS A LOT !!!
AND: with <TaskDisable> and <TaskEnable> my project works fine .. THIS is the final code....(if somebody else is interested in) ...
Code: Select all
On System#Boot do
GPIO,2,1
delay 500
let,100,60 // PulsOutput every xx sec
let,110,3000 // Distance to ground to calc the real OilLevel
let,111, 1.272 // ltr per cm
TaskEnable,1 // Start LX53L0X
timerset,2,[VAR#100] // Start PulseSequenceTimer
endon
// moving Average:
On LX53L0X#Distance Do
GPIO,2,1
// change to much > [VAR#3] => RESTART
if abs([LX53L0X#Distance]-[VAR#2])>[VAR#3]
Let,10,0
endif
// (Re-)START
if [VAR#10]=0
GPIO,2,1
Let,1,[LX53L0X#Distance]
Let,2,[VAR#1]
Let,3,50 // max Change (measured Value - moving average)
Let,5,0
Let,6,100 // length of Data-Puls [ms]
Let,7,2000 // length of Start/Stop-Pulse [ms]
Let,9,30 // max Number of Elements in moving Average
Let,10,1
endif
// Calc of Moving Average and the reported Value VAR#4
if [VAR#10]<[VAR#9]
Let,10,[VAR#10]+1
Let,1,[VAR#1]+[LX53L0X#Distance]
else
Let,1,round([VAR#1]*([VAR#10]-1)/[VAR#10])+[LX53L0X#Distance]
endif
Let,2,round([VAR#1]/[VAR#10])
if [VAR#2]<=[VAR#110]-50
Let,4,round(([VAR#110]-[VAR#2])/10) // Oil [*10 ltr]
else
let,4,35 // limit min.OilLevel
endif
logentry,[VAR#4] "cm OilNiveau"
let,112, round([Var#4]*[VAR#111])
logentry,[VAR#112] "x10 ltr Heizöl"
EndOn
on Rules#Timer=2 do // Timer to start Report
GPIO,2,1
if [VAR#10]=[VAR#9] and [VAR#4]>30
TaskDisable,1
GPIO,2,1
Let,5,[VAR#7]
delay 500
timerset_ms,1,5
else
TaskEnable,1
endif
timerset,2,[VAR#100]
EndOn
// PulseSequenz- Output
On Rules#Timer=1 do
timerset_ms,1,[VAR#5]*2
pulse,2,0,[VAR#5]
if [VAR#5] = [VAR#7] // START
let,5,[VAR#6]
elseif [VAR#4]>0 // Data
let 4,[VAR#4]-1
if [VAR#4]=0 //STOP
let,5,0
timerset_ms,1,[VAR#7]*2
pulse,2,0,[VAR#7]
TaskEnable,1
endif
endif
endon
Finally I'll change the GPIO for Output ... and fit all parameter to the real situation ...