LVGL raise a warning if multiple event_cb are assigned to the same object

This commit is contained in:
Stephan Hadinger 2022-01-22 10:41:59 +01:00
parent d6e45f113d
commit 5f43550a74
4 changed files with 1037 additions and 1010 deletions

View File

@ -47,6 +47,7 @@ extern const bcstring be_const_str_HTTP_POST;
extern const bcstring be_const_str_I2C_Driver; extern const bcstring be_const_str_I2C_Driver;
extern const bcstring be_const_str_I2C_X3A; extern const bcstring be_const_str_I2C_X3A;
extern const bcstring be_const_str_LVG_X3A_X20call_X20to_X20unsupported_X20callback; extern const bcstring be_const_str_LVG_X3A_X20call_X20to_X20unsupported_X20callback;
extern const bcstring be_const_str_LVG_X3A_X20object_X3A;
extern const bcstring be_const_str_Leds; extern const bcstring be_const_str_Leds;
extern const bcstring be_const_str_MD5; extern const bcstring be_const_str_MD5;
extern const bcstring be_const_str_None; extern const bcstring be_const_str_None;
@ -432,6 +433,7 @@ extern const bcstring be_const_str_gpio;
extern const bcstring be_const_str_group_def; extern const bcstring be_const_str_group_def;
extern const bcstring be_const_str_h; extern const bcstring be_const_str_h;
extern const bcstring be_const_str_has; extern const bcstring be_const_str_has;
extern const bcstring be_const_str_has_X20already_X20an_X20event_X20callback;
extern const bcstring be_const_str_has_arg; extern const bcstring be_const_str_has_arg;
extern const bcstring be_const_str_height_def; extern const bcstring be_const_str_height_def;
extern const bcstring be_const_str_hex; extern const bcstring be_const_str_hex;

File diff suppressed because it is too large Load Diff

View File

@ -698,9 +698,9 @@ be_local_closure(LVGL_glob_widget_event_impl, /* name */
********************************************************************/ ********************************************************************/
be_local_closure(LVGL_glob_make_cb, /* name */ be_local_closure(LVGL_glob_make_cb, /* name */
be_nested_proto( be_nested_proto(
8, /* nstack */ 9, /* nstack */
4, /* argc */ 4, /* argc */
0, /* varg */ 2, /* varg */
0, /* has upvals */ 0, /* has upvals */
NULL, /* no upvals */ NULL, /* no upvals */
1, /* has sup protos */ 1, /* has sup protos */
@ -731,26 +731,31 @@ be_local_closure(LVGL_glob_make_cb, /* name */
), ),
}), }),
1, /* has constants */ 1, /* has constants */
( &(const bvalue[12]) { /* constants */ ( &(const bvalue[17]) { /* constants */
/* K0 */ be_nested_str(cb), /* K0 */ be_nested_str(cb),
/* K1 */ be_nested_str(lv_event_cb), /* K1 */ be_nested_str(lv_event_cb),
/* K2 */ be_nested_str(cb_event_closure), /* K2 */ be_nested_str(cb_event_closure),
/* K3 */ be_nested_str(event_cb), /* K3 */ be_nested_str(event_cb),
/* K4 */ be_nested_str(gen_cb), /* K4 */ be_nested_str(gen_cb),
/* K5 */ be_nested_str(register_obj), /* K5 */ be_nested_str(register_obj),
/* K6 */ be_nested_str(_p), /* K6 */ be_nested_str(contains),
/* K7 */ be_const_int(0), /* K7 */ be_nested_str(_p),
/* K8 */ be_const_int(2), /* K8 */ be_nested_str(tasmota),
/* K9 */ be_nested_str(lv_), /* K9 */ be_nested_str(log),
/* K10 */ be_nested_str(null_cb), /* K10 */ be_nested_str(LVG_X3A_X20object_X3A),
/* K11 */ be_nested_str(cb_do_nothing), /* K11 */ be_nested_str(has_X20already_X20an_X20event_X20callback),
/* K12 */ be_const_int(2),
/* K13 */ be_const_int(0),
/* K14 */ be_nested_str(lv_),
/* K15 */ be_nested_str(null_cb),
/* K16 */ be_nested_str(cb_do_nothing),
}), }),
&be_const_str_make_cb, &be_const_str_make_cb,
&be_const_str_solidified, &be_const_str_solidified,
( &(const binstruction[49]) { /* code */ ( &(const binstruction[63]) { /* code */
0xA4120000, // 0000 IMPORT R4 K0 0xA4120000, // 0000 IMPORT R4 K0
0x1C140701, // 0001 EQ R5 R3 K1 0x1C140701, // 0001 EQ R5 R3 K1
0x78160018, // 0002 JMPF R5 #001C 0x78160026, // 0002 JMPF R5 #002A
0x88140102, // 0003 GETMBR R5 R0 K2 0x88140102, // 0003 GETMBR R5 R0 K2
0x4C180000, // 0004 LDNIL R6 0x4C180000, // 0004 LDNIL R6
0x1C140A06, // 0005 EQ R5 R5 R6 0x1C140A06, // 0005 EQ R5 R5 R6
@ -769,34 +774,48 @@ be_local_closure(LVGL_glob_make_cb, /* name */
0x8C140105, // 0012 GETMET R5 R0 K5 0x8C140105, // 0012 GETMET R5 R0 K5
0x5C1C0400, // 0013 MOVE R7 R2 0x5C1C0400, // 0013 MOVE R7 R2
0x7C140400, // 0014 CALL R5 2 0x7C140400, // 0014 CALL R5 2
0x88140506, // 0015 GETMBR R5 R2 K6 0x88140102, // 0015 GETMBR R5 R0 K2
0x88180102, // 0016 GETMBR R6 R0 K2 0x8C140B06, // 0016 GETMET R5 R5 K6
0x98180A01, // 0017 SETIDX R6 R5 R1 0x881C0507, // 0017 GETMBR R7 R2 K7
0x88140103, // 0018 GETMBR R5 R0 K3 0x7C140400, // 0018 CALL R5 2
0xA0000000, // 0019 CLOSE R0 0x78160008, // 0019 JMPF R5 #0023
0x80040A00, // 001A RET 1 R5 0xB8161000, // 001A GETNGBL R5 K8
0x70020012, // 001B JMP #002F 0x8C140B09, // 001B GETMET R5 R5 K9
0x40160F08, // 001C CONNECT R5 K7 K8 0x601C0008, // 001C GETGBL R7 G8
0x94140605, // 001D GETIDX R5 R3 R5 0x5C200400, // 001D MOVE R8 R2
0x1C140B09, // 001E EQ R5 R5 K9 0x7C1C0200, // 001E CALL R7 1
0x7816000B, // 001F JMPF R5 #002C 0x001E1407, // 001F ADD R7 K10 R7
0x8814010A, // 0020 GETMBR R5 R0 K10 0x001C0F0B, // 0020 ADD R7 R7 K11
0x4C180000, // 0021 LDNIL R6 0x5820000C, // 0021 LDCONST R8 K12
0x1C140A06, // 0022 EQ R5 R5 R6 0x7C140600, // 0022 CALL R5 3
0x78160003, // 0023 JMPF R5 #0028 0x88140507, // 0023 GETMBR R5 R2 K7
0x8C140904, // 0024 GETMET R5 R4 K4 0x88180102, // 0024 GETMBR R6 R0 K2
0x881C010B, // 0025 GETMBR R7 R0 K11 0x98180A01, // 0025 SETIDX R6 R5 R1
0x7C140400, // 0026 CALL R5 2 0x88140103, // 0026 GETMBR R5 R0 K3
0x90021405, // 0027 SETMBR R0 K10 R5 0xA0000000, // 0027 CLOSE R0
0x8814010A, // 0028 GETMBR R5 R0 K10 0x80040A00, // 0028 RET 1 R5
0xA0000000, // 0029 CLOSE R0 0x70020012, // 0029 JMP #003D
0x80040A00, // 002A RET 1 R5 0x40161B0C, // 002A CONNECT R5 K13 K12
0x70020002, // 002B JMP #002F 0x94140605, // 002B GETIDX R5 R3 R5
0x4C140000, // 002C LDNIL R5 0x1C140B0E, // 002C EQ R5 R5 K14
0xA0000000, // 002D CLOSE R0 0x7816000B, // 002D JMPF R5 #003A
0x80040A00, // 002E RET 1 R5 0x8814010F, // 002E GETMBR R5 R0 K15
0xA0000000, // 002F CLOSE R0 0x4C180000, // 002F LDNIL R6
0x80000000, // 0030 RET 0 0x1C140A06, // 0030 EQ R5 R5 R6
0x78160003, // 0031 JMPF R5 #0036
0x8C140904, // 0032 GETMET R5 R4 K4
0x881C0110, // 0033 GETMBR R7 R0 K16
0x7C140400, // 0034 CALL R5 2
0x90021E05, // 0035 SETMBR R0 K15 R5
0x8814010F, // 0036 GETMBR R5 R0 K15
0xA0000000, // 0037 CLOSE R0
0x80040A00, // 0038 RET 1 R5
0x70020002, // 0039 JMP #003D
0x4C140000, // 003A LDNIL R5
0xA0000000, // 003B CLOSE R0
0x80040A00, // 003C RET 1 R5
0xA0000000, // 003D CLOSE R0
0x80000000, // 003E RET 0
}) })
) )
); );

View File

@ -58,11 +58,14 @@ class LVGL_glob
# record the object, whatever the callback # record the object, whatever the callback
if name == "lv_event_cb" if name == "lv_event_cb"
if self.cb_event_closure == nil self.cb_event_closure = {} end if self.cb_event_closure == nil self.cb_event_closure = {} end # lazy instanciation
if self.event_cb == nil self.event_cb = cb.gen_cb(/ event_ptr -> self.lvgl_event_dispatch(event_ptr)) end # encapsulate 'self' in closure if self.event_cb == nil self.event_cb = cb.gen_cb(/ event_ptr -> self.lvgl_event_dispatch(event_ptr)) end # encapsulate 'self' in closure
self.register_obj(obj) self.register_obj(obj) # keep a record of the object to prevent from being gc'ed
self.cb_event_closure[obj._p] = f if self.cb_event_closure.contains(obj._p)
tasmota.log("LVG: object:" + str(obj) + "has already an event callback", 2)
end
self.cb_event_closure[obj._p] = f # keep a mapping of the closure to call, indexed by internal lvgl native pointer
return self.event_cb return self.event_cb
# elif name == "<other_cb>" # elif name == "<other_cb>"
elif name[0..2] == "lv_" elif name[0..2] == "lv_"