mirror of https://github.com/arendst/Tasmota.git
Added antiburn module
An LCD/OLED anti-screenburn feature. To use: * copy Antiburn.tapp to file system * Either issue Tasmota command antiburn or * Programmatically using lv.antiburn() The lvgl screen will change form black to red to green to blue to white each second for 30 seconds. The antiburn cleaning can be cancelled by touching the screen or it will complete after 30 seconds.
This commit is contained in:
parent
bcde597a9b
commit
04e14d0ff2
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