2022-01-31 18:55:05 +00:00
|
|
|
var antiburn = module('antiburn')
|
|
|
|
|
|
|
|
antiburn.init = def (m)
|
|
|
|
class Antiburn
|
2022-10-07 16:50:25 +01:00
|
|
|
var antiburn # the lv_obj object used as a plain color
|
2022-01-31 18:55:05 +00:00
|
|
|
var running
|
|
|
|
static colors = [
|
|
|
|
0x000000,
|
|
|
|
0xff0000,
|
|
|
|
0x00ff00,
|
|
|
|
0x0000ff,
|
|
|
|
0xffffff
|
|
|
|
]
|
|
|
|
def init()
|
|
|
|
self.running = false
|
|
|
|
end
|
|
|
|
def start()
|
|
|
|
if self.running
|
|
|
|
return
|
|
|
|
else
|
|
|
|
lv.start()
|
2022-10-07 16:50:25 +01:00
|
|
|
|
|
|
|
if self.antiburn == nil
|
|
|
|
var antiburn = lv.obj(lv.layer_top())
|
|
|
|
antiburn.set_style_radius(0, 0)
|
|
|
|
antiburn.set_style_border_width(0, 0)
|
|
|
|
antiburn.set_style_bg_opa(255, 0)
|
|
|
|
antiburn.set_pos(0, 0)
|
|
|
|
antiburn.set_width(lv.get_hor_res())
|
|
|
|
antiburn.set_height(lv.get_ver_res())
|
|
|
|
|
|
|
|
antiburn.add_event_cb(/->self.stop(), lv.EVENT_PRESSED, 0)
|
|
|
|
self.antiburn = antiburn
|
|
|
|
end
|
|
|
|
self.antiburn.set_style_bg_opa(255, 0)
|
|
|
|
self.antiburn.add_flag(lv.OBJ_FLAG_CLICKABLE)
|
|
|
|
self.antiburn.move_foreground()
|
|
|
|
|
2022-01-31 18:55:05 +00:00
|
|
|
self.running = true
|
|
|
|
self.cycle(0)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def cycle(i)
|
2022-10-07 16:50:25 +01:00
|
|
|
if !self.running || self.antiburn == nil return nil end
|
2022-01-31 18:55:05 +00:00
|
|
|
if i < 30
|
2022-10-07 16:50:25 +01:00
|
|
|
self.antiburn.set_style_bg_color(lv.color_hex(self.colors[i % 5]), 0)
|
2022-01-31 18:55:05 +00:00
|
|
|
tasmota.set_timer(1000, /->self.cycle(i+1))
|
|
|
|
else
|
|
|
|
self.stop()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def stop()
|
2022-10-07 16:50:25 +01:00
|
|
|
if self.running && self.antiburn != nil
|
|
|
|
self.antiburn.set_style_bg_opa(0, 0)
|
|
|
|
self.antiburn.clear_flag(lv.OBJ_FLAG_CLICKABLE)
|
2022-01-31 18:55:05 +00:00
|
|
|
self.running = false
|
2022-10-07 16:50:25 +01:00
|
|
|
self.antiburn.del()
|
|
|
|
self.antiburn = nil
|
2022-01-31 18:55:05 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return Antiburn()
|
|
|
|
end
|
|
|
|
|
2022-10-07 16:50:25 +01:00
|
|
|
return antiburn
|