mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-21 17:56:31 +00:00
Merge pull request #14687 from Beormund/development
Added antiburn module
This commit is contained in:
commit
f8b402f198
BIN
tasmota/berry/modules/Antiburn.tapp
Normal file
BIN
tasmota/berry/modules/Antiburn.tapp
Normal file
Binary file not shown.
52
tasmota/berry/modules/antiburn/antiburn.be
Normal file
52
tasmota/berry/modules/antiburn/antiburn.be
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
var antiburn = module('antiburn')
|
||||||
|
|
||||||
|
antiburn.init = def (m)
|
||||||
|
class Antiburn
|
||||||
|
var scr_original
|
||||||
|
var scr_antiburn
|
||||||
|
var running
|
||||||
|
static colors = [
|
||||||
|
0x000000,
|
||||||
|
0xff0000,
|
||||||
|
0x00ff00,
|
||||||
|
0x0000ff,
|
||||||
|
0xffffff
|
||||||
|
]
|
||||||
|
def init()
|
||||||
|
self.running = false
|
||||||
|
end
|
||||||
|
def start()
|
||||||
|
if self.running
|
||||||
|
return
|
||||||
|
else
|
||||||
|
lv.start()
|
||||||
|
self.scr_original = lv.scr_act()
|
||||||
|
self.scr_antiburn = lv.obj(0)
|
||||||
|
lv.scr_load(self.scr_antiburn)
|
||||||
|
self.scr_antiburn.add_event_cb(/->self.stop(), lv.EVENT_PRESSED, 0)
|
||||||
|
self.running = true
|
||||||
|
self.cycle(0)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def cycle(i)
|
||||||
|
if !self.running return end
|
||||||
|
if i < 30
|
||||||
|
self.scr_antiburn.set_style_bg_color(lv.color_hex(self.colors[i % 5]), 0)
|
||||||
|
tasmota.set_timer(1000, /->self.cycle(i+1))
|
||||||
|
else
|
||||||
|
self.stop()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
def stop()
|
||||||
|
if self.running && self.scr_antiburn != nil
|
||||||
|
lv.scr_load(self.scr_original)
|
||||||
|
self.running = false
|
||||||
|
self.scr_antiburn.del()
|
||||||
|
self.scr_antiburn = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return Antiburn()
|
||||||
|
end
|
||||||
|
|
||||||
|
return antiburn
|
20
tasmota/berry/modules/antiburn/autoexec.be
Normal file
20
tasmota/berry/modules/antiburn/autoexec.be
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
# Register the command 'Antiburn'
|
||||||
|
# Module loaded in memory only when the command is first used
|
||||||
|
|
||||||
|
var wd = tasmota.wd
|
||||||
|
|
||||||
|
lv.antiburn = def()
|
||||||
|
import sys
|
||||||
|
var path = sys.path()
|
||||||
|
path.push(wd)
|
||||||
|
import antiburn
|
||||||
|
path.pop()
|
||||||
|
antiburn.start()
|
||||||
|
end
|
||||||
|
|
||||||
|
tasmota.add_cmd("Antiburn",
|
||||||
|
def ()
|
||||||
|
lv.antiburn()
|
||||||
|
tasmota.resp_cmnd_done()
|
||||||
|
end
|
||||||
|
)
|
Loading…
x
Reference in New Issue
Block a user