diff --git a/lib/libesp32/Berry/default/be_lvgl_signal_bars_lib.c b/lib/libesp32/Berry/default/be_lvgl_signal_bars_lib.c index 14c1e197a..1784493a0 100644 --- a/lib/libesp32/Berry/default/be_lvgl_signal_bars_lib.c +++ b/lib/libesp32/Berry/default/be_lvgl_signal_bars_lib.c @@ -7,44 +7,94 @@ #include "lvgl.h" +/******************************************************************** +** Solidified function: get_percentage +********************************************************************/ +be_local_closure(get_percentage, /* name */ + be_nested_proto( + 2, /* nstack */ + 1, /* argc */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 1]) { /* constants */ + be_nested_string("percentage", -1756136011, 10), + }), + (be_nested_const_str("get_percentage", -1414483304, 14)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[ 2]) { /* code */ + 0x88040100, // 0000 GETMBR R1 R0 R256 + 0x80040200, // 0001 RET 1 R1 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** Solidified function: set_percentage +********************************************************************/ +be_local_closure(set_percentage, /* name */ + be_nested_proto( + 5, /* nstack */ + 2, /* argc */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 3]) { /* constants */ + be_nested_string("percentage", -1756136011, 10), + be_const_int(0), + be_nested_string("invalidate", -1645232368, 10), + }), + (be_nested_const_str("set_percentage", -1342944572, 14)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[18]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 R256 + 0x540E0004, // 0001 LDINT R3 5 + 0x0C080403, // 0002 DIV R2 R2 R3 + 0x540E0063, // 0003 LDINT R3 100 + 0x240C0203, // 0004 GT R3 R1 R3 + 0x780E0000, // 0005 JMPF R3 #0007 + 0x54060063, // 0006 LDINT R1 100 + 0x140C0301, // 0007 LT R3 R1 R257 + 0x780E0000, // 0008 JMPF R3 #000A + 0x58040001, // 0009 LDCONST R1 K1 + 0x90020001, // 000A SETMBR R0 R256 R1 + 0x540E0004, // 000B LDINT R3 5 + 0x0C0C0203, // 000C DIV R3 R1 R3 + 0x200C0403, // 000D NE R3 R2 R3 + 0x780E0001, // 000E JMPF R3 #0011 + 0x8C0C0102, // 000F GETMET R3 R0 R258 + 0x7C0C0200, // 0010 CALL R3 1 + 0x80000000, // 0011 RET 0 R0 + }) + ) +); +/*******************************************************************/ + + /******************************************************************** ** Solidified function: my_design_cb ********************************************************************/ be_local_closure(my_design_cb, /* name */ be_nested_proto( - 23, /* nstack */ + 22, /* nstack */ 3, /* argc */ 0, /* has upvals */ NULL, /* no upvals */ - 1, /* has sup protos */ - be_nested_proto( - 2, /* nstack */ - 1, /* argc */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 1]) { /* constants */ - be_const_int(1), - }), - (be_nested_const_str("atleast1", 1956331672, 8)), - (be_nested_const_str("input", -103256197, 5)), - ( &(const binstruction[ 6]) { /* code */ - 0x28040100, // 0000 GE R1 R0 R256 - 0x78060001, // 0001 JMPF R1 #0004 - 0x80040000, // 0002 RET 1 R0 - 0x70020000, // 0003 JMP #0005 - 0x80060000, // 0004 RET 1 R256 - 0x80000000, // 0005 RET 0 R0 - }) - ), + 0, /* has sup protos */ + NULL, /* no sub protos */ 1, /* has constants */ - ( &(const bvalue[34]) { /* constants */ + ( &(const bvalue[35]) { /* constants */ be_nested_string("global", 503252654, 6), be_nested_string("lv", 1529997255, 2), be_nested_string("get_height", -723211773, 10), be_nested_string("get_width", -1001549996, 9), + be_nested_string("atleast1", 1956331672, 8), be_const_int(3), be_const_int(2), be_nested_string("DESIGN_COVER_CHK", -1298406708, 16), @@ -78,118 +128,117 @@ be_local_closure(my_design_cb, /* name */ }), (be_nested_const_str("my_design_cb", -1173588798, 12)), (be_nested_const_str("input", -103256197, 5)), - ( &(const binstruction[111]) { /* code */ + ( &(const binstruction[110]) { /* code */ 0xA40E0000, // 0000 IMPORT R3 R256 0x88100701, // 0001 GETMBR R4 R3 R257 - 0x84140000, // 0002 CLOSURE R5 P0 - 0x8C180102, // 0003 GETMET R6 R0 R258 - 0x7C180200, // 0004 CALL R6 1 - 0x8C1C0103, // 0005 GETMET R7 R0 R259 - 0x7C1C0200, // 0006 CALL R7 1 - 0x5C200A00, // 0007 MOVE R8 R5 - 0x5426000E, // 0008 LDINT R9 15 - 0x0C240E09, // 0009 DIV R9 R7 R9 - 0x7C200200, // 000A CALL R8 1 - 0x5C240A00, // 000B MOVE R9 R5 - 0x08281104, // 000C MUL R10 R8 R260 - 0x04280E0A, // 000D SUB R10 R7 R10 - 0x542E0003, // 000E LDINT R11 4 - 0x0C28140B, // 000F DIV R10 R10 R11 - 0x7C240200, // 0010 CALL R9 1 - 0x0C281305, // 0011 DIV R10 R9 R261 - 0x882C0906, // 0012 GETMBR R11 R4 R262 - 0x1C2C040B, // 0013 EQ R11 R2 R11 - 0x782E0007, // 0014 JMPF R11 #001D - 0x882C0107, // 0015 GETMBR R11 R0 R263 - 0x8C2C1708, // 0016 GETMET R11 R11 R264 - 0x5C340000, // 0017 MOVE R13 R0 - 0x5C380200, // 0018 MOVE R14 R1 - 0x5C3C0400, // 0019 MOVE R15 R2 - 0x7C2C0800, // 001A CALL R11 4 - 0x80041600, // 001B RET 1 R11 - 0x7002004F, // 001C JMP #006D - 0x882C0909, // 001D GETMBR R11 R4 R265 - 0x1C2C040B, // 001E EQ R11 R2 R11 - 0x782E004C, // 001F JMPF R11 #006D - 0x8C2C010A, // 0020 GETMET R11 R0 R266 - 0x5C340200, // 0021 MOVE R13 R1 - 0x7C2C0400, // 0022 CALL R11 2 - 0x882C030B, // 0023 GETMBR R11 R1 R267 - 0x8830030C, // 0024 GETMBR R12 R1 R268 - 0x8C34090D, // 0025 GETMET R13 R4 R269 - 0x883C010E, // 0026 GETMBR R15 R0 R270 - 0x7C340400, // 0027 CALL R13 2 - 0x8C34010F, // 0028 GETMET R13 R0 R271 - 0x883C0910, // 0029 GETMBR R15 R4 R272 - 0x8840010E, // 002A GETMBR R16 R0 R270 - 0x7C340600, // 002B CALL R13 3 - 0x8834010E, // 002C GETMBR R13 R0 R270 - 0x90362312, // 002D SETMBR R13 R273 R274 - 0x8834010E, // 002E GETMBR R13 R0 R270 - 0x90362712, // 002F SETMBR R13 R275 R274 - 0x8834010E, // 0030 GETMBR R13 R0 R270 - 0x90362809, // 0031 SETMBR R13 R276 R9 - 0x8C340115, // 0032 GETMET R13 R0 R277 - 0x883C0910, // 0033 GETMBR R15 R4 R272 - 0x88400916, // 0034 GETMBR R16 R4 R278 - 0x7C340600, // 0035 CALL R13 3 - 0x8C380117, // 0036 GETMET R14 R0 R279 - 0x88400910, // 0037 GETMBR R16 R4 R272 - 0x88440916, // 0038 GETMBR R17 R4 R278 - 0x7C380600, // 0039 CALL R14 3 - 0x603C0000, // 003A GETGBL R15 G0 - 0x40423104, // 003B CONNECT R16 R280 R260 - 0x7C3C0200, // 003C CALL R15 1 - 0xA802002B, // 003D EXBLK 0 #006A - 0x5C401E00, // 003E MOVE R16 R15 - 0x7C400000, // 003F CALL R16 0 - 0x8844010E, // 0040 GETMBR R17 R0 R270 - 0x8848011A, // 0041 GETMBR R18 R0 R282 - 0x004C2112, // 0042 ADD R19 R16 R274 - 0x54520013, // 0043 LDINT R20 20 - 0x084C2614, // 0044 MUL R19 R19 R20 - 0x28482413, // 0045 GE R18 R18 R19 - 0x784A0001, // 0046 JMPF R18 #0049 - 0x5C481A00, // 0047 MOVE R18 R13 - 0x70020000, // 0048 JMP #004A - 0x5C481C00, // 0049 MOVE R18 R14 - 0x90463212, // 004A SETMBR R17 R281 R18 - 0x8844011B, // 004B GETMBR R17 R0 R283 - 0x00481806, // 004C ADD R18 R12 R6 - 0x04482512, // 004D SUB R18 R18 R274 - 0x0448240A, // 004E SUB R18 R18 R10 - 0x90463812, // 004F SETMBR R17 R284 R18 - 0x8844011B, // 0050 GETMBR R17 R0 R283 - 0x00481208, // 0051 ADD R18 R9 R8 - 0x08482012, // 0052 MUL R18 R16 R18 - 0x00481612, // 0053 ADD R18 R11 R18 - 0x0048240A, // 0054 ADD R18 R18 R10 - 0x90463A12, // 0055 SETMBR R17 R285 R18 - 0x8844011E, // 0056 GETMBR R17 R0 R286 - 0x044A0810, // 0057 SUB R18 R260 R16 - 0x044C0C09, // 0058 SUB R19 R6 R9 - 0x08482413, // 0059 MUL R18 R18 R19 - 0x544E0003, // 005A LDINT R19 4 - 0x0C482413, // 005B DIV R18 R18 R19 - 0x00481812, // 005C ADD R18 R12 R18 - 0x0048240A, // 005D ADD R18 R18 R10 - 0x90463812, // 005E SETMBR R17 R284 R18 - 0x8844011E, // 005F GETMBR R17 R0 R286 - 0x8848011B, // 0060 GETMBR R18 R0 R283 - 0x8848251D, // 0061 GETMBR R18 R18 R285 - 0x90463A12, // 0062 SETMBR R17 R285 R18 - 0x8C44091F, // 0063 GETMET R17 R4 R287 - 0x884C011B, // 0064 GETMBR R19 R0 R283 - 0x8850011E, // 0065 GETMBR R20 R0 R286 - 0x5C540200, // 0066 MOVE R21 R1 - 0x8858010E, // 0067 GETMBR R22 R0 R270 - 0x7C440A00, // 0068 CALL R17 5 - 0x7001FFD3, // 0069 JMP #003E - 0x583C0020, // 006A LDCONST R15 K32 - 0xAC3C0200, // 006B CATCH R15 1 0 - 0xB0080000, // 006C RAISE 2 R0 R0 - 0x882C0921, // 006D GETMBR R11 R4 R289 - 0x80041600, // 006E RET 1 R11 + 0x8C140102, // 0002 GETMET R5 R0 R258 + 0x7C140200, // 0003 CALL R5 1 + 0x8C180103, // 0004 GETMET R6 R0 R259 + 0x7C180200, // 0005 CALL R6 1 + 0x8C1C0104, // 0006 GETMET R7 R0 R260 + 0x5426000E, // 0007 LDINT R9 15 + 0x0C240C09, // 0008 DIV R9 R6 R9 + 0x7C1C0400, // 0009 CALL R7 2 + 0x8C200104, // 000A GETMET R8 R0 R260 + 0x08280F05, // 000B MUL R10 R7 R261 + 0x04280C0A, // 000C SUB R10 R6 R10 + 0x542E0003, // 000D LDINT R11 4 + 0x0C28140B, // 000E DIV R10 R10 R11 + 0x7C200400, // 000F CALL R8 2 + 0x0C241106, // 0010 DIV R9 R8 R262 + 0x88280907, // 0011 GETMBR R10 R4 R263 + 0x1C28040A, // 0012 EQ R10 R2 R10 + 0x782A0007, // 0013 JMPF R10 #001C + 0x88280108, // 0014 GETMBR R10 R0 R264 + 0x8C281509, // 0015 GETMET R10 R10 R265 + 0x5C300000, // 0016 MOVE R12 R0 + 0x5C340200, // 0017 MOVE R13 R1 + 0x5C380400, // 0018 MOVE R14 R2 + 0x7C280800, // 0019 CALL R10 4 + 0x80041400, // 001A RET 1 R10 + 0x7002004F, // 001B JMP #006C + 0x8828090A, // 001C GETMBR R10 R4 R266 + 0x1C28040A, // 001D EQ R10 R2 R10 + 0x782A004C, // 001E JMPF R10 #006C + 0x8C28010B, // 001F GETMET R10 R0 R267 + 0x5C300200, // 0020 MOVE R12 R1 + 0x7C280400, // 0021 CALL R10 2 + 0x8828030C, // 0022 GETMBR R10 R1 R268 + 0x882C030D, // 0023 GETMBR R11 R1 R269 + 0x8C30090E, // 0024 GETMET R12 R4 R270 + 0x8838010F, // 0025 GETMBR R14 R0 R271 + 0x7C300400, // 0026 CALL R12 2 + 0x8C300110, // 0027 GETMET R12 R0 R272 + 0x88380911, // 0028 GETMBR R14 R4 R273 + 0x883C010F, // 0029 GETMBR R15 R0 R271 + 0x7C300600, // 002A CALL R12 3 + 0x8830010F, // 002B GETMBR R12 R0 R271 + 0x90322513, // 002C SETMBR R12 R274 R275 + 0x8830010F, // 002D GETMBR R12 R0 R271 + 0x90322913, // 002E SETMBR R12 R276 R275 + 0x8830010F, // 002F GETMBR R12 R0 R271 + 0x90322A08, // 0030 SETMBR R12 R277 R8 + 0x8C300116, // 0031 GETMET R12 R0 R278 + 0x88380911, // 0032 GETMBR R14 R4 R273 + 0x883C0917, // 0033 GETMBR R15 R4 R279 + 0x7C300600, // 0034 CALL R12 3 + 0x8C340118, // 0035 GETMET R13 R0 R280 + 0x883C0911, // 0036 GETMBR R15 R4 R273 + 0x88400917, // 0037 GETMBR R16 R4 R279 + 0x7C340600, // 0038 CALL R13 3 + 0x60380000, // 0039 GETGBL R14 G0 + 0x403E3305, // 003A CONNECT R15 R281 R261 + 0x7C380200, // 003B CALL R14 1 + 0xA802002B, // 003C EXBLK 0 #0069 + 0x5C3C1C00, // 003D MOVE R15 R14 + 0x7C3C0000, // 003E CALL R15 0 + 0x8840010F, // 003F GETMBR R16 R0 R271 + 0x8844011B, // 0040 GETMBR R17 R0 R283 + 0x00481F13, // 0041 ADD R18 R15 R275 + 0x544E0013, // 0042 LDINT R19 20 + 0x08482413, // 0043 MUL R18 R18 R19 + 0x28442212, // 0044 GE R17 R17 R18 + 0x78460001, // 0045 JMPF R17 #0048 + 0x5C441800, // 0046 MOVE R17 R12 + 0x70020000, // 0047 JMP #0049 + 0x5C441A00, // 0048 MOVE R17 R13 + 0x90423411, // 0049 SETMBR R16 R282 R17 + 0x8840011C, // 004A GETMBR R16 R0 R284 + 0x00441605, // 004B ADD R17 R11 R5 + 0x04442313, // 004C SUB R17 R17 R275 + 0x04442209, // 004D SUB R17 R17 R9 + 0x90423A11, // 004E SETMBR R16 R285 R17 + 0x8840011C, // 004F GETMBR R16 R0 R284 + 0x00441007, // 0050 ADD R17 R8 R7 + 0x08441E11, // 0051 MUL R17 R15 R17 + 0x00441411, // 0052 ADD R17 R10 R17 + 0x00442209, // 0053 ADD R17 R17 R9 + 0x90423C11, // 0054 SETMBR R16 R286 R17 + 0x8840011F, // 0055 GETMBR R16 R0 R287 + 0x04460A0F, // 0056 SUB R17 R261 R15 + 0x04480A08, // 0057 SUB R18 R5 R8 + 0x08442212, // 0058 MUL R17 R17 R18 + 0x544A0003, // 0059 LDINT R18 4 + 0x0C442212, // 005A DIV R17 R17 R18 + 0x00441611, // 005B ADD R17 R11 R17 + 0x00442209, // 005C ADD R17 R17 R9 + 0x90423A11, // 005D SETMBR R16 R285 R17 + 0x8840011F, // 005E GETMBR R16 R0 R287 + 0x8844011C, // 005F GETMBR R17 R0 R284 + 0x8844231E, // 0060 GETMBR R17 R17 R286 + 0x90423C11, // 0061 SETMBR R16 R286 R17 + 0x8C400920, // 0062 GETMET R16 R4 R288 + 0x8848011C, // 0063 GETMBR R18 R0 R284 + 0x884C011F, // 0064 GETMBR R19 R0 R287 + 0x5C500200, // 0065 MOVE R20 R1 + 0x8854010F, // 0066 GETMBR R21 R0 R271 + 0x7C400A00, // 0067 CALL R16 5 + 0x7001FFD3, // 0068 JMP #003D + 0x58380021, // 0069 LDCONST R14 K33 + 0xAC380200, // 006A CATCH R14 1 0 + 0xB0080000, // 006B RAISE 2 R0 R0 + 0x88280922, // 006C GETMBR R10 R4 R290 + 0x80041400, // 006D RET 1 R10 }) ) ); @@ -197,25 +246,29 @@ be_local_closure(my_design_cb, /* name */ /******************************************************************** -** Solidified function: get_percentage +** Solidified function: atleast1 ********************************************************************/ -be_local_closure(get_percentage, /* name */ +be_local_closure(atleast1, /* name */ be_nested_proto( - 2, /* nstack */ - 1, /* argc */ + 3, /* nstack */ + 2, /* argc */ 0, /* has upvals */ NULL, /* no upvals */ 0, /* has sup protos */ NULL, /* no sub protos */ 1, /* has constants */ ( &(const bvalue[ 1]) { /* constants */ - be_nested_string("percentage", -1756136011, 10), + be_const_int(1), }), - (be_nested_const_str("get_percentage", -1414483304, 14)), + (be_nested_const_str("atleast1", 1956331672, 8)), (be_nested_const_str("input", -103256197, 5)), - ( &(const binstruction[ 2]) { /* code */ - 0x88040100, // 0000 GETMBR R1 R0 R256 - 0x80040200, // 0001 RET 1 R1 + ( &(const binstruction[ 6]) { /* code */ + 0x28080300, // 0000 GE R2 R1 R256 + 0x780A0001, // 0001 JMPF R2 #0004 + 0x80040200, // 0002 RET 1 R1 + 0x70020000, // 0003 JMP #0005 + 0x80060000, // 0004 RET 1 R256 + 0x80000000, // 0005 RET 0 R0 }) ) ); @@ -292,50 +345,6 @@ be_local_closure(init, /* name */ /*******************************************************************/ -/******************************************************************** -** Solidified function: set_percentage -********************************************************************/ -be_local_closure(set_percentage, /* name */ - be_nested_proto( - 5, /* nstack */ - 2, /* argc */ - 0, /* has upvals */ - NULL, /* no upvals */ - 0, /* has sup protos */ - NULL, /* no sub protos */ - 1, /* has constants */ - ( &(const bvalue[ 3]) { /* constants */ - be_nested_string("percentage", -1756136011, 10), - be_const_int(0), - be_nested_string("invalidate", -1645232368, 10), - }), - (be_nested_const_str("set_percentage", -1342944572, 14)), - (be_nested_const_str("input", -103256197, 5)), - ( &(const binstruction[18]) { /* code */ - 0x88080100, // 0000 GETMBR R2 R0 R256 - 0x540E0004, // 0001 LDINT R3 5 - 0x0C080403, // 0002 DIV R2 R2 R3 - 0x540E0063, // 0003 LDINT R3 100 - 0x240C0203, // 0004 GT R3 R1 R3 - 0x780E0000, // 0005 JMPF R3 #0007 - 0x54060063, // 0006 LDINT R1 100 - 0x140C0301, // 0007 LT R3 R1 R257 - 0x780E0000, // 0008 JMPF R3 #000A - 0x58040001, // 0009 LDCONST R1 K1 - 0x90020001, // 000A SETMBR R0 R256 R1 - 0x540E0004, // 000B LDINT R3 5 - 0x0C0C0203, // 000C DIV R3 R1 R3 - 0x200C0403, // 000D NE R3 R2 R3 - 0x780E0001, // 000E JMPF R3 #0011 - 0x8C0C0102, // 000F GETMET R3 R0 R258 - 0x7C0C0200, // 0010 CALL R3 1 - 0x80000000, // 0011 RET 0 R0 - }) - ) -); -/*******************************************************************/ - - /******************************************************************** ** Solidified class: lv_signal_bars ********************************************************************/ @@ -343,18 +352,19 @@ extern const bclass be_class_lv_obj; be_local_class(lv_signal_bars, 6, &be_class_lv_obj, - be_nested_map(10, + be_nested_map(11, ( (struct bmapnode*) &(const bmapnode[]) { { be_nested_key("p1", -1605446022, 2, -1), be_const_index(2) }, - { be_nested_key("my_design_cb", -1173588798, 12, -1), be_const_closure(my_design_cb_closure) }, - { be_nested_key("get_percentage", -1414483304, 14, -1), be_const_closure(get_percentage_closure) }, - { be_nested_key("init", 380752755, 4, 7), be_const_closure(init_closure) }, - { be_nested_key("set_percentage", -1342944572, 14, 0), be_const_closure(set_percentage_closure) }, - { be_nested_key("percentage", -1756136011, 10, 3), be_const_index(1) }, - { be_nested_key("area", -1693507260, 4, -1), be_const_index(5) }, + { be_nested_key("get_percentage", -1414483304, 14, 5), be_const_closure(get_percentage_closure) }, + { be_nested_key("set_percentage", -1342944572, 14, -1), be_const_closure(set_percentage_closure) }, { be_nested_key("p2", -1622223641, 2, -1), be_const_index(3) }, - { be_nested_key("line_dsc", -200476318, 8, 1), be_const_index(4) }, { be_nested_key("ancestor_design", 421545719, 15, -1), be_const_index(0) }, + { be_nested_key("percentage", -1756136011, 10, 4), be_const_index(1) }, + { be_nested_key("line_dsc", -200476318, 8, -1), be_const_index(4) }, + { be_nested_key("my_design_cb", -1173588798, 12, -1), be_const_closure(my_design_cb_closure) }, + { be_nested_key("atleast1", 1956331672, 8, -1), be_const_closure(atleast1_closure) }, + { be_nested_key("init", 380752755, 4, 8), be_const_closure(init_closure) }, + { be_nested_key("area", -1693507260, 4, 3), be_const_index(5) }, })), (be_nested_const_str("lv_signal_bars", -780994737, 14)) ); diff --git a/tasmota/berry/lvgl_examples/lvgl_demo.be b/tasmota/berry/lvgl_examples/lvgl_demo.be index 34b0a735d..1f995772d 100644 --- a/tasmota/berry/lvgl_examples/lvgl_demo.be +++ b/tasmota/berry/lvgl_examples/lvgl_demo.be @@ -52,96 +52,6 @@ home_label = lv_label(home_btn) home_label.set_text(lv.SYMBOL_OK) - - -class lv_signal_bars : lv_obj - var ancestor_design # previous design_cb - var percentage - var p1, p2, line_dsc, area - - def init(parent, copy) - import global - var lv = global.lv - # init parent object - super(self, global.lv_obj).init(parent, copy) - # keep a copy of - self.ancestor_design = self.get_design_cb() - self.set_design_cb(self.my_design_cb) - # own values - self.percentage = 100 - # pre-allocate buffers - self.p1 = global.lv_point() - self.p2 = global.lv_point() - self.line_dsc = global.lv_draw_line_dsc() - self.area = global.lv_area() - end - - def my_design_cb(area, mode) - import global - var lv = global.lv - def atleast1(x) if x >= 1 return x else return 1 end end - # the model is that we have 4 bars and inter-bar (1/4 of width) - var height = self.get_height() - var width = self.get_width() - - var inter_bar = atleast1(width / 15) - var bar = atleast1((width - inter_bar * 3) / 4) - var bar_offset = bar / 2 - - if mode == lv.DESIGN_COVER_CHK - #- Return false if the object is not covers the clip_area area -# - return self.ancestor_design.call(self, area, mode) - - elif mode == lv.DESIGN_DRAW_MAIN - #self.ancestor_design.call(self, area, mode) - don't draw a background - - # get coordinates of area - self.get_coords(area) - var x_ofs = area.x1 - var y_ofs = area.y1 - - lv.draw_line_dsc_init(self.line_dsc) - self.init_draw_line_dsc(lv.OBJ_PART_MAIN, self.line_dsc) - - self.line_dsc.round_start = 1 - self.line_dsc.round_end = 1 - self.line_dsc.width = bar - var on_color = self.get_style_line_color(lv.OBJ_PART_MAIN, lv.STATE_DEFAULT) - var off_color = self.get_style_bg_color(lv.OBJ_PART_MAIN, lv.STATE_DEFAULT) - - for i:0..3 - self.line_dsc.color = self.percentage >= (i+1)*20 ? on_color : off_color - self.p1.y = y_ofs + height - 1 - bar_offset - self.p1.x = x_ofs + i * (bar + inter_bar) + bar_offset - self.p2.y = y_ofs + ((3 - i) * (height - bar)) / 4 + bar_offset - self.p2.x = self.p1.x - lv.draw_line(self.p1, self.p2, area, self.line_dsc) - end - #elif mode == lv.DESIGN_DRAW_POST # we don't want a frame around this object - #self.ancestor_design.call(self, area, mode) - end - return lv.DESIGN_RES_OK - end - - def set_percentage(v) - var old_bars = self.percentage / 5 - if v > 100 v = 100 end - if v < 0 v = 0 end - self.percentage = v - if old_bars != v / 5 - self.invalidate() # be frugal and avoid updating the widget if it's not needed - end - end - - def get_percentage() - return self.percentage - end -end - - - - - log_height = log.get_height() # log.get_style_pad_right(lv.OBJ_PART_MAIN, lv.STATE_DEFAULT) diff --git a/tasmota/berry/lvgl_examples/signal_bars.be b/tasmota/berry/lvgl_examples/signal_bars.be index be108e7b3..d66c05c36 100644 --- a/tasmota/berry/lvgl_examples/signal_bars.be +++ b/tasmota/berry/lvgl_examples/signal_bars.be @@ -27,16 +27,18 @@ class lv_signal_bars : lv_obj self.area = global.lv_area() end + def atleast1(x) if x >= 1 return x else return 1 end end + def my_design_cb(area, mode) import global var lv = global.lv - def atleast1(x) if x >= 1 return x else return 1 end end + #def atleast1(x) if x >= 1 return x else return 1 end end # the model is that we have 4 bars and inter-bar (1/4 of width) var height = self.get_height() var width = self.get_width() - var inter_bar = atleast1(width / 15) - var bar = atleast1((width - inter_bar * 3) / 4) + var inter_bar = self.atleast1(width / 15) + var bar = self.atleast1((width - inter_bar * 3) / 4) var bar_offset = bar / 2 if mode == lv.DESIGN_COVER_CHK