mirror of https://github.com/arendst/Tasmota.git
Merge pull request #14687 from Beormund/development
Added antiburn module
This commit is contained in:
commit
f8b402f198
Binary file not shown.
|
@ -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
|
|
@ -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…
Reference in New Issue