From 1e55a9ba50264c127a53765022083720366595dd Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Fri, 13 May 2022 22:28:17 +0200 Subject: [PATCH 1/2] OpenHASP support for dropdown attributes --- .../berry_mapping/src/be_class_wrapper.c | 1 + .../berry_tasmota/src/be_lv_openhasp.c | 386 +++++++++++++++++- tasmota/berry/openhasp/openhasp.tapp | Bin 58548 -> 60625 bytes tasmota/berry/openhasp/openhasp_demo.tapp | Bin 189354 -> 191431 bytes tasmota/berry/openhasp_src/openhasp.tapp | Bin 58548 -> 60625 bytes .../openhasp_src/openhasp_core/openhasp.be | 72 +++- tasmota/berry/openhasp_src/openhasp_demo.tapp | Bin 189354 -> 191431 bytes 7 files changed, 457 insertions(+), 2 deletions(-) diff --git a/lib/libesp32/berry_mapping/src/be_class_wrapper.c b/lib/libesp32/berry_mapping/src/be_class_wrapper.c index 2591477ce..a1f6502bb 100644 --- a/lib/libesp32/berry_mapping/src/be_class_wrapper.c +++ b/lib/libesp32/berry_mapping/src/be_class_wrapper.c @@ -222,6 +222,7 @@ intptr_t be_convert_single_elt(bvm *vm, int idx, const char * arg_type, int *buf type_ok = (arg_type[0] == '.'); // any type is accepted type_ok = type_ok || (arg_type[0] == provided_type && arg_type[1] == 0); // or type is a match (single char only) type_ok = type_ok || (ret == 0 && arg_type_len != 1); // or NULL is accepted for an instance + type_ok = type_ok || (ret == 0 && arg_type[0] == 's' && arg_type[1] == 0); // accept nil for string, can be dangerous if (!type_ok) { be_raisef(vm, "type_error", "Unexpected argument type '%c', expected '%s'", provided_type, arg_type); diff --git a/lib/libesp32/berry_tasmota/src/be_lv_openhasp.c b/lib/libesp32/berry_tasmota/src/be_lv_openhasp.c index 07b0d04a3..9c1241a03 100644 --- a/lib/libesp32/berry_tasmota/src/be_lv_openhasp.c +++ b/lib/libesp32/berry_tasmota/src/be_lv_openhasp.c @@ -5144,6 +5144,372 @@ void be_load_lvh_textarea_class(bvm *vm) { be_pop(vm, 1); } +/******************************************************************** +** Solidified function: get_val +********************************************************************/ +be_local_closure(lvh_dropdown_get_val, /* name */ + be_nested_proto( + 3, /* nstack */ + 1, /* argc */ + 2, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 2]) { /* constants */ + /* K0 */ be_nested_str_literal("_lv_obj"), + /* K1 */ be_nested_str_literal("get_selected"), + }), + be_str_literal("get_val"), + &be_const_str_solidified, + ( &(const binstruction[ 4]) { /* code */ + 0x88040100, // 0000 GETMBR R1 R0 K0 + 0x8C040301, // 0001 GETMET R1 R1 K1 + 0x7C040200, // 0002 CALL R1 1 + 0x80040200, // 0003 RET 1 R1 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: set_direction +********************************************************************/ +be_local_closure(lvh_dropdown_set_direction, /* name */ + be_nested_proto( + 6, /* nstack */ + 2, /* argc */ + 2, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 3]) { /* constants */ + /* K0 */ be_nested_str_literal("_lv_obj"), + /* K1 */ be_nested_str_literal("set_dir"), + /* K2 */ be_nested_str_literal("_dir"), + }), + be_str_literal("set_direction"), + &be_const_str_solidified, + ( &(const binstruction[ 9]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 K0 + 0x8C080501, // 0001 GETMET R2 R2 K1 + 0x60100009, // 0002 GETGBL R4 G9 + 0x5C140200, // 0003 MOVE R5 R1 + 0x7C100200, // 0004 CALL R4 1 + 0x88140102, // 0005 GETMBR R5 R0 K2 + 0x94100A04, // 0006 GETIDX R4 R5 R4 + 0x7C080400, // 0007 CALL R2 2 + 0x80000000, // 0008 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: set_options +********************************************************************/ +be_local_closure(lvh_dropdown_set_options, /* name */ + be_nested_proto( + 6, /* nstack */ + 2, /* argc */ + 2, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 4]) { /* constants */ + /* K0 */ be_nested_str_literal("_lv_obj"), + /* K1 */ be_nested_str_literal("set_options"), + /* K2 */ be_nested_str_literal("lv"), + /* K3 */ be_nested_str_literal("ROLLER_MODE_NORMAL"), + }), + be_str_literal("set_options"), + &be_const_str_solidified, + ( &(const binstruction[ 7]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 K0 + 0x8C080501, // 0001 GETMET R2 R2 K1 + 0x5C100200, // 0002 MOVE R4 R1 + 0xB8160400, // 0003 GETNGBL R5 K2 + 0x88140B03, // 0004 GETMBR R5 R5 K3 + 0x7C080600, // 0005 CALL R2 3 + 0x80000000, // 0006 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: set_val +********************************************************************/ +be_local_closure(lvh_dropdown_set_val, /* name */ + be_nested_proto( + 6, /* nstack */ + 2, /* argc */ + 2, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 3]) { /* constants */ + /* K0 */ be_nested_str_literal("_lv_obj"), + /* K1 */ be_nested_str_literal("set_selected"), + /* K2 */ be_const_int(0), + }), + be_str_literal("set_val"), + &be_const_str_solidified, + ( &(const binstruction[ 6]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 K0 + 0x8C080501, // 0001 GETMET R2 R2 K1 + 0x5C100200, // 0002 MOVE R4 R1 + 0x58140002, // 0003 LDCONST R5 K2 + 0x7C080600, // 0004 CALL R2 3 + 0x80000000, // 0005 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: get_text +********************************************************************/ +be_local_closure(lvh_dropdown_get_text, /* name */ + be_nested_proto( + 7, /* nstack */ + 1, /* argc */ + 2, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 7]) { /* constants */ + /* K0 */ be_nested_str_literal("_lv_obj"), + /* K1 */ be_nested_str_literal("get_text"), + /* K2 */ be_nested_str_literal("resize"), + /* K3 */ be_nested_str_literal("get_selected_str"), + /* K4 */ be_nested_str_literal("_buffer"), + /* K5 */ be_nested_str_literal("remove_trailing_zeroes"), + /* K6 */ be_nested_str_literal("asstring"), + }), + be_str_literal("get_text"), + &be_const_str_solidified, + ( &(const binstruction[27]) { /* code */ + 0x88040100, // 0000 GETMBR R1 R0 K0 + 0x8C040301, // 0001 GETMET R1 R1 K1 + 0x7C040200, // 0002 CALL R1 1 + 0x4C080000, // 0003 LDNIL R2 + 0x1C080202, // 0004 EQ R2 R1 R2 + 0x780A0012, // 0005 JMPF R2 #0019 + 0x60080015, // 0006 GETGBL R2 G21 + 0x7C080000, // 0007 CALL R2 0 + 0x8C080502, // 0008 GETMET R2 R2 K2 + 0x541200FF, // 0009 LDINT R4 256 + 0x7C080400, // 000A CALL R2 2 + 0x880C0100, // 000B GETMBR R3 R0 K0 + 0x8C0C0703, // 000C GETMET R3 R3 K3 + 0x8C140504, // 000D GETMET R5 R2 K4 + 0x7C140200, // 000E CALL R5 1 + 0x541A00FF, // 000F LDINT R6 256 + 0x7C0C0600, // 0010 CALL R3 3 + 0x8C0C0105, // 0011 GETMET R3 R0 K5 + 0x5C140400, // 0012 MOVE R5 R2 + 0x7C0C0400, // 0013 CALL R3 2 + 0x5C080600, // 0014 MOVE R2 R3 + 0x8C0C0506, // 0015 GETMET R3 R2 K6 + 0x7C0C0200, // 0016 CALL R3 1 + 0x80040600, // 0017 RET 1 R3 + 0x70020000, // 0018 JMP #001A + 0x80040200, // 0019 RET 1 R1 + 0x80000000, // 001A RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: get_direction +********************************************************************/ +be_local_closure(lvh_dropdown_get_direction, /* name */ + be_nested_proto( + 5, /* nstack */ + 1, /* argc */ + 2, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 4]) { /* constants */ + /* K0 */ be_nested_str_literal("_lv_obj"), + /* K1 */ be_nested_str_literal("get_dir"), + /* K2 */ be_nested_str_literal("_dir"), + /* K3 */ be_nested_str_literal("stop_iteration"), + }), + be_str_literal("get_direction"), + &be_const_str_solidified, + ( &(const binstruction[21]) { /* code */ + 0x88040100, // 0000 GETMBR R1 R0 K0 + 0x8C040301, // 0001 GETMET R1 R1 K1 + 0x7C040200, // 0002 CALL R1 1 + 0x60080010, // 0003 GETGBL R2 G16 + 0x880C0102, // 0004 GETMBR R3 R0 K2 + 0x7C080200, // 0005 CALL R2 1 + 0xA8020008, // 0006 EXBLK 0 #0010 + 0x5C0C0400, // 0007 MOVE R3 R2 + 0x7C0C0000, // 0008 CALL R3 0 + 0x88100102, // 0009 GETMBR R4 R0 K2 + 0x94100803, // 000A GETIDX R4 R4 R3 + 0x1C100204, // 000B EQ R4 R1 R4 + 0x78120001, // 000C JMPF R4 #000F + 0xA8040001, // 000D EXBLK 1 1 + 0x80040600, // 000E RET 1 R3 + 0x7001FFF6, // 000F JMP #0007 + 0x58080003, // 0010 LDCONST R2 K3 + 0xAC080200, // 0011 CATCH R2 1 0 + 0xB0080000, // 0012 RAISE 2 R0 R0 + 0x5409FFFE, // 0013 LDINT R2 -1 + 0x80040400, // 0014 RET 1 R2 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: set_show_selected +********************************************************************/ +be_local_closure(lvh_dropdown_set_show_selected, /* name */ + be_nested_proto( + 5, /* nstack */ + 2, /* argc */ + 2, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 2]) { /* constants */ + /* K0 */ be_nested_str_literal("_lv_obj"), + /* K1 */ be_nested_str_literal("set_text"), + }), + be_str_literal("set_show_selected"), + &be_const_str_solidified, + ( &(const binstruction[ 6]) { /* code */ + 0x78060003, // 0000 JMPF R1 #0005 + 0x88080100, // 0001 GETMBR R2 R0 K0 + 0x8C080501, // 0002 GETMET R2 R2 K1 + 0x4C100000, // 0003 LDNIL R4 + 0x7C080400, // 0004 CALL R2 2 + 0x80000000, // 0005 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: set_text +********************************************************************/ +be_local_closure(lvh_dropdown_set_text, /* name */ + be_nested_proto( + 5, /* nstack */ + 2, /* argc */ + 2, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 2]) { /* constants */ + /* K0 */ be_nested_str_literal("_lv_obj"), + /* K1 */ be_nested_str_literal("set_text"), + }), + be_str_literal("set_text"), + &be_const_str_solidified, + ( &(const binstruction[ 5]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 K0 + 0x8C080501, // 0001 GETMET R2 R2 K1 + 0x5C100200, // 0002 MOVE R4 R1 + 0x7C080400, // 0003 CALL R2 2 + 0x80000000, // 0004 RET 0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: get_options +********************************************************************/ +be_local_closure(lvh_dropdown_get_options, /* name */ + be_nested_proto( + 3, /* nstack */ + 1, /* argc */ + 2, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 2]) { /* constants */ + /* K0 */ be_nested_str_literal("_lv_obj"), + /* K1 */ be_nested_str_literal("get_options"), + }), + be_str_literal("get_options"), + &be_const_str_solidified, + ( &(const binstruction[ 4]) { /* code */ + 0x88040100, // 0000 GETMBR R1 R0 K0 + 0x8C040301, // 0001 GETMET R1 R1 K1 + 0x7C040200, // 0002 CALL R1 1 + 0x80040200, // 0003 RET 1 R1 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: get_show_selected +********************************************************************/ +be_local_closure(lvh_dropdown_get_show_selected, /* name */ + be_nested_proto( + 3, /* nstack */ + 1, /* argc */ + 2, /* varg */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 2]) { /* constants */ + /* K0 */ be_nested_str_literal("_lv_obj"), + /* K1 */ be_nested_str_literal("get_text"), + }), + be_str_literal("get_show_selected"), + &be_const_str_solidified, + ( &(const binstruction[ 6]) { /* code */ + 0x88040100, // 0000 GETMBR R1 R0 K0 + 0x8C040301, // 0001 GETMET R1 R1 K1 + 0x7C040200, // 0002 CALL R1 1 + 0x4C080000, // 0003 LDNIL R2 + 0x1C080202, // 0004 EQ R2 R1 R2 + 0x80040400, // 0005 RET 1 R2 + }) + ) +); +/*******************************************************************/ + + /******************************************************************** ** Solidified class: lvh_dropdown ********************************************************************/ @@ -5151,9 +5517,27 @@ extern const bclass be_class_lvh_obj; be_local_class(lvh_dropdown, 0, &be_class_lvh_obj, - be_nested_map(1, + be_nested_map(12, ( (struct bmapnode*) &(const bmapnode[]) { + { be_const_key_literal("get_show_selected", 8), be_const_closure(lvh_dropdown_get_show_selected_closure) }, + { be_const_key_literal("set_direction", -1), be_const_closure(lvh_dropdown_set_direction_closure) }, + { be_const_key_literal("set_options", -1), be_const_closure(lvh_dropdown_set_options_closure) }, + { be_const_key_literal("set_val", 4), be_const_closure(lvh_dropdown_set_val_closure) }, + { be_const_key_literal("get_text", -1), be_const_closure(lvh_dropdown_get_text_closure) }, + { be_const_key_literal("get_direction", 9), be_const_closure(lvh_dropdown_get_direction_closure) }, { be_const_key_literal("_lv_class", -1), be_const_class(be_class_lv_dropdown) }, + { be_const_key_literal("set_show_selected", 6), be_const_closure(lvh_dropdown_set_show_selected_closure) }, + { be_const_key_literal("set_text", -1), be_const_closure(lvh_dropdown_set_text_closure) }, + { be_const_key_literal("_dir", -1), be_const_simple_instance(be_nested_simple_instance(&be_class_list, { + be_const_list( * be_nested_list(4, + ( (struct bvalue*) &(const bvalue[]) { + be_const_int(8), + be_const_int(4), + be_const_int(1), + be_const_int(2), + })) ) } )) }, + { be_const_key_literal("get_options", -1), be_const_closure(lvh_dropdown_get_options_closure) }, + { be_const_key_literal("get_val", 0), be_const_closure(lvh_dropdown_get_val_closure) }, })), be_str_literal("lvh_dropdown") ); diff --git a/tasmota/berry/openhasp/openhasp.tapp b/tasmota/berry/openhasp/openhasp.tapp index e7f8e8ae139be04b415d98ca584fff71cf35a0e9..e5f536b07d2b07718300077c800f16a2214efa9e 100644 GIT binary patch delta 1196 zcmah}&1(}u6i-^ITEC!3v0&lZDorE?tCw0WqG&&$l3G(mLP&PAv&ramC+^NB)Z!JS$=Zz2xFS@L2I8UVG5iQ~v_r%qFQp!G&brypP}e?eD$h-RJK0Z{2Us zhfkK@zDjO~z8-kF849V-zR=MSFA}Fax1lC4Y+PJ(kOh7B4$GF}2z!-#-|rw4A*Fo-hQ>LB^skOh5`) zDSl;UK65#dOeU_yTGwP^u5Hg=olLeb^D|S^Nl3#moW^q1C)SYm0|FR$Ov*@D8mDz#Yej=>J^!>L@X#53_(i71yLYSGMG;g z2(YW~5y(1}WkGNS0j80=tFtr$x3%pNMsfmic1qD@$L062{XHr%B4n2K%NG}SPnHa~ zNh07ifv}jGVWkW=@5J*>zLBVAK<&=t2|zL!k=fdid{{dtS1ufqpK2p=s}_}gD@SD4 z$HSFCa}BRSh-2ZYzVR3a90jta+yRFWONo->4!*pnT(-*>A%VLwed)#=IR2uE0Wcg3 zW^Yc-j(CV*5hR5)+c*&skZleL{x>DLKGt8s>PYbBXr-uw8b#9zCt$0ZC@prH1U-~| z=)-~kC7VJFl5Fk*9dDx}sCrOKU8zeeC^_CzG_67|5x(mHZ8mR_Xa`P>Hi_YZJ5}K2 z459}!kC>dZC{QJ2TR6kAsFGOcbB8U#A~785_7S)zK49Shet_$jJ@e7!J` z?kwGr_mB1Ym&_VC$ZpCO>8Q{v8kNsov;Jh|OSrza`XP0&^B+j&H;#814f%BASkJ(( H5I(;FCd!wX delta 130 zcmcb3lX=TY<_*@2TIvaFL*Dvt`qTD^fdPcM8Dtpp3sUnk5{nD;l2SuMI2o9;bn23F zbT+3lHaAYLYhJi{Ys+e;$t#LNH^1q-#K@6SlwXjNU!FI)VS>tJoeqx8YbKnE=0i1i Va?2YPrYxPwtKKNG{dvp)1OTbYHjMxP diff --git a/tasmota/berry/openhasp/openhasp_demo.tapp b/tasmota/berry/openhasp/openhasp_demo.tapp index 79b11f4845a1087c13a22d3ae507569111511d73..eb402a46a883d309cd765a563b8581f20e97ff0e 100644 GIT binary patch delta 1273 zcma)6O=uHA6i(*Q*3=(7Snwde8lefqU@H_U#Bs$bb_qR-Qzkd59x>J)cHponW;BbriFFovhY zY>|Q+X!(4#C}P;rVm1U!7-d?2Qzdtz)wsS2_Eab%0NNT#yDT1*9J;|Qs1&JSW#)q@ zGAL6gWQYdXIt&=(UGC&TcnShcT6m(fG=gVqJ75kg2*l}>qRURpXY=HAzsgLAqfRTMK0IKO*u41 z&dFCbG9nLZBv}RUnFxIs%rp%G;d6Jj*_k;(<8kejE@(X)b1gj8FCKBg_2J{V=Yq?a zr8q2jE^-wpm+gCNkSQ^D`tH&KxZ#?K0ibiP1+&Xjvm*gQw6@X)LNaut|J|%ypC=cp zSe|H*gw_go6{k4`)Re4E12X8Ap zrTihYIOG5u5x=YGU;u1X-TF*(j?h>V-KYx%&B=Q@o#-(lm delta 126 zcmX?poqN@B?uIRlf`9qc6V`^j_22ZT?GXb*+oS37e;LKtvUKW_a&)#^|7C1$oE}oo zv~YWO1Ji1z>2-Nbq1z92Fk%y=GEj T%F>y>;5CyX+ok(V3=9kaofZ!JS$=Zz2xFS@L2I8UVG5iQ~v_r%qFQp!G&brypP}e?eD$h-RJK0Z{2Us zhfkK@zDjO~z8-kF849V-zR=MSFA}Fax1lC4Y+PJ(kOh7B4$GF}2z!-#-|rw4A*Fo-hQ>LB^skOh5`) zDSl;UK65#dOeU_yTGwP^u5Hg=olLeb^D|S^Nl3#moW^q1C)SYm0|FR$Ov*@D8mDz#Yej=>J^!>L@X#53_(i71yLYSGMG;g z2(YW~5y(1}WkGNS0j80=tFtr$x3%pNMsfmic1qD@$L062{XHr%B4n2K%NG}SPnHa~ zNh07ifv}jGVWkW=@5J*>zLBVAK<&=t2|zL!k=fdid{{dtS1ufqpK2p=s}_}gD@SD4 z$HSFCa}BRSh-2ZYzVR3a90jta+yRFWONo->4!*pnT(-*>A%VLwed)#=IR2uE0Wcg3 zW^Yc-j(CV*5hR5)+c*&skZleL{x>DLKGt8s>PYbBXr-uw8b#9zCt$0ZC@prH1U-~| z=)-~kC7VJFl5Fk*9dDx}sCrOKU8zeeC^_CzG_67|5x(mHZ8mR_Xa`P>Hi_YZJ5}K2 z459}!kC>dZC{QJ2TR6kAsFGOcbB8U#A~785_7S)zK49Shet_$jJ@e7!J` z?kwGr_mB1Ym&_VC$ZpCO>8Q{v8kNsov;Jh|OSrza`XP0&^B+j&H;#814f%BASkJ(( H5I(;FCd!wX delta 130 zcmcb3lX=TY<_*@2TIvaFL*Dvt`qTD^fdPcM8Dtpp3sUnk5{nD;l2SuMI2o9;bn23F zbT+3lHaAYLYhJi{Ys+e;$t#LNH^1q-#K@6SlwXjNU!FI)VS>tJoeqx8YbKnE=0i1i Va?2YPrYxPwtKKNG{dvp)1OTbYHjMxP diff --git a/tasmota/berry/openhasp_src/openhasp_core/openhasp.be b/tasmota/berry/openhasp_src/openhasp_core/openhasp.be index 3c0e552ff..20c2fceca 100644 --- a/tasmota/berry/openhasp_src/openhasp_core/openhasp.be +++ b/tasmota/berry/openhasp_src/openhasp_core/openhasp.be @@ -1022,6 +1022,9 @@ class lvh_qrcode : lvh_obj def get_qr_text() end end +#==================================================================== +# slider +#==================================================================== class lvh_slider : lvh_obj static _lv_class = lv.slider @@ -1030,6 +1033,9 @@ class lvh_slider : lvh_obj end end +#==================================================================== +# roller +#==================================================================== class lvh_roller : lvh_obj static _lv_class = lv.roller @@ -1059,6 +1065,71 @@ class lvh_roller : lvh_obj end end +#==================================================================== +# dropdown +#==================================================================== +class lvh_dropdown : lvh_obj + static _lv_class = lv.dropdown + static _dir = [ lv.DIR_BOTTOM, lv.DIR_TOP, lv.DIR_LEFT, lv.DIR_RIGHT ] # 0 = down, 1 = up, 2 = left, 3 = right + + def set_val(t) + self._lv_obj.set_selected(t, 0) # add second parameter - no animation + end + def get_val() + return self._lv_obj.get_selected() + end + + def set_options(t) + self._lv_obj.set_options(t, lv.ROLLER_MODE_NORMAL) + end + def get_options() + return self._lv_obj.get_options() + end + + def set_text(t) + # set_text sets a static text displayed whatever the value + # use `nil` to set back the text of the selected value + self._lv_obj.set_text(t) + end + def get_text() + var static_text = self._lv_obj.get_text() + if static_text == nil + # allocate a bytes buffer + var b = bytes().resize(256) # force 256 bytes + self._lv_obj.get_selected_str(b._buffer(), 256) + b = self.remove_trailing_zeroes(b) + return b.asstring() + else + return static_text + end + end + + # direction needs a conversion from OpenHASP numbers and LVGL's + def set_direction(t) + # 0 = down, 1 = up, 2 = left, 3 = right + self._lv_obj.set_dir(self._dir[int(t)]) + end + def get_direction() + var dir = self._lv_obj.get_dir() + for i:self._dir + if dir == self._dir[i] return i end + end + return -1 + end + + # show_selected (bool) is a OpenHASP addition + # only meaningful if set to `true`, setting to false requires a call to `set_text` + def set_show_selected(t) + if t + self._lv_obj.set_text(nil) # undo static text + end + end + def get_show_selected() + var static_text = self._lv_obj.get_text() + return (static_text == nil) + end +end + ################################################################################# # # All other subclasses than just map the LVGL object @@ -1069,7 +1140,6 @@ class lvh_bar : lvh_obj static _lv_class = lv.bar end class lvh_btn : lvh_obj static _lv_class = lv.btn end class lvh_btnmatrix : lvh_obj static _lv_class = lv.btnmatrix end class lvh_checkbox : lvh_obj static _lv_class = lv.checkbox end -class lvh_dropdown : lvh_obj static _lv_class = lv.dropdown end class lvh_line : lvh_obj static _lv_class = lv.line end class lvh_textarea : lvh_obj static _lv_class = lv.textarea end # special case for scr (which is actually lv_obj) diff --git a/tasmota/berry/openhasp_src/openhasp_demo.tapp b/tasmota/berry/openhasp_src/openhasp_demo.tapp index 79b11f4845a1087c13a22d3ae507569111511d73..eb402a46a883d309cd765a563b8581f20e97ff0e 100644 GIT binary patch delta 1273 zcma)6O=uHA6i(*Q*3=(7Snwde8lefqU@H_U#Bs$bb_qR-Qzkd59x>J)cHponW;BbriFFovhY zY>|Q+X!(4#C}P;rVm1U!7-d?2Qzdtz)wsS2_Eab%0NNT#yDT1*9J;|Qs1&JSW#)q@ zGAL6gWQYdXIt&=(UGC&TcnShcT6m(fG=gVqJ75kg2*l}>qRURpXY=HAzsgLAqfRTMK0IKO*u41 z&dFCbG9nLZBv}RUnFxIs%rp%G;d6Jj*_k;(<8kejE@(X)b1gj8FCKBg_2J{V=Yq?a zr8q2jE^-wpm+gCNkSQ^D`tH&KxZ#?K0ibiP1+&Xjvm*gQw6@X)LNaut|J|%ypC=cp zSe|H*gw_go6{k4`)Re4E12X8Ap zrTihYIOG5u5x=YGU;u1X-TF*(j?h>V-KYx%&B=Q@o#-(lm delta 126 zcmX?poqN@B?uIRlf`9qc6V`^j_22ZT?GXb*+oS37e;LKtvUKW_a&)#^|7C1$oE}oo zv~YWO1Ji1z>2-Nbq1z92Fk%y=GEj T%F>y>;5CyX+ok(V3=9kaof Date: Fri, 13 May 2022 22:39:51 +0200 Subject: [PATCH 2/2] OpenHASP fix dropdown direction --- .../berry_tasmota/src/be_lv_openhasp.c | 42 +++++++++--------- tasmota/berry/openhasp/openhasp.tapp | Bin 60625 -> 60662 bytes tasmota/berry/openhasp/openhasp_demo.tapp | Bin 191431 -> 191468 bytes tasmota/berry/openhasp_src/openhasp.tapp | Bin 60625 -> 60662 bytes .../openhasp_src/openhasp_core/openhasp.be | 4 +- tasmota/berry/openhasp_src/openhasp_demo.tapp | Bin 191431 -> 191468 bytes 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/lib/libesp32/berry_tasmota/src/be_lv_openhasp.c b/lib/libesp32/berry_tasmota/src/be_lv_openhasp.c index 9c1241a03..1f82d2643 100644 --- a/lib/libesp32/berry_tasmota/src/be_lv_openhasp.c +++ b/lib/libesp32/berry_tasmota/src/be_lv_openhasp.c @@ -5349,36 +5349,34 @@ be_local_closure(lvh_dropdown_get_direction, /* name */ 0, /* has sup protos */ NULL, /* no sub protos */ 1, /* has constants */ - ( &(const bvalue[ 4]) { /* constants */ + ( &(const bvalue[ 5]) { /* constants */ /* K0 */ be_nested_str_literal("_lv_obj"), /* K1 */ be_nested_str_literal("get_dir"), - /* K2 */ be_nested_str_literal("_dir"), - /* K3 */ be_nested_str_literal("stop_iteration"), + /* K2 */ be_const_int(0), + /* K3 */ be_nested_str_literal("_dir"), + /* K4 */ be_const_int(1), }), be_str_literal("get_direction"), &be_const_str_solidified, - ( &(const binstruction[21]) { /* code */ + ( &(const binstruction[18]) { /* code */ 0x88040100, // 0000 GETMBR R1 R0 K0 0x8C040301, // 0001 GETMET R1 R1 K1 0x7C040200, // 0002 CALL R1 1 - 0x60080010, // 0003 GETGBL R2 G16 - 0x880C0102, // 0004 GETMBR R3 R0 K2 - 0x7C080200, // 0005 CALL R2 1 - 0xA8020008, // 0006 EXBLK 0 #0010 - 0x5C0C0400, // 0007 MOVE R3 R2 - 0x7C0C0000, // 0008 CALL R3 0 - 0x88100102, // 0009 GETMBR R4 R0 K2 - 0x94100803, // 000A GETIDX R4 R4 R3 - 0x1C100204, // 000B EQ R4 R1 R4 - 0x78120001, // 000C JMPF R4 #000F - 0xA8040001, // 000D EXBLK 1 1 - 0x80040600, // 000E RET 1 R3 - 0x7001FFF6, // 000F JMP #0007 - 0x58080003, // 0010 LDCONST R2 K3 - 0xAC080200, // 0011 CATCH R2 1 0 - 0xB0080000, // 0012 RAISE 2 R0 R0 - 0x5409FFFE, // 0013 LDINT R2 -1 - 0x80040400, // 0014 RET 1 R2 + 0x58080002, // 0003 LDCONST R2 K2 + 0x600C000C, // 0004 GETGBL R3 G12 + 0x88100103, // 0005 GETMBR R4 R0 K3 + 0x7C0C0200, // 0006 CALL R3 1 + 0x140C0403, // 0007 LT R3 R2 R3 + 0x780E0006, // 0008 JMPF R3 #0010 + 0x880C0103, // 0009 GETMBR R3 R0 K3 + 0x940C0602, // 000A GETIDX R3 R3 R2 + 0x1C0C0203, // 000B EQ R3 R1 R3 + 0x780E0000, // 000C JMPF R3 #000E + 0x80040400, // 000D RET 1 R2 + 0x00080504, // 000E ADD R2 R2 K4 + 0x7001FFF3, // 000F JMP #0004 + 0x540DFFFE, // 0010 LDINT R3 -1 + 0x80040600, // 0011 RET 1 R3 }) ) ); diff --git a/tasmota/berry/openhasp/openhasp.tapp b/tasmota/berry/openhasp/openhasp.tapp index e5f536b07d2b07718300077c800f16a2214efa9e..f14e884386fa460d2319108f8e0d3608ff76d483 100644 GIT binary patch delta 125 zcmcb3llj|C<_*@2TJBrchJ0|?{^!Ii1_lu3W{_dXFG$VHNGvYUOG*t5;bdSwcAzfl z#DUGJj1}FJ-$_gIWmctX6sP8->BXmH7HLj?(_=JQUq*EDzwPXsb$dPIc~Q)q-26tB R>DYnEtKKNG*}Y)^0stRyH3t9y delta 114 zcmex%llkIJ<_*@2TIHM8hJ0eU!n^nt0|N+iGsrOH7o_H8Bo-IwC8dUja569_?yXBo z+PgWGv7(zlEx$-1)2cW%CrvLtC9`NUORv#p=iZ2TUKE2SuXv-%l(={D`8SGel5ZG* F000BXmH7HLj?(_=JQUq*EDzwPXsb$dPIc~Q)q-26tB R>DYnEtKKNG*}Y)^0stRyH3t9y delta 114 zcmex%llkIJ<_*@2TIHM8hJ0eU!n^nt0|N+iGsrOH7o_H8Bo-IwC8dUja569_?yXBo z+PgWGv7(zlEx$-1)2cW%CrvLtC9`NUORv#p=iZ2TUKE2SuXv-%l(={D`8SGel5ZG* F000