LVGL HASPmota demo and antiburn update

This commit is contained in:
Stephan Hadinger 2022-10-07 17:50:25 +02:00
parent 0876360f44
commit 0c1ad0254f
7 changed files with 28 additions and 15 deletions

Binary file not shown.

View File

@ -1,5 +1,5 @@
# generate all haspmota tapp files # generate all haspmota tapp files
rm haspmota.tapp; zip -j -0 haspmota.tapp haspmota_core/* rm haspmota.tapp; zip -j -0 haspmota.tapp haspmota_core/*
rm haspmota_demo.tapp ; zip -j -0 haspmota_demo.tapp haspmota_demo/* haspmota_core/haspmota.be rm haspmota_demo.tapp ; zip -j -0 haspmota_demo.tapp haspmota_demo/*
cp haspmota.tapp ../haspmota cp haspmota.tapp ../haspmota
cp haspmota_demo.tapp ../haspmota cp haspmota_demo.tapp ../haspmota

View File

@ -11,7 +11,7 @@ import lv_tasmota_info
import lv_wifi_graph import lv_wifi_graph
import haspmota import haspmota
haspmota.start(false, "haspmota_demo.tapp#pages.jsonl") haspmota.start(false, tasmota.wd + "pages.jsonl")
var prev_day = -1 var prev_day = -1
def set_watch() def set_watch()

View File

@ -2,8 +2,7 @@ var antiburn = module('antiburn')
antiburn.init = def (m) antiburn.init = def (m)
class Antiburn class Antiburn
var scr_original var antiburn # the lv_obj object used as a plain color
var scr_antiburn
var running var running
static colors = [ static colors = [
0x000000, 0x000000,
@ -20,29 +19,43 @@ antiburn.init = def (m)
return return
else else
lv.start() lv.start()
self.scr_original = lv.scr_act()
self.scr_antiburn = lv.obj(0) if self.antiburn == nil
lv.scr_load(self.scr_antiburn) var antiburn = lv.obj(lv.layer_top())
self.scr_antiburn.add_event_cb(/->self.stop(), lv.EVENT_PRESSED, 0) 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()
self.running = true self.running = true
self.cycle(0) self.cycle(0)
end end
end end
def cycle(i) def cycle(i)
if !self.running return end if !self.running || self.antiburn == nil return nil end
if i < 30 if i < 30
self.scr_antiburn.set_style_bg_color(lv.color_hex(self.colors[i % 5]), 0) self.antiburn.set_style_bg_color(lv.color_hex(self.colors[i % 5]), 0)
tasmota.set_timer(1000, /->self.cycle(i+1)) tasmota.set_timer(1000, /->self.cycle(i+1))
else else
self.stop() self.stop()
end end
end end
def stop() def stop()
if self.running && self.scr_antiburn != nil if self.running && self.antiburn != nil
lv.scr_load(self.scr_original) self.antiburn.set_style_bg_opa(0, 0)
self.antiburn.clear_flag(lv.OBJ_FLAG_CLICKABLE)
self.running = false self.running = false
self.scr_antiburn.del() self.antiburn.del()
self.scr_antiburn = nil self.antiburn = nil
end end
end end
end end