mirror of https://github.com/arendst/Tasmota.git
LVGL OpenHASP alpha 4
This commit is contained in:
parent
a2020a8ec8
commit
cb27f53816
|
@ -123,8 +123,8 @@ be_local_closure(every_second, /* name */
|
|||
********************************************************************/
|
||||
be_local_closure(init, /* name */
|
||||
be_nested_proto(
|
||||
12, /* nstack */
|
||||
3, /* argc */
|
||||
11, /* nstack */
|
||||
2, /* argc */
|
||||
0, /* varg */
|
||||
0, /* has upvals */
|
||||
NULL, /* no upvals */
|
||||
|
@ -157,90 +157,89 @@ be_local_closure(init, /* name */
|
|||
}),
|
||||
(be_nested_const_str("init", 380752755, 4)),
|
||||
(be_nested_const_str("input", -103256197, 5)),
|
||||
( &(const binstruction[83]) { /* code */
|
||||
0x600C0003, // 0000 GETGBL R3 G3
|
||||
0x5C100000, // 0001 MOVE R4 R0
|
||||
0x7C0C0200, // 0002 CALL R3 1
|
||||
0x8C0C0700, // 0003 GETMET R3 R3 K0
|
||||
0x5C140200, // 0004 MOVE R5 R1
|
||||
0x5C180400, // 0005 MOVE R6 R2
|
||||
0x7C0C0600, // 0006 CALL R3 3
|
||||
0xB80E0200, // 0007 GETNGBL R3 K1
|
||||
0x8C0C0702, // 0008 GETMET R3 R3 K2
|
||||
0x5416000F, // 0009 LDINT R5 16
|
||||
0x7C0C0400, // 000A CALL R3 2
|
||||
0x4C100000, // 000B LDNIL R4
|
||||
0x20100604, // 000C NE R4 R3 R4
|
||||
0x78120007, // 000D JMPF R4 #0016
|
||||
0x8C100103, // 000E GETMET R4 R0 K3
|
||||
0x5C180600, // 000F MOVE R6 R3
|
||||
0xB81E0200, // 0010 GETNGBL R7 K1
|
||||
0x881C0F04, // 0011 GETMBR R7 R7 K4
|
||||
0xB8220200, // 0012 GETNGBL R8 K1
|
||||
0x88201105, // 0013 GETMBR R8 R8 K5
|
||||
0x301C0E08, // 0014 OR R7 R7 R8
|
||||
0x7C100600, // 0015 CALL R4 3
|
||||
0x4C100000, // 0016 LDNIL R4
|
||||
0x20100204, // 0017 NE R4 R1 R4
|
||||
0x78120034, // 0018 JMPF R4 #004E
|
||||
0x8C100306, // 0019 GETMET R4 R1 K6
|
||||
0x7C100200, // 001A CALL R4 1
|
||||
0x8C140107, // 001B GETMET R5 R0 K7
|
||||
0x581C0008, // 001C LDCONST R7 K8
|
||||
0x7C140400, // 001D CALL R5 2
|
||||
0x8C140109, // 001E GETMET R5 R0 K9
|
||||
0x7C140200, // 001F CALL R5 1
|
||||
0x8C14010A, // 0020 GETMET R5 R0 K10
|
||||
0x7C140200, // 0021 CALL R5 1
|
||||
0x8C18010B, // 0022 GETMET R6 R0 K11
|
||||
0x8C200306, // 0023 GETMET R8 R1 K6
|
||||
0x7C200200, // 0024 CALL R8 1
|
||||
0x8C240106, // 0025 GETMET R9 R0 K6
|
||||
0x7C240200, // 0026 CALL R9 1
|
||||
0x04201009, // 0027 SUB R8 R8 R9
|
||||
0x0C20110C, // 0028 DIV R8 R8 K12
|
||||
0x7C180400, // 0029 CALL R6 2
|
||||
0x8C18030D, // 002A GETMET R6 R1 K13
|
||||
0xB8220200, // 002B GETNGBL R8 K1
|
||||
0x88201104, // 002C GETMBR R8 R8 K4
|
||||
0xB8260200, // 002D GETNGBL R9 K1
|
||||
0x88241305, // 002E GETMBR R9 R9 K5
|
||||
0x30201009, // 002F OR R8 R8 R9
|
||||
0x7C180400, // 0030 CALL R6 2
|
||||
0x8C1C010E, // 0031 GETMET R7 R0 K14
|
||||
0x8C24030A, // 0032 GETMET R9 R1 K10
|
||||
0x7C240200, // 0033 CALL R9 1
|
||||
0x04241205, // 0034 SUB R9 R9 R5
|
||||
0x04241206, // 0035 SUB R9 R9 R6
|
||||
0x0424130F, // 0036 SUB R9 R9 K15
|
||||
0x7C1C0400, // 0037 CALL R7 2
|
||||
0x8C1C0310, // 0038 GETMET R7 R1 K16
|
||||
0x00240C05, // 0039 ADD R9 R6 R5
|
||||
0x542A0005, // 003A LDINT R10 6
|
||||
0x0024120A, // 003B ADD R9 R9 R10
|
||||
0xB82A0200, // 003C GETNGBL R10 K1
|
||||
0x88281504, // 003D GETMBR R10 R10 K4
|
||||
0xB82E0200, // 003E GETNGBL R11 K1
|
||||
0x882C1705, // 003F GETMBR R11 R11 K5
|
||||
0x3028140B, // 0040 OR R10 R10 R11
|
||||
0x7C1C0600, // 0041 CALL R7 3
|
||||
0x8C1C0111, // 0042 GETMET R7 R0 K17
|
||||
0xB8260200, // 0043 GETNGBL R9 K1
|
||||
0x8C241312, // 0044 GETMET R9 R9 K18
|
||||
0xB82E0200, // 0045 GETNGBL R11 K1
|
||||
0x882C1713, // 0046 GETMBR R11 R11 K19
|
||||
0x7C240400, // 0047 CALL R9 2
|
||||
0xB82A0200, // 0048 GETNGBL R10 K1
|
||||
0x88281504, // 0049 GETMBR R10 R10 K4
|
||||
0xB82E0200, // 004A GETNGBL R11 K1
|
||||
0x882C1705, // 004B GETMBR R11 R11 K5
|
||||
0x3028140B, // 004C OR R10 R10 R11
|
||||
0x7C1C0600, // 004D CALL R7 3
|
||||
0xB8122800, // 004E GETNGBL R4 K20
|
||||
0x8C100915, // 004F GETMET R4 R4 K21
|
||||
0x5C180000, // 0050 MOVE R6 R0
|
||||
0x7C100400, // 0051 CALL R4 2
|
||||
0x80000000, // 0052 RET 0
|
||||
( &(const binstruction[82]) { /* code */
|
||||
0x60080003, // 0000 GETGBL R2 G3
|
||||
0x5C0C0000, // 0001 MOVE R3 R0
|
||||
0x7C080200, // 0002 CALL R2 1
|
||||
0x8C080500, // 0003 GETMET R2 R2 K0
|
||||
0x5C100200, // 0004 MOVE R4 R1
|
||||
0x7C080400, // 0005 CALL R2 2
|
||||
0xB80A0200, // 0006 GETNGBL R2 K1
|
||||
0x8C080502, // 0007 GETMET R2 R2 K2
|
||||
0x5412000F, // 0008 LDINT R4 16
|
||||
0x7C080400, // 0009 CALL R2 2
|
||||
0x4C0C0000, // 000A LDNIL R3
|
||||
0x200C0403, // 000B NE R3 R2 R3
|
||||
0x780E0007, // 000C JMPF R3 #0015
|
||||
0x8C0C0103, // 000D GETMET R3 R0 K3
|
||||
0x5C140400, // 000E MOVE R5 R2
|
||||
0xB81A0200, // 000F GETNGBL R6 K1
|
||||
0x88180D04, // 0010 GETMBR R6 R6 K4
|
||||
0xB81E0200, // 0011 GETNGBL R7 K1
|
||||
0x881C0F05, // 0012 GETMBR R7 R7 K5
|
||||
0x30180C07, // 0013 OR R6 R6 R7
|
||||
0x7C0C0600, // 0014 CALL R3 3
|
||||
0x4C0C0000, // 0015 LDNIL R3
|
||||
0x200C0203, // 0016 NE R3 R1 R3
|
||||
0x780E0034, // 0017 JMPF R3 #004D
|
||||
0x8C0C0306, // 0018 GETMET R3 R1 K6
|
||||
0x7C0C0200, // 0019 CALL R3 1
|
||||
0x8C100107, // 001A GETMET R4 R0 K7
|
||||
0x58180008, // 001B LDCONST R6 K8
|
||||
0x7C100400, // 001C CALL R4 2
|
||||
0x8C100109, // 001D GETMET R4 R0 K9
|
||||
0x7C100200, // 001E CALL R4 1
|
||||
0x8C10010A, // 001F GETMET R4 R0 K10
|
||||
0x7C100200, // 0020 CALL R4 1
|
||||
0x8C14010B, // 0021 GETMET R5 R0 K11
|
||||
0x8C1C0306, // 0022 GETMET R7 R1 K6
|
||||
0x7C1C0200, // 0023 CALL R7 1
|
||||
0x8C200106, // 0024 GETMET R8 R0 K6
|
||||
0x7C200200, // 0025 CALL R8 1
|
||||
0x041C0E08, // 0026 SUB R7 R7 R8
|
||||
0x0C1C0F0C, // 0027 DIV R7 R7 K12
|
||||
0x7C140400, // 0028 CALL R5 2
|
||||
0x8C14030D, // 0029 GETMET R5 R1 K13
|
||||
0xB81E0200, // 002A GETNGBL R7 K1
|
||||
0x881C0F04, // 002B GETMBR R7 R7 K4
|
||||
0xB8220200, // 002C GETNGBL R8 K1
|
||||
0x88201105, // 002D GETMBR R8 R8 K5
|
||||
0x301C0E08, // 002E OR R7 R7 R8
|
||||
0x7C140400, // 002F CALL R5 2
|
||||
0x8C18010E, // 0030 GETMET R6 R0 K14
|
||||
0x8C20030A, // 0031 GETMET R8 R1 K10
|
||||
0x7C200200, // 0032 CALL R8 1
|
||||
0x04201004, // 0033 SUB R8 R8 R4
|
||||
0x04201005, // 0034 SUB R8 R8 R5
|
||||
0x0420110F, // 0035 SUB R8 R8 K15
|
||||
0x7C180400, // 0036 CALL R6 2
|
||||
0x8C180310, // 0037 GETMET R6 R1 K16
|
||||
0x00200A04, // 0038 ADD R8 R5 R4
|
||||
0x54260005, // 0039 LDINT R9 6
|
||||
0x00201009, // 003A ADD R8 R8 R9
|
||||
0xB8260200, // 003B GETNGBL R9 K1
|
||||
0x88241304, // 003C GETMBR R9 R9 K4
|
||||
0xB82A0200, // 003D GETNGBL R10 K1
|
||||
0x88281505, // 003E GETMBR R10 R10 K5
|
||||
0x3024120A, // 003F OR R9 R9 R10
|
||||
0x7C180600, // 0040 CALL R6 3
|
||||
0x8C180111, // 0041 GETMET R6 R0 K17
|
||||
0xB8220200, // 0042 GETNGBL R8 K1
|
||||
0x8C201112, // 0043 GETMET R8 R8 K18
|
||||
0xB82A0200, // 0044 GETNGBL R10 K1
|
||||
0x88281513, // 0045 GETMBR R10 R10 K19
|
||||
0x7C200400, // 0046 CALL R8 2
|
||||
0xB8260200, // 0047 GETNGBL R9 K1
|
||||
0x88241304, // 0048 GETMBR R9 R9 K4
|
||||
0xB82A0200, // 0049 GETNGBL R10 K1
|
||||
0x88281505, // 004A GETMBR R10 R10 K5
|
||||
0x3024120A, // 004B OR R9 R9 R10
|
||||
0x7C180600, // 004C CALL R6 3
|
||||
0xB80E2800, // 004D GETNGBL R3 K20
|
||||
0x8C0C0715, // 004E GETMET R3 R3 K21
|
||||
0x5C140000, // 004F MOVE R5 R0
|
||||
0x7C0C0400, // 0050 CALL R3 2
|
||||
0x80000000, // 0051 RET 0
|
||||
})
|
||||
)
|
||||
);
|
||||
|
|
|
@ -18,7 +18,6 @@ extern int lco_init(bvm *vm); // generic function
|
|||
extern int lco_tostring(bvm *vm); // generic function
|
||||
extern int lco_toint(bvm *vm); // generic function
|
||||
|
||||
extern int lvx_init_ctor(bvm *vm, void * func);
|
||||
extern int lvx_member(bvm *vm);
|
||||
extern int lvx_tostring(bvm *vm); // generic function
|
||||
|
||||
|
@ -838,6 +837,38 @@ extern int be_ntv_lv_switch_init(bvm *vm);
|
|||
extern int be_ntv_lv_table_init(bvm *vm);
|
||||
extern int be_ntv_lv_textarea_init(bvm *vm);
|
||||
|
||||
extern const bclass be_class_lv_arc;
|
||||
extern const bclass be_class_lv_bar;
|
||||
extern const bclass be_class_lv_btn;
|
||||
extern const bclass be_class_lv_btnmatrix;
|
||||
extern const bclass be_class_lv_canvas;
|
||||
extern const bclass be_class_lv_chart;
|
||||
extern const bclass be_class_lv_checkbox;
|
||||
extern const bclass be_class_lv_color;
|
||||
extern const bclass be_class_lv_colorwheel;
|
||||
extern const bclass be_class_lv_disp;
|
||||
extern const bclass be_class_lv_dropdown;
|
||||
extern const bclass be_class_lv_font;
|
||||
extern const bclass be_class_lv_group;
|
||||
extern const bclass be_class_lv_img;
|
||||
extern const bclass be_class_lv_imgbtn;
|
||||
extern const bclass be_class_lv_indev;
|
||||
extern const bclass be_class_lv_label;
|
||||
extern const bclass be_class_lv_led;
|
||||
extern const bclass be_class_lv_line;
|
||||
extern const bclass be_class_lv_meter;
|
||||
extern const bclass be_class_lv_msgbox;
|
||||
extern const bclass be_class_lv_obj;
|
||||
extern const bclass be_class_lv_roller;
|
||||
extern const bclass be_class_lv_slider;
|
||||
extern const bclass be_class_lv_spinbox;
|
||||
extern const bclass be_class_lv_spinner;
|
||||
extern const bclass be_class_lv_style;
|
||||
extern const bclass be_class_lv_switch;
|
||||
extern const bclass be_class_lv_table;
|
||||
extern const bclass be_class_lv_textarea;
|
||||
extern const bclass be_class_lv_theme;
|
||||
|
||||
|
||||
/********************************************************************
|
||||
** Solidified class: lv_style
|
||||
|
@ -1182,7 +1213,7 @@ void be_load_lv_msgbox_class(bvm *vm) {
|
|||
extern const bclass be_class_lv_obj;
|
||||
be_local_class(lv_spinbox,
|
||||
0,
|
||||
&be_class_lv_obj,
|
||||
&be_class_lv_textarea,
|
||||
be_nested_map(2,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_nested_key("_class", -1562820946, 6, -1), be_const_comptr(&lv_spinbox_class) },
|
||||
|
@ -1204,7 +1235,7 @@ void be_load_lv_spinbox_class(bvm *vm) {
|
|||
extern const bclass be_class_lv_obj;
|
||||
be_local_class(lv_spinner,
|
||||
0,
|
||||
&be_class_lv_obj,
|
||||
&be_class_lv_arc,
|
||||
be_nested_map(2,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_nested_key("_class", -1562820946, 6, -1), be_const_comptr(&lv_spinner_class) },
|
||||
|
@ -1314,7 +1345,7 @@ void be_load_lv_btnmatrix_class(bvm *vm) {
|
|||
extern const bclass be_class_lv_obj;
|
||||
be_local_class(lv_canvas,
|
||||
0,
|
||||
&be_class_lv_obj,
|
||||
&be_class_lv_img,
|
||||
be_nested_map(2,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {
|
||||
{ be_nested_key("_class", -1562820946, 6, -1), be_const_comptr(&lv_canvas_class) },
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
class lv_clock_icon: lv.label
|
||||
var hour, minute, sec
|
||||
|
||||
def init(parent, copy)
|
||||
super(self).init(parent, copy)
|
||||
def init(parent)
|
||||
super(self).init(parent)
|
||||
var f_s7_16 = lv.seg7_font(16)
|
||||
if f_s7_16 != nil self.set_style_text_font(f_s7_16, lv.PART_MAIN | lv.STATE_DEFAULT) end
|
||||
|
||||
|
|
|
@ -25,6 +25,14 @@ lv.theme_apply(lv.layer_top())
|
|||
lv.layer_top().set_style_bg_opa(0,0)
|
||||
|
||||
|
||||
# takes an attribute name and responds if it needs color conversion
|
||||
def is_color_attribute(t)
|
||||
import string
|
||||
t = str(t)
|
||||
# contains `color` but does not contain `color_`
|
||||
return (string.find(t, "color") >= 0) && (string.find(t, "color_") < 0)
|
||||
end
|
||||
|
||||
# parse hex string
|
||||
def parse_hex(s)
|
||||
import string
|
||||
|
@ -81,6 +89,8 @@ class lvh_obj
|
|||
"obj",
|
||||
"page",
|
||||
"comment",
|
||||
"parentid",
|
||||
"auto_size", # TODO not sure it's still needed in LVGL8
|
||||
]
|
||||
#- mapping from OpenHASP attribute to LVGL attribute -#
|
||||
#- if mapping is null, we use set_X and get_X from our own class -#
|
||||
|
@ -100,6 +110,8 @@ class lvh_obj
|
|||
"border_side": "style_border_side",
|
||||
"bg_opa": "style_bg_opa",
|
||||
"border_width": "style_border_width",
|
||||
"line_width": nil, # depebds on class
|
||||
"line_width1": nil, # depebds on class
|
||||
"action": nil, # store the action in self._action
|
||||
"hidden": nil, # apply to self
|
||||
"enabled": nil, # apply to self
|
||||
|
@ -127,6 +139,9 @@ class lvh_obj
|
|||
"src": "src",
|
||||
"image_recolor": "style_img_recolor",
|
||||
"image_recolor_opa": "style_img_recolor_opa",
|
||||
# spinner
|
||||
"angle": nil,
|
||||
"speed": nil,
|
||||
# padding of knob
|
||||
"pad_top2": nil,
|
||||
"pad_bottom2": nil,
|
||||
|
@ -142,7 +157,9 @@ class lvh_obj
|
|||
|
||||
# init
|
||||
# - create the LVGL encapsulated object
|
||||
def init(parent)
|
||||
# arg1: parent object
|
||||
# arg2: json line object
|
||||
def init(parent, jline)
|
||||
var obj_class = self._lv_class # need to assign to a var to distinguish from method call
|
||||
self._lv_obj = obj_class(parent) # instanciate LVGL object
|
||||
self.post_init()
|
||||
|
@ -164,6 +181,13 @@ class lvh_obj
|
|||
return self._action()
|
||||
end
|
||||
|
||||
def set_line_width(t)
|
||||
self._lv_obj.set_style_line_width(int(t), lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
end
|
||||
def get_line_width()
|
||||
return self._lv_obj.get_style_line_width(lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
end
|
||||
|
||||
#- ------------------------------------------------------------
|
||||
Mapping of synthetic attributes
|
||||
- text
|
||||
|
@ -236,7 +260,7 @@ class lvh_obj
|
|||
|
||||
def set_text(t)
|
||||
self.check_label()
|
||||
self._lv_label.set_text(t)
|
||||
self._lv_label.set_text(str(t))
|
||||
end
|
||||
def set_value_str(t) self.set_text(t) end
|
||||
|
||||
|
@ -279,11 +303,10 @@ class lvh_obj
|
|||
if f != nil
|
||||
self._lv_label.set_style_text_font(f, lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
else
|
||||
print("HSP: Unsupported font size: robotocondensed-latin1", self._text_font)
|
||||
print("HSP: Unsupported font size: robotocondensed-latin1", t)
|
||||
end
|
||||
end
|
||||
def get_text_font()
|
||||
return self._text_font
|
||||
end
|
||||
def set_value_font(t) self.set_text_font(t) end
|
||||
def get_value_font() return self.get_text_font() end
|
||||
|
@ -412,7 +435,7 @@ class lvh_obj
|
|||
if kv
|
||||
var f = introspect.get(self._lv_obj, "set_" + kv)
|
||||
# if the attribute contains 'color', convert to lv_color
|
||||
if type(kv) == 'string' && string.find(kv, "color") + 5 == size(kv) # endswith 'color'
|
||||
if type(kv) == 'string' && is_color_attribute(kv)
|
||||
v = parse_color(v)
|
||||
end
|
||||
# print("f=", f, v, kv, self._lv_obj, self)
|
||||
|
@ -444,6 +467,13 @@ class lvh_obj
|
|||
end
|
||||
end
|
||||
|
||||
#- ------------------------------------------------------------
|
||||
Other widgets
|
||||
- ------------------------------------------------------------ -#
|
||||
|
||||
#- ------------------------------------------------------------
|
||||
label
|
||||
#- ------------------------------------------------------------#
|
||||
class lvh_label : lvh_obj
|
||||
static _lv_class = lv.label
|
||||
# label do not need a sub-label
|
||||
|
@ -452,10 +482,27 @@ class lvh_label : lvh_obj
|
|||
end
|
||||
end
|
||||
|
||||
#- ------------------------------------------------------------
|
||||
arc
|
||||
#- ------------------------------------------------------------#
|
||||
class lvh_arc : lvh_obj
|
||||
static _lv_class = lv.arc
|
||||
static _lv_part2_selector = lv.PART_KNOB
|
||||
|
||||
# line_width converts to arc_width
|
||||
def set_line_width(t)
|
||||
self._lv_obj.set_style_arc_width(int(t), lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
end
|
||||
def get_line_width()
|
||||
return self._lv_obj.get_arc_line_width(lv.PART_MAIN | lv.STATE_DEFAULT)
|
||||
end
|
||||
def set_line_width1(t)
|
||||
self._lv_obj.set_style_arc_width(int(t), lv.PART_INDICATOR | lv.STATE_DEFAULT)
|
||||
end
|
||||
def get_line_width1()
|
||||
return self._lv_obj.get_arc_line_width(lv.PART_INDICATOR | lv.STATE_DEFAULT)
|
||||
end
|
||||
|
||||
def set_min(t)
|
||||
self._lv_obj.set_range(int(t), self.get_max())
|
||||
end
|
||||
|
@ -500,11 +547,38 @@ class lvh_arc : lvh_obj
|
|||
|
||||
end
|
||||
|
||||
#- ------------------------------------------------------------
|
||||
switch
|
||||
#- ------------------------------------------------------------#
|
||||
class lvh_switch : lvh_obj
|
||||
static _lv_class = lv.switch
|
||||
static _lv_part2_selector = lv.PART_KNOB
|
||||
end
|
||||
|
||||
#- ------------------------------------------------------------
|
||||
spinner
|
||||
#- ------------------------------------------------------------#
|
||||
class lvh_spinner : lvh_arc
|
||||
static _lv_class = lv.spinner
|
||||
|
||||
# init
|
||||
# - create the LVGL encapsulated object
|
||||
# arg1: parent object
|
||||
# arg2: json line object
|
||||
def init(parent, jline)
|
||||
var angle = jline.find("angle", 60)
|
||||
var speed = jline.find("speed", 1000)
|
||||
self._lv_obj = lv.spinner(parent, speed, angle)
|
||||
self.post_init()
|
||||
end
|
||||
|
||||
# ignore attributes, spinner can't be changed once created
|
||||
def set_angle(t) end
|
||||
def get_angle() end
|
||||
def set_speed(t) end
|
||||
def get_speed() end
|
||||
end
|
||||
|
||||
#- creat sub-classes of lvh_obj and map the LVGL class in static '_lv_class' attribute -#
|
||||
class lvh_bar : lvh_obj static _lv_class = lv.bar end
|
||||
class lvh_btn : lvh_obj static _lv_class = lv.btn end
|
||||
|
@ -515,7 +589,6 @@ class lvh_img : lvh_obj static _lv_class = lv.img end
|
|||
class lvh_line : lvh_obj static _lv_class = lv.line end
|
||||
class lvh_roller : lvh_obj static _lv_class = lv.roller end
|
||||
class lvh_slider : lvh_obj static _lv_class = lv.slider end
|
||||
class lvh_spinner : lvh_obj static _lv_class = lv.spinner end
|
||||
class lvh_textarea : lvh_obj static _lv_class = lv.textarea end
|
||||
|
||||
#- ----------------------------------------------------------------------------
|
||||
|
@ -542,7 +615,8 @@ class lvh_page
|
|||
self._lv_scr = lv.layer_top() # top layer, visible over all screens
|
||||
else
|
||||
self._lv_scr = lv.obj(0) # allocate a new screen
|
||||
self._lv_scr.set_style_bg_color(lv.color(0x000000), lv.PART_MAIN | lv.STATE_DEFAULT) # set black background
|
||||
# self._lv_scr.set_style_bg_color(lv.color(0x000000), lv.PART_MAIN | lv.STATE_DEFAULT) # set black background
|
||||
self._lv_scr.set_style_bg_color(lv.color(0xFFFFFF), lv.PART_MAIN | lv.STATE_DEFAULT) # set white background
|
||||
end
|
||||
|
||||
# create a global for this page of form p<page_number>, ex p1
|
||||
|
@ -651,9 +725,9 @@ def parse_obj(jline, page)
|
|||
if obj_class == nil
|
||||
raise "value error", "cannot find object of type " + str(obj_type)
|
||||
end
|
||||
|
||||
|
||||
# instanciate the object, passing the lvgl screen as paren object
|
||||
var obj = obj_class(parent)
|
||||
var obj = obj_class(parent, jline)
|
||||
|
||||
# add object to page object
|
||||
lvh_page_cur.set_obj(obj_id, obj)
|
||||
|
@ -678,6 +752,7 @@ end
|
|||
Parse jsonl file line by line
|
||||
|
||||
- ------------------------------------------------------------ -#
|
||||
tasmota.yield()
|
||||
for j:jsonl
|
||||
var jline = json.load(j)
|
||||
|
||||
|
|
|
@ -0,0 +1,61 @@
|
|||
{"page":1,"comment":"---------- Page 1 ----------"}
|
||||
{"page":1,"id":0,"bg_color":"#FFFFFF","bg_grad_color":"#FFFFFF","text_color":"#000000","radius":0,"border_side":0}
|
||||
{"page":1,"id":1,"obj":"btn","x":0,"y":0,"w":240,"h":30,"text":"LIVING ROOM","value_font":24,"bg_color":"#2C3E50","bg_grad_color":"#2C3E50","text_color":"#FFFFFF","radius":0,"border_side":0}
|
||||
|
||||
{"page":1,"id":2,"obj":"arc","x":20,"y":65,"w":80,"h":100,"max":40,"border_side":0,"type":0,"rotation":0,"start_angle":180,"end_angle":0,"start_angle1":180,"value_font":12,"value_ofs_x":0,"value_ofs_y":-14,"bg_opa":0,"text":"21.2°C","min":-20,"max":50,"val":21}
|
||||
|
||||
{"page":1,"id":3,"obj":"arc","x":140,"y":65,"w":80,"h":100,"max":100,"border_side":0,"type":0,"start_angle":180,"end_angle":0,"start_angle1":180,"value_font":12,"value_color":"#000000","value_ofs_x":0,"value_ofs_y":-14,"bg_opa":0,"text":"44%","val":44}
|
||||
|
||||
{"page":1,"id":4,"obj":"label","x":0,"y":120,"w":240,"h":20,"text":"CO2 levels: 1483 ppm","radius":0,"border_side":0,"align":1}
|
||||
{"page":1,"id":5,"obj":"label","x":2,"y":35,"w":140,"text":"Temperature","align":1}
|
||||
{"page":1,"id":6,"obj":"label","x":140,"y":35,"w":95,"text":"Humidity","align":1}
|
||||
{"page":1,"id":7,"obj":"btn","x":0,"y":160,"w":240,"h":20,"text":"LIGHTS","bg_color":"#F1C40F","text_color":"#FFFFFF","radius":0,"border_side":0}
|
||||
{"page":1,"id":8,"obj":"label","x":20,"y":190,"w":140,"h":20,"text":"Ceiling Light"}
|
||||
{"page":1,"id":9,"obj":"switch","x":160,"y":190,"w":40,"h":20,"toggle":"TRUE"}
|
||||
{"page":1,"id":10,"obj":"label","x":20,"y":215,"w":140,"h":20,"text":"Wall Light"}
|
||||
{"page":1,"id":11,"obj":"switch","x":160,"y":215,"w":40,"h":20,"toggle":"TRUE"}
|
||||
{"page":1,"id":12,"obj":"label","x":20,"y":240,"w":200,"h":20,"text":"Ambient Light"}
|
||||
{"page":1,"id":13,"obj":"slider","x":30,"y":265,"w":200,"h":10}
|
||||
|
||||
{"page":2,"comment":"---------- Page 2 ----------"}
|
||||
{"page":2,"id":1,"obj":"btn","x":0,"y":0,"w":240,"h":30,"text":"ENTITIES","value_font":24,"bg_color":"#2C3E50","text_color":"#FFFFFF","radius":0,"border_side":0,"click":0}
|
||||
{"page":2,"id":2,"obj":"obj","x":5,"y":35,"w":230,"h":250,"click":0}
|
||||
|
||||
{"page":2,"id":11,"obj":"label","x":8,"y":33,"w":35,"h":35,"text":"\uE004","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":2,"id":12,"obj":"label","x":48,"y":43,"w":130,"h":30,"text":"Presence override","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":2,"id":13,"obj":"switch","x":177,"y":40,"w":50,"h":25,"radius":25,"radius2":15}
|
||||
|
||||
{"page":2,"id":21,"obj":"label","x":8,"y":69,"w":35,"h":35,"text":"\uF020","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":2,"id":22,"obj":"label","x":48,"y":79,"w":130,"h":30,"text":"Front door light","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":2,"id":23,"obj":"switch","x":177,"y":74,"w":50,"h":25,"radius":25,"radius2":15}
|
||||
|
||||
{"page":2,"id":31,"obj":"label","x":8,"y":103,"w":35,"h":35,"text":"\uF054","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":2,"id":32,"obj":"label","x":48,"y":113,"w":130,"h":30,"text":"Back yard lights","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":2,"id":33,"obj":"switch","x":177,"y":110,"w":50,"h":25,"radius":25,"radius2":15}
|
||||
|
||||
{"page":2,"id":41,"obj":"label","x":8,"y":138,"w":35,"h":35,"text":"\uEA7A","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":2,"id":42,"obj":"label","x":48,"y":148,"w":130,"h":30,"text":"Trash service","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":2,"id":43,"obj":"label","x":97,"y":148,"w":130,"h":30,"text":"in 6 days","align":2,"text_color":"black"}
|
||||
|
||||
{"page":2,"id":51,"obj":"label","x":8,"y":173,"w":35,"h":35,"text":"\uF39D","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":2,"id":52,"obj":"label","x":48,"y":183,"w":130,"h":30,"text":"Selective trash","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":2,"id":53,"obj":"label","x":97,"y":183,"w":130,"h":30,"text":"in 10 days","align":2,"text_color":"black"}
|
||||
|
||||
{"page":2,"id":61,"obj":"label","x":8,"y":208,"w":35,"h":35,"text":"\uE32A","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":2,"id":62,"obj":"label","x":48,"y":218,"w":130,"h":30,"text":"Green energy active","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":2,"id":63,"obj":"label","x":97,"y":218,"w":130,"h":30,"text":"Yes :)","align":2,"text_color":"black"}
|
||||
|
||||
{"page":2,"id":71,"obj":"label","x":8,"y":243,"w":35,"h":35,"text":"\uE957","align":1,"text_font":32,"text_color":"black"}
|
||||
{"page":2,"id":72,"obj":"label","x":48,"y":253,"w":130,"h":30,"text":"Air quality","align":0,"text_font":16,"text_color":"black"}
|
||||
{"page":2,"id":73,"obj":"label","x":97,"y":253,"w":130,"h":30,"text":"OK (29.58 µg/m³)","align":2,"text_color":"black"}
|
||||
|
||||
{"page":3,"comment":"---------- Page 3 ----------"}
|
||||
{"page":3,"id":1,"obj":"btn","x":0,"y":0,"w":240,"h":30,"text":"FAN STATUS","text_font":16,"bg_color":"#2C3E50","text_color":"#FFFFFF","radius":0,"border_side":0,"click":0}
|
||||
|
||||
{"page":3,"id":11,"obj":"img","src":"A:/noun_Fan_35097_140.png","auto_size":1,"w":140,"h":140,"x":50,"y":75,"image_recolor":"lime","image_recolor_opa":150}
|
||||
{"page":3,"id":12,"obj":"spinner","parentid":11,"x":7,"y":6,"w":126,"h":126,"bg_opa":0,"border_width":0,"line_width":7,"line_width1":7,"type":2,"angle":120,"speed":1000,"value_str":3,"value_font":24}
|
||||
|
||||
{"page":0,"comment":"---------- All pages ----------"}
|
||||
{"page":0,"id":11,"obj":"btn","action":"prev","x":0,"y":290,"w":79,"h":32,"bg_color":"#34495E","text":"\uE141","text_color":"#CCCCCC","radius":0,"border_side":0,"text_font":32}
|
||||
{"page":0,"id":12,"obj":"btn","action":"back","x":80,"y":290,"w":80,"h":32,"bg_color":"#34495E","text":"\uE2DC","text_color":"#CCCCCC","radius":0,"border_side":0,"text_font":24}
|
||||
{"page":0,"id":13,"obj":"btn","action":"next","x":161,"y":290,"w":79,"h":32,"bg_color":"#34495E","text":"\uE142","text_color":"#CCCCCC","radius":0,"border_side":0,"text_font":32}
|
|
@ -0,0 +1,4 @@
|
|||
{"page":1,"id":1,"obj":"btn","x":0,"y":0,"w":240,"h":30,"text":"FAN STATUS","text_font":16,"bg_color":"#2C3E50","text_color":"#FFFFFF","radius":0,"border_side":0,"click":0}
|
||||
|
||||
{"page":1,"id":11,"obj":"img","src":"A:/noun_Fan_35097_140.png","auto_size":1,"w":140,"h":140,"x":50,"y":75,"image_recolor":"lime","image_recolor_opa":150}
|
||||
{"page":1,"id":12,"obj":"spinner","parentid":11,"x":7,"y":6,"w":126,"h":126,"bg_opa":0,"border_width":0,"line_width":7,"line_width1":7,"type":2,"angle":120,"speed":1000,"value_str":3,"value_font":24}
|
|
@ -988,101 +988,101 @@ const size_t lv_classes_size = sizeof(lv_classes) / sizeof(lv_classes[0]);
|
|||
/* `lv_theme` methods */
|
||||
/* `lv_img` methods */
|
||||
#ifdef BE_LV_WIDGET_IMG
|
||||
int be_ntv_lv_img_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_img_create, "+lv.lv_img", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_img_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_img_create, "+", "(lv.lv_obj)"); }
|
||||
#endif // BE_LV_WIDGET_IMG
|
||||
/* `lv_disp` methods */
|
||||
/* `lv_obj` methods */
|
||||
int be_ntv_lv_obj_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_obj_create, "+lv.lv_obj", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_obj_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_obj_create, "+", "(lv.lv_obj)"); }
|
||||
/* `lv_group` methods */
|
||||
int be_ntv_lv_group_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_group_create, "+lv.lv_group", ""); }
|
||||
int be_ntv_lv_group_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_group_create, "+", ""); }
|
||||
/* `lv_indev` methods */
|
||||
/* `lv_chart` methods */
|
||||
#ifdef BE_LV_WIDGET_CHART
|
||||
int be_ntv_lv_chart_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_chart_create, "+lv.lv_chart", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_chart_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_chart_create, "+", "(lv.lv_obj)"); }
|
||||
#endif // BE_LV_WIDGET_CHART
|
||||
/* `lv_colorwheel` methods */
|
||||
#ifdef BE_LV_WIDGET_COLORWHEEL
|
||||
int be_ntv_lv_colorwheel_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_colorwheel_create, "+lv.lv_colorwheel", "(lv.lv_obj)b"); }
|
||||
int be_ntv_lv_colorwheel_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_colorwheel_create, "+", "(lv.lv_obj)b"); }
|
||||
#endif // BE_LV_WIDGET_COLORWHEEL
|
||||
/* `lv_imgbtn` methods */
|
||||
#ifdef BE_LV_WIDGET_IMGBTN
|
||||
int be_ntv_lv_imgbtn_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_imgbtn_create, "+lv.lv_imgbtn", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_imgbtn_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_imgbtn_create, "+", "(lv.lv_obj)"); }
|
||||
#endif // BE_LV_WIDGET_IMGBTN
|
||||
/* `lv_led` methods */
|
||||
#ifdef BE_LV_WIDGET_LED
|
||||
int be_ntv_lv_led_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_led_create, "+lv.lv_led", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_led_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_led_create, "+", "(lv.lv_obj)"); }
|
||||
#endif // BE_LV_WIDGET_LED
|
||||
/* `lv_meter` methods */
|
||||
#ifdef BE_LV_WIDGET_METER
|
||||
int be_ntv_lv_meter_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_meter_create, "+lv.lv_meter", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_meter_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_meter_create, "+", "(lv.lv_obj)"); }
|
||||
#endif // BE_LV_WIDGET_METER
|
||||
/* `lv_msgbox` methods */
|
||||
#ifdef BE_LV_WIDGET_MSGBOX
|
||||
int be_ntv_lv_msgbox_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_msgbox_create, "+lv.lv_msgbox", "(lv.lv_obj)sssb"); }
|
||||
int be_ntv_lv_msgbox_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_msgbox_create, "+", "(lv.lv_obj)sssb"); }
|
||||
#endif // BE_LV_WIDGET_MSGBOX
|
||||
/* `lv_spinbox` methods */
|
||||
#ifdef BE_LV_WIDGET_SPINBOX
|
||||
int be_ntv_lv_spinbox_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_spinbox_create, "+lv.lv_spinbox", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_spinbox_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_spinbox_create, "+", "(lv.lv_obj)"); }
|
||||
#endif // BE_LV_WIDGET_SPINBOX
|
||||
/* `lv_spinner` methods */
|
||||
#ifdef BE_LV_WIDGET_SPINNER
|
||||
int be_ntv_lv_spinner_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_spinner_create, "+lv.lv_spinner", "(lv.lv_obj)ii"); }
|
||||
int be_ntv_lv_spinner_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_spinner_create, "+", "(lv.lv_obj)ii"); }
|
||||
#endif // BE_LV_WIDGET_SPINNER
|
||||
/* `lv_arc` methods */
|
||||
#ifdef BE_LV_WIDGET_ARC
|
||||
int be_ntv_lv_arc_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_arc_create, "+lv.lv_arc", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_arc_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_arc_create, "+", "(lv.lv_obj)"); }
|
||||
#endif // BE_LV_WIDGET_ARC
|
||||
/* `lv_bar` methods */
|
||||
#ifdef BE_LV_WIDGET_BAR
|
||||
int be_ntv_lv_bar_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_bar_create, "+lv.lv_bar", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_bar_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_bar_create, "+", "(lv.lv_obj)"); }
|
||||
#endif // BE_LV_WIDGET_BAR
|
||||
/* `lv_btn` methods */
|
||||
#ifdef BE_LV_WIDGET_BTN
|
||||
int be_ntv_lv_btn_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_btn_create, "+lv.lv_btn", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_btn_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_btn_create, "+", "(lv.lv_obj)"); }
|
||||
#endif // BE_LV_WIDGET_BTN
|
||||
/* `lv_btnmatrix` methods */
|
||||
#ifdef BE_LV_WIDGET_BTNMATRIX
|
||||
int be_ntv_lv_btnmatrix_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_btnmatrix_create, "+lv.lv_btnmatrix", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_btnmatrix_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_btnmatrix_create, "+", "(lv.lv_obj)"); }
|
||||
#endif // BE_LV_WIDGET_BTNMATRIX
|
||||
/* `lv_canvas` methods */
|
||||
#ifdef BE_LV_WIDGET_CANVAS
|
||||
int be_ntv_lv_canvas_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_canvas_create, "+lv.lv_canvas", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_canvas_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_canvas_create, "+", "(lv.lv_obj)"); }
|
||||
#endif // BE_LV_WIDGET_CANVAS
|
||||
/* `lv_checkbox` methods */
|
||||
#ifdef BE_LV_WIDGET_CHECKBOX
|
||||
int be_ntv_lv_checkbox_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_checkbox_create, "+lv.lv_checkbox", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_checkbox_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_checkbox_create, "+", "(lv.lv_obj)"); }
|
||||
#endif // BE_LV_WIDGET_CHECKBOX
|
||||
/* `lv_dropdown` methods */
|
||||
#ifdef BE_LV_WIDGET_DROPDOWN
|
||||
int be_ntv_lv_dropdown_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_dropdown_create, "+lv.lv_dropdown", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_dropdown_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_dropdown_create, "+", "(lv.lv_obj)"); }
|
||||
#endif // BE_LV_WIDGET_DROPDOWN
|
||||
/* `lv_label` methods */
|
||||
#ifdef BE_LV_WIDGET_LABEL
|
||||
int be_ntv_lv_label_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_label_create, "+lv.lv_label", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_label_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_label_create, "+", "(lv.lv_obj)"); }
|
||||
#endif // BE_LV_WIDGET_LABEL
|
||||
/* `lv_line` methods */
|
||||
#ifdef BE_LV_WIDGET_LINE
|
||||
int be_ntv_lv_line_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_line_create, "+lv.lv_line", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_line_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_line_create, "+", "(lv.lv_obj)"); }
|
||||
#endif // BE_LV_WIDGET_LINE
|
||||
/* `lv_roller` methods */
|
||||
#ifdef BE_LV_WIDGET_ROLLER
|
||||
int be_ntv_lv_roller_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_roller_create, "+lv.lv_roller", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_roller_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_roller_create, "+", "(lv.lv_obj)"); }
|
||||
#endif // BE_LV_WIDGET_ROLLER
|
||||
/* `lv_slider` methods */
|
||||
#ifdef BE_LV_WIDGET_SLIDER
|
||||
int be_ntv_lv_slider_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_slider_create, "+lv.lv_slider", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_slider_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_slider_create, "+", "(lv.lv_obj)"); }
|
||||
#endif // BE_LV_WIDGET_SLIDER
|
||||
/* `lv_switch` methods */
|
||||
#ifdef BE_LV_WIDGET_SWITCH
|
||||
int be_ntv_lv_switch_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_switch_create, "+lv.lv_switch", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_switch_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_switch_create, "+", "(lv.lv_obj)"); }
|
||||
#endif // BE_LV_WIDGET_SWITCH
|
||||
/* `lv_table` methods */
|
||||
#ifdef BE_LV_WIDGET_TABLE
|
||||
int be_ntv_lv_table_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_table_create, "+lv.lv_table", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_table_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_table_create, "+", "(lv.lv_obj)"); }
|
||||
#endif // BE_LV_WIDGET_TABLE
|
||||
/* `lv_textarea` methods */
|
||||
#ifdef BE_LV_WIDGET_TEXTAREA
|
||||
int be_ntv_lv_textarea_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_textarea_create, "+lv.lv_textarea", "(lv.lv_obj)"); }
|
||||
int be_ntv_lv_textarea_init(bvm *vm) { return be_call_c_func(vm, (void*) &lv_textarea_create, "+", "(lv.lv_obj)"); }
|
||||
#endif // BE_LV_WIDGET_TEXTAREA
|
||||
|
||||
// create font either empty or from parameter on stack
|
||||
|
|
|
@ -46,9 +46,11 @@ extern "C" {
|
|||
\*********************************************************************************************/
|
||||
extern "C" {
|
||||
#include "be_exec.h"
|
||||
#include "be_debug.h"
|
||||
void be_dumpstack(bvm *vm) {
|
||||
int32_t top = be_top(vm);
|
||||
AddLog(LOG_LEVEL_INFO, "BRY: top=%d", top);
|
||||
be_tracestack(vm);
|
||||
for (uint32_t i = 1; i <= top; i++) {
|
||||
const char * tname = be_typename(vm, i);
|
||||
const char * cname = be_classname(vm, i);
|
||||
|
|
|
@ -117,8 +117,8 @@ extern void lv_ex_get_started_1(void);
|
|||
// - '(lv_button)' -> lv_button class or derived
|
||||
// - '[lv_event_cb]' -> callback type, still prefixed with '^' to mark that it is cb
|
||||
//
|
||||
void be_check_arg_type(bvm *vm, int32_t argc, const char * arg_type, int32_t p[8]);
|
||||
void be_check_arg_type(bvm *vm, int32_t argc, const char * arg_type, int32_t p[8]) {
|
||||
void be_check_arg_type(bvm *vm, int32_t arg_start, int32_t argc, const char * arg_type, int32_t p[8]);
|
||||
void be_check_arg_type(bvm *vm, int32_t arg_start, int32_t argc, const char * arg_type, int32_t p[8]) {
|
||||
bool arg_type_check = (arg_type != nullptr); // is type checking activated
|
||||
int32_t arg_idx = 0; // position in arg_type string
|
||||
char type_short_name[32];
|
||||
|
@ -161,8 +161,8 @@ void be_check_arg_type(bvm *vm, int32_t argc, const char * arg_type, int32_t p[8
|
|||
break;
|
||||
}
|
||||
}
|
||||
// berry_log_P(">> be_call_c_func arg %i, type %s", i, arg_type_check ? type_short_name : "<null>");
|
||||
p[i] = be_convert_single_elt(vm, i+1, arg_type_check ? type_short_name : nullptr, p[0]);
|
||||
// AddLog(LOG_LEVEL_INFO, ">> be_call_c_func arg %i, type %s", i, arg_type_check ? type_short_name : "<null>");
|
||||
p[i] = be_convert_single_elt(vm, i + arg_start, arg_type_check ? type_short_name : nullptr, p[0]);
|
||||
}
|
||||
|
||||
// check if we are missing arguments
|
||||
|
@ -177,32 +177,6 @@ extern "C" {
|
|||
|
||||
void lv_init_set_member(bvm *vm, int index, void * ptr);
|
||||
|
||||
// called programmatically, when an object is construced
|
||||
// LVGL8: constructor now has only 1 parameter (parent)
|
||||
// If arg1 is comptr, then just encapsulate
|
||||
int lvx_init_ctor(bvm *vm, void * func);
|
||||
int lvx_init_ctor(bvm *vm, void * func) {
|
||||
int argc = be_top(vm);
|
||||
lv_obj_t * obj = nullptr;
|
||||
|
||||
if ((argc > 1) && be_iscomptr(vm, 2)) {
|
||||
obj = (lv_obj_t*) be_tocomptr(vm, 2);
|
||||
} else {
|
||||
lv_obj_t * obj1 = nullptr;
|
||||
if (argc > 1) {
|
||||
obj1 = (lv_obj_t*) be_convert_single_elt(vm, 2);
|
||||
}
|
||||
// AddLog(LOG_LEVEL_INFO, "argc %d obj1 %p obj2 %p", argc, obj1, obj2);
|
||||
fn_any_callable f = (fn_any_callable) func;
|
||||
// AddLog(LOG_LEVEL_INFO, ">> be_call_c_func(%p) - %p,%p,%p,%p,%p", f, p[0], p[1], p[2], p[3], p[4]);
|
||||
if (f) { // if f is null, just store 0x00000000
|
||||
obj = (lv_obj_t*) (*f)((int32_t)obj1, 0, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
}
|
||||
lv_init_set_member(vm, 1, obj);
|
||||
be_return_nil(vm);
|
||||
}
|
||||
|
||||
int be_call_c_func(bvm *vm, void * func, const char * return_type, const char * arg_type);
|
||||
|
||||
// native closure to call `be_call_c_func`
|
||||
|
@ -273,21 +247,41 @@ extern "C" {
|
|||
}
|
||||
|
||||
int be_call_c_func(bvm *vm, void * func, const char * return_type, const char * arg_type) {
|
||||
// AddLog(LOG_LEVEL_INFO, ">> be_call_c_func, func=%p, return_type=%s, arg_type=%s", func, return_type ? return_type : "", arg_type ? arg_type : "");
|
||||
int32_t p[8] = {0,0,0,0,0,0,0,0};
|
||||
int32_t argc = be_top(vm); // Get the number of arguments
|
||||
|
||||
// the following describe the active payload for the C function (start and count)
|
||||
// this is because the `init()` constructor first arg is not passed to the C function
|
||||
int32_t arg_start = 1; // start with standard values
|
||||
int32_t arg_count = argc;
|
||||
|
||||
// check if we call a constructor, in this case we store the return type into the new object
|
||||
// check if we call a constructor with a comptr as first arg
|
||||
if (return_type && return_type[0] == '+') {
|
||||
return_type++; // skip the leading '+'
|
||||
return lvx_init_ctor(vm, func);
|
||||
if (argc > 1 && be_iscomptr(vm, 2)) {
|
||||
lv_obj_t * obj = (lv_obj_t*) be_tocomptr(vm, 2);
|
||||
lv_init_set_member(vm, 1, obj);
|
||||
be_return_nil(vm);
|
||||
} else {
|
||||
// we need to discard the first arg
|
||||
arg_start++;
|
||||
arg_count--;
|
||||
}
|
||||
}
|
||||
|
||||
fn_any_callable f = (fn_any_callable) func;
|
||||
be_check_arg_type(vm, argc, arg_type, p);
|
||||
// berry_log_C(">> be_call_c_func(%p) - %p,%p,%p,%p,%p - %s", f, p[0], p[1], p[2], p[3], p[4], return_type ? return_type : "NULL");
|
||||
// AddLog(LOG_LEVEL_INFO, ">> before be_check_arg_type argc=%i - %i", arg_count, arg_start);
|
||||
be_check_arg_type(vm, arg_start, arg_count, arg_type, p);
|
||||
// AddLog(LOG_LEVEL_INFO, ">> be_call_c_func(%p) - %p,%p,%p,%p,%p - %s", f, p[0], p[1], p[2], p[3], p[4], return_type ? return_type : "NULL");
|
||||
int32_t ret = (*f)(p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7]);
|
||||
// AddLog(LOG_LEVEL_INFO, ">> be_call_c_func, ret = %p", ret);
|
||||
if ((return_type == nullptr) || (strlen(return_type) == 0)) { be_return_nil(vm); } // does not return
|
||||
else if (return_type[0] == '+') {
|
||||
lv_obj_t * obj = (lv_obj_t*) ret;
|
||||
lv_init_set_member(vm, 1, obj);
|
||||
be_return_nil(vm);
|
||||
}
|
||||
else if (strlen(return_type) == 1) {
|
||||
switch (return_type[0]) {
|
||||
case '.': // fallback next
|
||||
|
|
|
@ -156,6 +156,19 @@ lv_widgets = ['arc', 'bar', 'btn', 'btnmatrix', 'canvas', 'checkbox',
|
|||
lv_widgets = lv_widgets + [ 'chart', 'colorwheel', 'imgbtn', 'led', 'meter', 'msgbox', 'spinbox', 'spinner' ]
|
||||
lv_prefix = ['obj', 'group', 'style', 'indev', 'disp'] + lv_widgets
|
||||
|
||||
# define here widget inheritance because it's hard to deduce from source
|
||||
lv_widget_inheritance = {
|
||||
"animing": "img",
|
||||
"calendar": "btnmatrix",
|
||||
"keyboard": "btnmatrix",
|
||||
"list_btn": "btn",
|
||||
"list_text": "label",
|
||||
"spinbox": "textarea",
|
||||
"spinner": "arc", # lv_spinner is a subclass of lv_arc
|
||||
"canvas": "img",
|
||||
"roller_label": "label",
|
||||
}
|
||||
|
||||
def try_int(s):
|
||||
try:
|
||||
v = int(s)
|
||||
|
@ -378,7 +391,7 @@ for subtype, flv in lv.items():
|
|||
if len(c_ret_type) > 1: c_ret_type = "lv." + c_ret_type
|
||||
|
||||
if c_func_name.endswith("_create"):
|
||||
c_ret_type = f"+lv.lv_{subtype}"
|
||||
c_ret_type = "+" # constructor, init method does not return any value
|
||||
if subtype in lv_widgets:
|
||||
print(f"#ifdef BE_LV_WIDGET_{subtype.upper()}")
|
||||
print(f" int be_ntv_lv_{subtype}_init(bvm *vm) {{ return be_call_c_func(vm, (void*) &{orig_func_name}, \"{c_ret_type}\", { c_argc if c_argc else 'nullptr'}); }}")
|
||||
|
@ -421,7 +434,6 @@ extern int lco_init(bvm *vm); // generic function
|
|||
extern int lco_tostring(bvm *vm); // generic function
|
||||
extern int lco_toint(bvm *vm); // generic function
|
||||
|
||||
extern int lvx_init_ctor(bvm *vm, void * func);
|
||||
extern int lvx_member(bvm *vm);
|
||||
extern int lvx_tostring(bvm *vm); // generic function
|
||||
|
||||
|
@ -456,6 +468,11 @@ for subtype, flv in lv.items():
|
|||
|
||||
print()
|
||||
|
||||
# extern classes
|
||||
for subtype in sorted(lv):
|
||||
print(f"extern const bclass be_class_lv_{subtype};");
|
||||
print()
|
||||
|
||||
# Define specific classes for lv_obj
|
||||
#
|
||||
print("""
|
||||
|
@ -599,13 +616,14 @@ be_local_class(lv_color,
|
|||
for subtype, flv in lv.items():
|
||||
# special version for widgets
|
||||
if subtype in lv_widgets:
|
||||
super_class = lv_widget_inheritance.get(subtype, "obj") # get superclass, default to lv_obj
|
||||
print(f"""/********************************************************************
|
||||
** Solidified class: lv_{subtype}
|
||||
********************************************************************/
|
||||
extern const bclass be_class_lv_obj;
|
||||
be_local_class(lv_{subtype},
|
||||
0,
|
||||
&be_class_lv_obj,
|
||||
&be_class_lv_{super_class},
|
||||
be_nested_map(2,
|
||||
( (struct bmapnode*) &(const bmapnode[]) {{
|
||||
{{ be_nested_key("_class", -1562820946, 6, -1), be_const_comptr(&lv_{subtype}_class) }},
|
||||
|
|
Loading…
Reference in New Issue