mirror of
https://github.com/arendst/Tasmota.git
synced 2025-07-29 05:36:39 +00:00
HASPmota add 'antiburn()' (#23400)
This commit is contained in:
parent
1e74d6fd4d
commit
66013fcf04
@ -13,6 +13,7 @@ All notable changes to this project will be documented in this file.
|
||||
- WebUI status line left and renamed events `FUNC_WEB_STATUS_LEFT` and `FUNC_WEB_STATUS_RIGHT` (#23354)
|
||||
- WebUI heap status (#23356)
|
||||
- Support for multi channel AU915-928 LoRaWanBridge by Rob Clark (#23372)
|
||||
- HASPmota add `antiburn()`
|
||||
|
||||
### Breaking Changed
|
||||
|
||||
|
@ -26,6 +26,69 @@ def list_to_bytes(l)
|
||||
return b
|
||||
end
|
||||
|
||||
#################################################################################
|
||||
# Class Antiburn now embedded in HASPmota
|
||||
#################################################################################
|
||||
#@ solidify:Antiburn,weak
|
||||
class Antiburn
|
||||
var antiburn # the lv_obj object used as a plain color
|
||||
var running
|
||||
static colors = [
|
||||
0x000000,
|
||||
0xff0000,
|
||||
0x00ff00,
|
||||
0x0000ff,
|
||||
0xffffff
|
||||
]
|
||||
def init()
|
||||
self.running = false
|
||||
end
|
||||
def start()
|
||||
if self.running
|
||||
return
|
||||
else
|
||||
lv.start()
|
||||
|
||||
if self.antiburn == nil
|
||||
var antiburn = lv.obj(lv.layer_sys())
|
||||
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.cycle(0)
|
||||
end
|
||||
end
|
||||
def cycle(i)
|
||||
if !self.running || self.antiburn == nil return nil end
|
||||
if i < 30
|
||||
self.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.antiburn != nil
|
||||
self.antiburn.set_style_bg_opa(0, 0)
|
||||
self.antiburn.clear_flag(lv.OBJ_FLAG_CLICKABLE)
|
||||
self.running = false
|
||||
self.antiburn.del()
|
||||
self.antiburn = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#################################################################################
|
||||
# Pre-defined events lists
|
||||
#################################################################################
|
||||
@ -290,7 +353,7 @@ class lvh_root
|
||||
else
|
||||
self._lv_obj = obj
|
||||
end
|
||||
self.post_init()
|
||||
self.post_init(jline)
|
||||
end
|
||||
|
||||
#====================================================================
|
||||
@ -599,7 +662,7 @@ class lvh_obj : lvh_root
|
||||
#====================================================================
|
||||
# post-init, to be overriden and used by certain classes
|
||||
#====================================================================
|
||||
def post_init()
|
||||
def post_init(jline)
|
||||
self.register_event_cb()
|
||||
end
|
||||
|
||||
@ -1177,8 +1240,8 @@ class lvh_fixed : lvh_obj
|
||||
# static var _EVENTS = EVENTS_ALL
|
||||
|
||||
# label do not need a sub-label
|
||||
def post_init()
|
||||
super(self).post_init() # call super
|
||||
def post_init(jline)
|
||||
super(self).post_init(jline) # call super
|
||||
var obj = self._lv_obj
|
||||
obj.set_style_pad_all(0, 0)
|
||||
obj.set_style_radius(0, 0)
|
||||
@ -1197,8 +1260,8 @@ class lvh_flex : lvh_fixed
|
||||
# static var _lv_class = lv.obj # from parent class
|
||||
static var _EVENTS = EVENTS_NONE # inhetited
|
||||
# label do not need a sub-label
|
||||
def post_init()
|
||||
super(self).post_init() # call super
|
||||
def post_init(jline)
|
||||
super(self).post_init(jline) # call super
|
||||
var obj = self._lv_obj
|
||||
obj.set_flex_flow(lv.FLEX_FLOW_ROW)
|
||||
end
|
||||
@ -1211,9 +1274,9 @@ end
|
||||
class lvh_label : lvh_obj
|
||||
static var _lv_class = lv.label
|
||||
# label do not need a sub-label
|
||||
def post_init()
|
||||
def post_init(jline)
|
||||
self._lv_label = self._lv_obj # the label is also the object itself
|
||||
super(self).post_init() # call super
|
||||
super(self).post_init(jline) # call super
|
||||
end
|
||||
end
|
||||
|
||||
@ -1349,6 +1412,21 @@ class lvh_msgbox : lvh_obj
|
||||
self.bg_opa = 255 # can be overriden
|
||||
end
|
||||
|
||||
#====================================================================
|
||||
# post_init
|
||||
#
|
||||
# We need to instanciate all buttons first before applying attributes
|
||||
#====================================================================
|
||||
def post_init(jline)
|
||||
# need to apply options first, and remove to avoid being handled again
|
||||
if jline.contains('options')
|
||||
self.set_options(jline['options'])
|
||||
jline.remove('options')
|
||||
end
|
||||
# rest of attributes
|
||||
super(self).post_init(jline)
|
||||
end
|
||||
|
||||
#====================================================================
|
||||
# register_event_cb
|
||||
#
|
||||
@ -1740,7 +1818,7 @@ class lvh_dropdown_list : lvh_obj
|
||||
static var _lv_class = nil
|
||||
# static var _EVENTS = EVENTS_NONE
|
||||
|
||||
def post_init()
|
||||
def post_init(jline)
|
||||
self._lv_obj = nil # default to nil object, whatever it was initialized with
|
||||
# check if it is the parent is a spangroup
|
||||
if isinstance(self._parent_lvh, self._page._hm.lvh_dropdown)
|
||||
@ -1748,7 +1826,7 @@ class lvh_dropdown_list : lvh_obj
|
||||
else
|
||||
print("HSP: 'dropdown_list' should have a parent of type 'dropdown'")
|
||||
end
|
||||
super(self).post_init()
|
||||
super(self).post_init(jline)
|
||||
end
|
||||
end
|
||||
|
||||
@ -1759,8 +1837,8 @@ end
|
||||
class lvh_bar : lvh_obj
|
||||
static var _lv_class = lv.bar
|
||||
|
||||
def post_init()
|
||||
super(self).post_init()
|
||||
def post_init(jline)
|
||||
super(self).post_init(jline)
|
||||
if isinstance(self._parent_lvh, self._page._hm.lvh_scale)
|
||||
# if sub-object of scale, copy min and max
|
||||
var min = self._parent_lvh._lv_obj.get_range_min_value()
|
||||
@ -1864,7 +1942,7 @@ class lvh_scale_section : lvh_root
|
||||
var _style30 # style for LV_PART_ITEMS
|
||||
var _min, _max
|
||||
|
||||
def post_init()
|
||||
def post_init(jline)
|
||||
self._lv_obj = nil # default to nil object, whatever it was initialized with
|
||||
self._min = 0 # default value by LVGL
|
||||
self._max = 0 # default value by LVGL
|
||||
@ -1881,7 +1959,7 @@ class lvh_scale_section : lvh_root
|
||||
else
|
||||
print("HSP: 'scale_section' should have a parent of type 'scale'")
|
||||
end
|
||||
# super(self).post_init() # call super - not needed for lvh_root
|
||||
# super(self).post_init(jline) # call super - not needed for lvh_root
|
||||
end
|
||||
|
||||
def set_min(t)
|
||||
@ -1998,14 +2076,14 @@ class lvh_scale_line : lvh_line
|
||||
var _needle_length
|
||||
# var _lv_points # in superclass
|
||||
|
||||
def post_init()
|
||||
def post_init(jline)
|
||||
# check if it is the parent is a spangroup
|
||||
if !isinstance(self._parent_lvh, self._page._hm.lvh_scale)
|
||||
print("HSP: 'scale_line' should have a parent of type 'scale'")
|
||||
end
|
||||
self._needle_length = 0
|
||||
self._lv_points = lv.point_arr([lv.point(), lv.point()]) # create an array with 2 points
|
||||
super(self).post_init()
|
||||
super(self).post_init(jline)
|
||||
end
|
||||
|
||||
def set_needle_length(t)
|
||||
@ -2040,10 +2118,10 @@ end
|
||||
class lvh_spangroup : lvh_obj
|
||||
static var _lv_class = lv.spangroup
|
||||
# label do not need a sub-label
|
||||
def post_init()
|
||||
def post_init(jline)
|
||||
self._lv_obj.set_mode(lv.SPAN_MODE_BREAK) # use lv.SPAN_MODE_BREAK by default
|
||||
self._lv_obj.refr_mode()
|
||||
super(self).post_init() # call super -- not needed
|
||||
super(self).post_init(jline) # call super -- not needed
|
||||
end
|
||||
# refresh mode
|
||||
def refr_mode()
|
||||
@ -2060,7 +2138,7 @@ class lvh_span : lvh_root
|
||||
# label do not need a sub-label
|
||||
var _style # style object
|
||||
|
||||
def post_init()
|
||||
def post_init(jline)
|
||||
self._lv_obj = nil # default to nil object, whatever it was initialized with
|
||||
# check if it is the parent is a spangroup
|
||||
if isinstance(self._parent_lvh, self._page._hm.lvh_spangroup)
|
||||
@ -2070,7 +2148,7 @@ class lvh_span : lvh_root
|
||||
else
|
||||
print("HSP: 'span' should have a parent of type 'spangroup'")
|
||||
end
|
||||
# super(self).post_init() # call super - not needed for lvh_root
|
||||
# super(self).post_init(jline) # call super - not needed for lvh_root
|
||||
end
|
||||
|
||||
#====================================================================
|
||||
@ -2182,9 +2260,9 @@ class lvh_tabview : lvh_obj
|
||||
var _tab_list # list of tabs
|
||||
|
||||
# label do not need a sub-label
|
||||
def post_init()
|
||||
def post_init(jline)
|
||||
self._tab_list = []
|
||||
super(self).post_init() # call super -- not needed
|
||||
super(self).post_init(jline) # call super -- not needed
|
||||
end
|
||||
|
||||
#====================================================================
|
||||
@ -2271,7 +2349,7 @@ class lvh_tab : lvh_obj
|
||||
#====================================================================
|
||||
# specific post-init wihtout events
|
||||
#====================================================================
|
||||
def post_init()
|
||||
def post_init(jline)
|
||||
self._lv_obj.set_style_radius(0, 0) # set default radius to `0` for rectangle tabs
|
||||
# self.register_event_cb()
|
||||
end
|
||||
@ -2291,7 +2369,7 @@ class lvh_tab : lvh_obj
|
||||
super(self).init(parent, page, jline, lv_instance, parent_obj)
|
||||
end
|
||||
|
||||
def post_init()
|
||||
def post_init(jline)
|
||||
self._lv_obj = nil # default to nil object, whatever it was initialized with
|
||||
# check if it is the parent is a spangroup
|
||||
if isinstance(self._parent_lvh, self._page._hm.lvh_tabview)
|
||||
@ -2313,7 +2391,7 @@ class lvh_tab : lvh_obj
|
||||
else
|
||||
print("HSP: 'tab' should have a parent of type 'tabview'")
|
||||
end
|
||||
# super(self).post_init() # call super - not needed for lvh_root
|
||||
# super(self).post_init(jline) # call super - not needed for lvh_root
|
||||
end
|
||||
|
||||
#====================================================================
|
||||
@ -2364,7 +2442,7 @@ class lvh_chart : lvh_obj
|
||||
# h_div/v_div contain the horizontal and vertical divisions, we need to memorize values because both are set from same API
|
||||
var _h_div, _v_div
|
||||
|
||||
def post_init()
|
||||
def post_init(jline)
|
||||
# default values from LVGL are 0..100
|
||||
self._y_min = 0
|
||||
self._y_max = 100
|
||||
@ -2380,6 +2458,7 @@ class lvh_chart : lvh_obj
|
||||
|
||||
self._ser1 = self._lv_obj.add_series(lv.color(0xEE4444), lv.CHART_AXIS_PRIMARY_Y)
|
||||
self._ser2 = self._lv_obj.add_series(lv.color(0x44EE44), lv.CHART_AXIS_SECONDARY_Y)
|
||||
super(self).post_init(jline)
|
||||
end
|
||||
|
||||
def add_point(v)
|
||||
@ -2854,6 +2933,8 @@ class HASPmota
|
||||
static lvh_qrcode = lvh_qrcode
|
||||
# special cases
|
||||
static lvh_chart = lvh_chart
|
||||
# other helper classes
|
||||
static var Antiburn = Antiburn
|
||||
|
||||
static var PAGES_JSONL = "pages.jsonl" # default template name
|
||||
|
||||
@ -2949,6 +3030,7 @@ class HASPmota
|
||||
# load from JSONL
|
||||
self._load(templ_name)
|
||||
self.started = true
|
||||
log("HSP: HASPmota initialized")
|
||||
end
|
||||
|
||||
#################################################################################
|
||||
@ -2970,6 +3052,12 @@ class HASPmota
|
||||
return l
|
||||
end
|
||||
|
||||
#################################################################################
|
||||
# Antiburn
|
||||
#################################################################################
|
||||
def antiburn()
|
||||
self.Antiburn().start()
|
||||
end
|
||||
|
||||
#####################################################################
|
||||
# General Setters and Getters
|
||||
@ -3014,6 +3102,7 @@ class HASPmota
|
||||
var jline = json.load(line)
|
||||
if type(jline) == 'instance'
|
||||
if tasmota.loglevel(4)
|
||||
if string.endswith(line, "\n") line = line[0..-2] end # remove unwanted last '\n'
|
||||
tasmota.log(f"HSP: parsing line '{line}'", 4)
|
||||
end
|
||||
self.parse_page(jline) # parse page first to create any page related objects, may change self.lvh_page_cur_idx_parsing
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user