diff --git a/lib/libesp32/Berry/default/be_i2c_driverlib.c b/lib/libesp32/Berry/default/be_i2c_driverlib.c index 2f9faf038..3b44bc6df 100644 --- a/lib/libesp32/Berry/default/be_i2c_driverlib.c +++ b/lib/libesp32/Berry/default/be_i2c_driverlib.c @@ -14,379 +14,370 @@ extern bclass* be_class_tasmota_driver; // Parent class /******************************************************************** ** Solidified function: init ********************************************************************/ - -/********** Solidified proto: init */ -be_define_local_const_str(init_str_name, "init", 380752755, 4); -be_define_local_const_str(init_str_source, "input", -103256197, 5); -be_define_local_const_str(init_str_0, "get_tasmota", 334356779, 11); -be_define_local_const_str(init_str_1, "i2c_enabled", 218388101, 11); -be_define_local_const_str(init_str_2, "addr", 1087856498, 4); -be_define_local_const_str(init_str_3, "wire", -212213352, 4); -be_define_local_const_str(init_str_4, "wire_scan", -1623691416, 9); -be_define_local_const_str(init_str_5, "function", -1630125495, 8); -be_define_local_const_str(init_str_6, "name", -1925595674, 4); -be_define_local_const_str(init_str_7, "I2C:", 813483371, 4); -be_define_local_const_str(init_str_8, "detected on bus", 1432002650, 15); -be_define_local_const_str(init_str_9, "bus", 1607822841, 3); - -static const bvalue init_ktab[10] = { - { { .s=be_local_const_str(init_str_0) }, BE_STRING}, - { { .s=be_local_const_str(init_str_1) }, BE_STRING}, - { { .s=be_local_const_str(init_str_2) }, BE_STRING}, - { { .s=be_local_const_str(init_str_3) }, BE_STRING}, - { { .s=be_local_const_str(init_str_4) }, BE_STRING}, - { { .s=be_local_const_str(init_str_5) }, BE_STRING}, - { { .s=be_local_const_str(init_str_6) }, BE_STRING}, - { { .s=be_local_const_str(init_str_7) }, BE_STRING}, - { { .s=be_local_const_str(init_str_8) }, BE_STRING}, - { { .s=be_local_const_str(init_str_9) }, BE_STRING}, -}; - -static const uint32_t init_code[44] = { - 0x8C100100, // 0000 GETMET R4 R0 R256 - 0x7C100200, // 0001 CALL R4 1 - 0x4C140000, // 0002 LDNIL 5 - 0x20140605, // 0003 NE R5 R3 R5 - 0x78160004, // 0004 JMPF R5 #000A - 0x8C140901, // 0005 GETMET R5 R4 R257 - 0x5C1C0600, // 0006 MOVE R7 R3 - 0x7C140400, // 0007 CALL R5 2 - 0x74160000, // 0008 JMPT R5 #000A - 0x80000A00, // 0009 RET 0 R5 - 0x90020402, // 000A SETMBR R0 R258 R2 - 0x8C140904, // 000B GETMET R5 R4 R260 - 0x881C0102, // 000C GETMBR R7 R0 R258 - 0x7C140400, // 000D CALL R5 2 - 0x90020605, // 000E SETMBR R0 R259 R5 - 0x88140103, // 000F GETMBR R5 R0 R259 - 0x78160019, // 0010 JMPF R5 #002B - 0x60140015, // 0011 GETGBL R5 G21 - 0x5C180200, // 0012 MOVE R6 R1 - 0x7C140200, // 0013 CALL R5 1 - 0x1C140B05, // 0014 EQ R5 R5 R261 - 0x78160004, // 0015 JMPF R5 #001B - 0x5C140200, // 0016 MOVE R5 R1 - 0x5C180000, // 0017 MOVE R6 R0 - 0x7C140200, // 0018 CALL R5 1 - 0x90020C05, // 0019 SETMBR R0 R262 R5 - 0x70020000, // 001A JMP #001C - 0x90020C01, // 001B SETMBR R0 R262 R1 - 0x88140106, // 001C GETMBR R5 R0 R262 - 0x4C180000, // 001D LDNIL 6 - 0x1C140A06, // 001E EQ R5 R5 R6 - 0x78160001, // 001F JMPF R5 #0022 - 0x4C140000, // 0020 LDNIL 5 - 0x90020605, // 0021 SETMBR R0 R259 R5 - 0x88140103, // 0022 GETMBR R5 R0 R259 - 0x78160006, // 0023 JMPF R5 #002B - 0x6014000F, // 0024 GETGBL R5 G15 - 0x58180007, // 0025 LDCONST R6 K7 - 0x881C0106, // 0026 GETMBR R7 R0 R262 - 0x58200008, // 0027 LDCONST R8 K8 - 0x88240103, // 0028 GETMBR R9 R0 R259 - 0x88241309, // 0029 GETMBR R9 R9 R265 - 0x7C140800, // 002A CALL R5 4 - 0x80000000, // 002B RET 0 R0 -}; - -be_define_local_proto(init, 10, 4, 1, 0, 0); -be_define_local_closure(init); - +be_local_closure(init, /* name */ + be_nested_proto( + 10, /* nstack */ + 4, /* argc */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[10]) { /* constants */ + be_nested_string("get_tasmota", 334356779, 11), + be_nested_string("i2c_enabled", 218388101, 11), + be_nested_string("addr", 1087856498, 4), + be_nested_string("wire", -212213352, 4), + be_nested_string("wire_scan", -1623691416, 9), + be_nested_string("function", -1630125495, 8), + be_nested_string("name", -1925595674, 4), + be_nested_string("I2C:", 813483371, 4), + be_nested_string("detected on bus", 1432002650, 15), + be_nested_string("bus", 1607822841, 3), + }), + (be_nested_const_str("init", 380752755, 4)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[44]) { /* code */ + 0x8C100100, // 0000 GETMET R4 R0 R256 + 0x7C100200, // 0001 CALL R4 1 + 0x4C140000, // 0002 LDNIL 5 + 0x20140605, // 0003 NE R5 R3 R5 + 0x78160004, // 0004 JMPF R5 #000A + 0x8C140901, // 0005 GETMET R5 R4 R257 + 0x5C1C0600, // 0006 MOVE R7 R3 + 0x7C140400, // 0007 CALL R5 2 + 0x74160000, // 0008 JMPT R5 #000A + 0x80000A00, // 0009 RET 0 R5 + 0x90020402, // 000A SETMBR R0 R258 R2 + 0x8C140904, // 000B GETMET R5 R4 R260 + 0x881C0102, // 000C GETMBR R7 R0 R258 + 0x7C140400, // 000D CALL R5 2 + 0x90020605, // 000E SETMBR R0 R259 R5 + 0x88140103, // 000F GETMBR R5 R0 R259 + 0x78160019, // 0010 JMPF R5 #002B + 0x60140015, // 0011 GETGBL R5 G21 + 0x5C180200, // 0012 MOVE R6 R1 + 0x7C140200, // 0013 CALL R5 1 + 0x1C140B05, // 0014 EQ R5 R5 R261 + 0x78160004, // 0015 JMPF R5 #001B + 0x5C140200, // 0016 MOVE R5 R1 + 0x5C180000, // 0017 MOVE R6 R0 + 0x7C140200, // 0018 CALL R5 1 + 0x90020C05, // 0019 SETMBR R0 R262 R5 + 0x70020000, // 001A JMP #001C + 0x90020C01, // 001B SETMBR R0 R262 R1 + 0x88140106, // 001C GETMBR R5 R0 R262 + 0x4C180000, // 001D LDNIL 6 + 0x1C140A06, // 001E EQ R5 R5 R6 + 0x78160001, // 001F JMPF R5 #0022 + 0x4C140000, // 0020 LDNIL 5 + 0x90020605, // 0021 SETMBR R0 R259 R5 + 0x88140103, // 0022 GETMBR R5 R0 R259 + 0x78160006, // 0023 JMPF R5 #002B + 0x6014000F, // 0024 GETGBL R5 G15 + 0x58180007, // 0025 LDCONST R6 K7 + 0x881C0106, // 0026 GETMBR R7 R0 R262 + 0x58200008, // 0027 LDCONST R8 K8 + 0x88240103, // 0028 GETMBR R9 R0 R259 + 0x88241309, // 0029 GETMBR R9 R9 R265 + 0x7C140800, // 002A CALL R5 4 + 0x80000000, // 002B RET 0 R0 + }) + ) +); /*******************************************************************/ /******************************************************************** ** Solidified function: write8 ********************************************************************/ - -/********** Solidified proto: write8 */ -be_define_local_const_str(write8_str_name, "write8", -1160975764, 6); -be_define_local_const_str(write8_str_source, "input", -103256197, 5); -be_define_local_const_str(write8_str_0, "wire", -212213352, 4); -be_define_local_const_str(write8_str_1, "write", -1104765092, 5); -be_define_local_const_str(write8_str_2, "addr", 1087856498, 4); - -static const bvalue write8_ktab[4] = { - { { .s=be_local_const_str(write8_str_0) }, BE_STRING}, - { { .s=be_local_const_str(write8_str_1) }, BE_STRING}, - { { .s=be_local_const_str(write8_str_2) }, BE_STRING}, - { { .i=1 }, BE_INT}, -}; - -static const uint32_t write8_code[8] = { - 0x880C0100, // 0000 GETMBR R3 R0 R256 - 0x8C0C0701, // 0001 GETMET R3 R3 R257 - 0x88140102, // 0002 GETMBR R5 R0 R258 - 0x5C180200, // 0003 MOVE R6 R1 - 0x5C1C0400, // 0004 MOVE R7 R2 - 0x58200003, // 0005 LDCONST R8 K3 - 0x7C0C0A00, // 0006 CALL R3 5 - 0x80040600, // 0007 RET 1 R3 -}; - -be_define_local_proto(write8, 9, 3, 1, 0, 0); -be_define_local_closure(write8); - +be_local_closure(write8, /* name */ + be_nested_proto( + 9, /* nstack */ + 3, /* argc */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 4]) { /* constants */ + be_nested_string("wire", -212213352, 4), + be_nested_string("write", -1104765092, 5), + be_nested_string("addr", 1087856498, 4), + be_const_int(1), + }), + (be_nested_const_str("write8", -1160975764, 6)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[ 8]) { /* code */ + 0x880C0100, // 0000 GETMBR R3 R0 R256 + 0x8C0C0701, // 0001 GETMET R3 R3 R257 + 0x88140102, // 0002 GETMBR R5 R0 R258 + 0x5C180200, // 0003 MOVE R6 R1 + 0x5C1C0400, // 0004 MOVE R7 R2 + 0x58200003, // 0005 LDCONST R8 K3 + 0x7C0C0A00, // 0006 CALL R3 5 + 0x80040600, // 0007 RET 1 R3 + }) + ) +); /*******************************************************************/ /******************************************************************** ** Solidified function: write_bit ********************************************************************/ - -/********** Solidified proto: write_bit */ -be_define_local_const_str(write_bit_str_name, "write_bit", -1633976860, 9); -be_define_local_const_str(write_bit_str_source, "input", -103256197, 5); -be_define_local_const_str(write_bit_str_2, "write8", -1160975764, 6); -be_define_local_const_str(write_bit_str_3, "read8", -1492179129, 5); - -static const bvalue write_bit_ktab[4] = { - { { .i=0 }, BE_INT}, - { { .i=1 }, BE_INT}, - { { .s=be_local_const_str(write_bit_str_2) }, BE_STRING}, - { { .s=be_local_const_str(write_bit_str_3) }, BE_STRING}, -}; - -static const uint32_t write_bit_code[26] = { - 0x14100500, // 0000 LT R4 R2 R256 - 0x74120002, // 0001 JMPT R4 #0005 - 0x54120006, // 0002 LDINT R4 7 - 0x24100404, // 0003 GT R4 R2 R4 - 0x78120000, // 0004 JMPF R4 #0006 - 0x80000800, // 0005 RET 0 R4 - 0x38120202, // 0006 SHL R4 R257 R2 - 0x780E0007, // 0007 JMPF R3 #0010 - 0x8C140102, // 0008 GETMET R5 R0 R258 - 0x5C1C0200, // 0009 MOVE R7 R1 - 0x8C200103, // 000A GETMET R8 R0 R259 - 0x5C280200, // 000B MOVE R10 R1 - 0x7C200400, // 000C CALL R8 2 - 0x30201004, // 000D OR R8 R8 R4 - 0x7C140600, // 000E CALL R5 3 - 0x70020008, // 000F JMP #0019 - 0x8C140102, // 0010 GETMET R5 R0 R258 - 0x5C1C0200, // 0011 MOVE R7 R1 - 0x8C200103, // 0012 GETMET R8 R0 R259 - 0x5C280200, // 0013 MOVE R10 R1 - 0x7C200400, // 0014 CALL R8 2 - 0x542600FE, // 0015 LDINT R9 255 - 0x4241204, // 0016 SUB R9 R9 R4 - 0x2C201009, // 0017 AND R8 R8 R9 - 0x7C140600, // 0018 CALL R5 3 - 0x80000000, // 0019 RET 0 R0 -}; - -be_define_local_proto(write_bit, 11, 4, 1, 0, 0); -be_define_local_closure(write_bit); - +be_local_closure(write_bit, /* name */ + be_nested_proto( + 11, /* nstack */ + 4, /* argc */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 4]) { /* constants */ + be_const_int(0), + be_const_int(1), + be_nested_string("write8", -1160975764, 6), + be_nested_string("read8", -1492179129, 5), + }), + (be_nested_const_str("write_bit", -1633976860, 9)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[26]) { /* code */ + 0x14100500, // 0000 LT R4 R2 R256 + 0x74120002, // 0001 JMPT R4 #0005 + 0x54120006, // 0002 LDINT R4 7 + 0x24100404, // 0003 GT R4 R2 R4 + 0x78120000, // 0004 JMPF R4 #0006 + 0x80000800, // 0005 RET 0 R4 + 0x38120202, // 0006 SHL R4 R257 R2 + 0x780E0007, // 0007 JMPF R3 #0010 + 0x8C140102, // 0008 GETMET R5 R0 R258 + 0x5C1C0200, // 0009 MOVE R7 R1 + 0x8C200103, // 000A GETMET R8 R0 R259 + 0x5C280200, // 000B MOVE R10 R1 + 0x7C200400, // 000C CALL R8 2 + 0x30201004, // 000D OR R8 R8 R4 + 0x7C140600, // 000E CALL R5 3 + 0x70020008, // 000F JMP #0019 + 0x8C140102, // 0010 GETMET R5 R0 R258 + 0x5C1C0200, // 0011 MOVE R7 R1 + 0x8C200103, // 0012 GETMET R8 R0 R259 + 0x5C280200, // 0013 MOVE R10 R1 + 0x7C200400, // 0014 CALL R8 2 + 0x542600FE, // 0015 LDINT R9 255 + 0x04241204, // 0016 SUB R9 R9 R4 + 0x2C201009, // 0017 AND R8 R8 R9 + 0x7C140600, // 0018 CALL R5 3 + 0x80000000, // 0019 RET 0 R0 + }) + ) +); /*******************************************************************/ - /******************************************************************** ** Solidified function: read8 ********************************************************************/ - -/********** Solidified proto: read8 */ -be_define_local_const_str(read8_str_name, "read8", -1492179129, 5); -be_define_local_const_str(read8_str_source, "input", -103256197, 5); -be_define_local_const_str(read8_str_0, "wire", -212213352, 4); -be_define_local_const_str(read8_str_1, "read", -824204347, 4); -be_define_local_const_str(read8_str_2, "addr", 1087856498, 4); - -static const bvalue read8_ktab[4] = { - { { .s=be_local_const_str(read8_str_0) }, BE_STRING}, - { { .s=be_local_const_str(read8_str_1) }, BE_STRING}, - { { .s=be_local_const_str(read8_str_2) }, BE_STRING}, - { { .i=1 }, BE_INT}, -}; - -static const uint32_t read8_code[7] = { - 0x88080100, // 0000 GETMBR R2 R0 R256 - 0x8C080501, // 0001 GETMET R2 R2 R257 - 0x88100102, // 0002 GETMBR R4 R0 R258 - 0x5C140200, // 0003 MOVE R5 R1 - 0x58180003, // 0004 LDCONST R6 K3 - 0x7C080800, // 0005 CALL R2 4 - 0x80040400, // 0006 RET 1 R2 -}; - -be_define_local_proto(read8, 7, 2, 1, 0, 0); -be_define_local_closure(read8); - +be_local_closure(read8, /* name */ + be_nested_proto( + 7, /* nstack */ + 2, /* argc */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 4]) { /* constants */ + be_nested_string("wire", -212213352, 4), + be_nested_string("read", -824204347, 4), + be_nested_string("addr", 1087856498, 4), + be_const_int(1), + }), + (be_nested_const_str("read8", -1492179129, 5)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[ 7]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 R256 + 0x8C080501, // 0001 GETMET R2 R2 R257 + 0x88100102, // 0002 GETMBR R4 R0 R258 + 0x5C140200, // 0003 MOVE R5 R1 + 0x58180003, // 0004 LDCONST R6 K3 + 0x7C080800, // 0005 CALL R2 4 + 0x80040400, // 0006 RET 1 R2 + }) + ) +); /*******************************************************************/ /******************************************************************** ** Solidified function: read12 ********************************************************************/ - -/********** Solidified proto: read12 */ -be_define_local_const_str(read12_str_name, "read12", -3890326, 6); -be_define_local_const_str(read12_str_source, "input", -103256197, 5); -be_define_local_const_str(read12_str_0, "wire", -212213352, 4); -be_define_local_const_str(read12_str_1, "read_bytes", -718234123, 10); -be_define_local_const_str(read12_str_2, "addr", 1087856498, 4); - -static const bvalue read12_ktab[6] = { - { { .s=be_local_const_str(read12_str_0) }, BE_STRING}, - { { .s=be_local_const_str(read12_str_1) }, BE_STRING}, - { { .s=be_local_const_str(read12_str_2) }, BE_STRING}, - { { .i=2 }, BE_INT}, - { { .i=0 }, BE_INT}, - { { .i=1 }, BE_INT}, -}; - -static const uint32_t read12_code[12] = { - 0x88080100, // 0000 GETMBR R2 R0 R256 - 0x8C080501, // 0001 GETMET R2 R2 R257 - 0x88100102, // 0002 GETMBR R4 R0 R258 - 0x5C140200, // 0003 MOVE R5 R1 - 0x58180003, // 0004 LDCONST R6 K3 - 0x7C080800, // 0005 CALL R2 4 - 0x940C0504, // 0006 GETIDX R3 R2 R260 - 0x54120003, // 0007 LDINT R4 4 - 0x380C0604, // 0008 SHL R3 R3 R4 - 0x94100505, // 0009 GETIDX R4 R2 R261 - 0xC0604, // 000A ADD R3 R3 R4 - 0x80040600, // 000B RET 1 R3 -}; - -be_define_local_proto(read12, 7, 2, 1, 0, 0); -be_define_local_closure(read12); - +be_local_closure(read12, /* name */ + be_nested_proto( + 7, /* nstack */ + 2, /* argc */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 6]) { /* constants */ + be_nested_string("wire", -212213352, 4), + be_nested_string("read_bytes", -718234123, 10), + be_nested_string("addr", 1087856498, 4), + be_const_int(2), + be_const_int(0), + be_const_int(1), + }), + (be_nested_const_str("read12", -3890326, 6)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[12]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 R256 + 0x8C080501, // 0001 GETMET R2 R2 R257 + 0x88100102, // 0002 GETMBR R4 R0 R258 + 0x5C140200, // 0003 MOVE R5 R1 + 0x58180003, // 0004 LDCONST R6 K3 + 0x7C080800, // 0005 CALL R2 4 + 0x940C0504, // 0006 GETIDX R3 R2 R260 + 0x54120003, // 0007 LDINT R4 4 + 0x380C0604, // 0008 SHL R3 R3 R4 + 0x94100505, // 0009 GETIDX R4 R2 R261 + 0x000C0604, // 000A ADD R3 R3 R4 + 0x80040600, // 000B RET 1 R3 + }) + ) +); /*******************************************************************/ - /******************************************************************** ** Solidified function: read13 ********************************************************************/ - -/********** Solidified proto: read13 */ -be_define_local_const_str(read13_str_name, "read13", 12887293, 6); -be_define_local_const_str(read13_str_source, "input", -103256197, 5); -be_define_local_const_str(read13_str_0, "wire", -212213352, 4); -be_define_local_const_str(read13_str_1, "read_bytes", -718234123, 10); -be_define_local_const_str(read13_str_2, "addr", 1087856498, 4); - -static const bvalue read13_ktab[6] = { - { { .s=be_local_const_str(read13_str_0) }, BE_STRING}, - { { .s=be_local_const_str(read13_str_1) }, BE_STRING}, - { { .s=be_local_const_str(read13_str_2) }, BE_STRING}, - { { .i=2 }, BE_INT}, - { { .i=0 }, BE_INT}, - { { .i=1 }, BE_INT}, -}; - -static const uint32_t read13_code[12] = { - 0x88080100, // 0000 GETMBR R2 R0 R256 - 0x8C080501, // 0001 GETMET R2 R2 R257 - 0x88100102, // 0002 GETMBR R4 R0 R258 - 0x5C140200, // 0003 MOVE R5 R1 - 0x58180003, // 0004 LDCONST R6 K3 - 0x7C080800, // 0005 CALL R2 4 - 0x940C0504, // 0006 GETIDX R3 R2 R260 - 0x54120004, // 0007 LDINT R4 5 - 0x380C0604, // 0008 SHL R3 R3 R4 - 0x94100505, // 0009 GETIDX R4 R2 R261 - 0xC0604, // 000A ADD R3 R3 R4 - 0x80040600, // 000B RET 1 R3 -}; - -be_define_local_proto(read13, 7, 2, 1, 0, 0); -be_define_local_closure(read13); - +be_local_closure(read13, /* name */ + be_nested_proto( + 7, /* nstack */ + 2, /* argc */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 6]) { /* constants */ + be_nested_string("wire", -212213352, 4), + be_nested_string("read_bytes", -718234123, 10), + be_nested_string("addr", 1087856498, 4), + be_const_int(2), + be_const_int(0), + be_const_int(1), + }), + (be_nested_const_str("read13", 12887293, 6)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[12]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 R256 + 0x8C080501, // 0001 GETMET R2 R2 R257 + 0x88100102, // 0002 GETMBR R4 R0 R258 + 0x5C140200, // 0003 MOVE R5 R1 + 0x58180003, // 0004 LDCONST R6 K3 + 0x7C080800, // 0005 CALL R2 4 + 0x940C0504, // 0006 GETIDX R3 R2 R260 + 0x54120004, // 0007 LDINT R4 5 + 0x380C0604, // 0008 SHL R3 R3 R4 + 0x94100505, // 0009 GETIDX R4 R2 R261 + 0x000C0604, // 000A ADD R3 R3 R4 + 0x80040600, // 000B RET 1 R3 + }) + ) +); /*******************************************************************/ - /******************************************************************** ** Solidified function: read24 ********************************************************************/ - -/********** Solidified proto: read24 */ -be_define_local_const_str(read24_str_name, "read24", 1808533811, 6); -be_define_local_const_str(read24_str_source, "input", -103256197, 5); -be_define_local_const_str(read24_str_0, "wire", -212213352, 4); -be_define_local_const_str(read24_str_1, "read_bytes", -718234123, 10); -be_define_local_const_str(read24_str_2, "addr", 1087856498, 4); - -static const bvalue read24_ktab[7] = { - { { .s=be_local_const_str(read24_str_0) }, BE_STRING}, - { { .s=be_local_const_str(read24_str_1) }, BE_STRING}, - { { .s=be_local_const_str(read24_str_2) }, BE_STRING}, - { { .i=3 }, BE_INT}, - { { .i=0 }, BE_INT}, - { { .i=1 }, BE_INT}, - { { .i=2 }, BE_INT}, -}; - -static const uint32_t read24_code[16] = { - 0x88080100, // 0000 GETMBR R2 R0 R256 - 0x8C080501, // 0001 GETMET R2 R2 R257 - 0x88100102, // 0002 GETMBR R4 R0 R258 - 0x5C140200, // 0003 MOVE R5 R1 - 0x58180003, // 0004 LDCONST R6 K3 - 0x7C080800, // 0005 CALL R2 4 - 0x940C0504, // 0006 GETIDX R3 R2 R260 - 0x5412000F, // 0007 LDINT R4 16 - 0x380C0604, // 0008 SHL R3 R3 R4 - 0x94100505, // 0009 GETIDX R4 R2 R261 - 0x54160007, // 000A LDINT R5 8 - 0x38100805, // 000B SHL R4 R4 R5 - 0xC0604, // 000C ADD R3 R3 R4 - 0x94100506, // 000D GETIDX R4 R2 R262 - 0xC0604, // 000E ADD R3 R3 R4 - 0x80040600, // 000F RET 1 R3 -}; - -be_define_local_proto(read24, 7, 2, 1, 0, 0); -be_define_local_closure(read24); - +be_local_closure(read24, /* name */ + be_nested_proto( + 7, /* nstack */ + 2, /* argc */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 7]) { /* constants */ + be_nested_string("wire", -212213352, 4), + be_nested_string("read_bytes", -718234123, 10), + be_nested_string("addr", 1087856498, 4), + be_const_int(3), + be_const_int(0), + be_const_int(1), + be_const_int(2), + }), + (be_nested_const_str("read24", 1808533811, 6)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[16]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 R256 + 0x8C080501, // 0001 GETMET R2 R2 R257 + 0x88100102, // 0002 GETMBR R4 R0 R258 + 0x5C140200, // 0003 MOVE R5 R1 + 0x58180003, // 0004 LDCONST R6 K3 + 0x7C080800, // 0005 CALL R2 4 + 0x940C0504, // 0006 GETIDX R3 R2 R260 + 0x5412000F, // 0007 LDINT R4 16 + 0x380C0604, // 0008 SHL R3 R3 R4 + 0x94100505, // 0009 GETIDX R4 R2 R261 + 0x54160007, // 000A LDINT R5 8 + 0x38100805, // 000B SHL R4 R4 R5 + 0x000C0604, // 000C ADD R3 R3 R4 + 0x94100506, // 000D GETIDX R4 R2 R262 + 0x000C0604, // 000E ADD R3 R3 R4 + 0x80040600, // 000F RET 1 R3 + }) + ) +); /*******************************************************************/ /******************************************************************** ** Solidified function: read32 ********************************************************************/ - -/********** Solidified proto: read32 */ -be_define_local_const_str(read32_str_name, "read32", 1741276240, 6); -be_define_local_const_str(read32_str_source, "input", -103256197, 5); -be_define_local_const_str(read32_str_0, "wire", -212213352, 4); -be_define_local_const_str(read32_str_1, "read_bytes", -718234123, 10); -be_define_local_const_str(read32_str_2, "addr", 1087856498, 4); - -static const bvalue read32_ktab[7] = { - { { .s=be_local_const_str(read32_str_0) }, BE_STRING}, - { { .s=be_local_const_str(read32_str_1) }, BE_STRING}, - { { .s=be_local_const_str(read32_str_2) }, BE_STRING}, - { { .i=0 }, BE_INT}, - { { .i=1 }, BE_INT}, - { { .i=2 }, BE_INT}, - { { .i=3 }, BE_INT}, -}; - -static const uint32_t read32_code[20] = { - 0x88080100, // 0000 GETMBR R2 R0 R256 - 0x8C080501, // 0001 GETMET R2 R2 R257 - 0x88100102, // 0002 GETMBR R4 R0 R258 - 0x5C140200, // 0003 MOVE R5 R1 - 0x541A0003, // 0004 LDINT R6 4 - 0x7C080800, // 0005 CALL R2 4 - 0x940C0503, // 0006 GETIDX R3 R2 R259 - 0x54120017, // 0007 LDINT R4 24 - 0x380C0604, // 0008 SHL R3 R3 R4 - 0x94100504, // 0009 GETIDX R4 R2 R260 - 0x5416000F, // 000A LDINT R5 16 - 0x38100805, // 000B SHL R4 R4 R5 - 0xC0604, // 000C ADD R3 R3 R4 - 0x94100505, // 000D GETIDX R4 R2 R261 - 0x54160007, // 000E LDINT R5 8 - 0x38100805, // 000F SHL R4 R4 R5 - 0xC0604, // 0010 ADD R3 R3 R4 - 0x94100506, // 0011 GETIDX R4 R2 R262 - 0xC0604, // 0012 ADD R3 R3 R4 - 0x80040600, // 0013 RET 1 R3 -}; - -be_define_local_proto(read32, 7, 2, 1, 0, 0); -be_define_local_closure(read32); - +be_local_closure(read32, /* name */ + be_nested_proto( + 7, /* nstack */ + 2, /* argc */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 7]) { /* constants */ + be_nested_string("wire", -212213352, 4), + be_nested_string("read_bytes", -718234123, 10), + be_nested_string("addr", 1087856498, 4), + be_const_int(0), + be_const_int(1), + be_const_int(2), + be_const_int(3), + }), + (be_nested_const_str("read32", 1741276240, 6)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[20]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 R256 + 0x8C080501, // 0001 GETMET R2 R2 R257 + 0x88100102, // 0002 GETMBR R4 R0 R258 + 0x5C140200, // 0003 MOVE R5 R1 + 0x541A0003, // 0004 LDINT R6 4 + 0x7C080800, // 0005 CALL R2 4 + 0x940C0503, // 0006 GETIDX R3 R2 R259 + 0x54120017, // 0007 LDINT R4 24 + 0x380C0604, // 0008 SHL R3 R3 R4 + 0x94100504, // 0009 GETIDX R4 R2 R260 + 0x5416000F, // 000A LDINT R5 16 + 0x38100805, // 000B SHL R4 R4 R5 + 0x000C0604, // 000C ADD R3 R3 R4 + 0x94100505, // 000D GETIDX R4 R2 R261 + 0x54160007, // 000E LDINT R5 8 + 0x38100805, // 000F SHL R4 R4 R5 + 0x000C0604, // 0010 ADD R3 R3 R4 + 0x94100506, // 0011 GETIDX R4 R2 R262 + 0x000C0604, // 0012 ADD R3 R3 R4 + 0x80040600, // 0013 RET 1 R3 + }) + ) +); /*******************************************************************/ diff --git a/lib/libesp32/Berry/default/be_lv_lvgl_module.c b/lib/libesp32/Berry/default/be_lv_lvgl_module.c index 6d47ffbb9..4785b3621 100644 --- a/lib/libesp32/Berry/default/be_lv_lvgl_module.c +++ b/lib/libesp32/Berry/default/be_lv_lvgl_module.c @@ -34,6 +34,7 @@ static int lv_get_ver_res(void) { /* `lv` methods */ const lvbe_call_c_t lv_func[] = { + { "color_mix", (void*) &lv_color_mix, "lv_color", "(lv_color)(lv_color)i" }, { "draw_arc", (void*) &lv_draw_arc, "", "iiiii(lv_area)(lv_draw_line_dsc)" }, { "draw_img", (void*) &lv_draw_img, "", "(lv_area)(lv_area).(lv_draw_img_dsc)" }, { "draw_img_dsc_init", (void*) &lv_draw_img_dsc_init, "", "(lv_draw_img_dsc)" }, @@ -54,6 +55,7 @@ const lvbe_call_c_t lv_func[] = { { "draw_polygon", (void*) &lv_draw_polygon, "", "ii(lv_area)(lv_draw_rect_dsc)" }, { "draw_px", (void*) &lv_draw_px, "", "(lv_point)(lv_area)(lv_style)" }, { "draw_rect", (void*) &lv_draw_rect, "", "(lv_area)(lv_area)(lv_draw_rect_dsc)" }, + { "draw_rect_dsc_init", (void*) &lv_draw_rect_dsc_init, "", "(lv_draw_rect_dsc)" }, { "draw_triangle", (void*) &lv_draw_triangle, "", "i(lv_area)(lv_draw_rect_dsc)" }, { "event_get_data", (void*) &lv_event_get_data, ".", "" }, { "event_send", (void*) &lv_event_send, "i", "(lv_obj)i." }, diff --git a/lib/libesp32/Berry/default/be_lvgl_color_lib.c b/lib/libesp32/Berry/default/be_lvgl_color_lib.c index d76fd8ced..27eabbbd1 100644 --- a/lib/libesp32/Berry/default/be_lvgl_color_lib.c +++ b/lib/libesp32/Berry/default/be_lvgl_color_lib.c @@ -9,6 +9,7 @@ extern int lco_init(bvm *vm); // generic function extern int lco_tostring(bvm *vm); // generic function +extern int lco_toint(bvm *vm); // generic function #if BE_USE_PRECOMPILED_OBJECT @@ -21,6 +22,7 @@ void be_load_lvgl_color_lib(bvm *vm) { { ".p", NULL }, // keeping track of styles to avoid GC { "init", lco_init }, { "tostring", lco_tostring }, + { "toint", lco_toint }, // { NULL, (bntvfunc) BE_CLOSURE }, /* mark section for berry closures */ @@ -39,6 +41,7 @@ class be_class_lv_color (scope: global, name: lv_color) { .p, var init, func(lco_init) tostring, func(lco_tostring) + toint, func(lco_toint) } @const_object_info_end */ diff --git a/lib/libesp32/Berry/default/be_lvgl_ctypes.c b/lib/libesp32/Berry/default/be_lvgl_ctypes.c index a3b50440d..a8932a39f 100644 --- a/lib/libesp32/Berry/default/be_lvgl_ctypes.c +++ b/lib/libesp32/Berry/default/be_lvgl_ctypes.c @@ -38,7 +38,6 @@ int32_t bin_search_ctypes(const char * needle, const void * table, size_t elt_si enum { - ctypes_i32 = 14, ctypes_i16 = 12, ctypes_i8 = 11, @@ -62,7 +61,8 @@ typedef struct be_ctypes_structure_item_t { uint16_t offset_bytes; uint8_t offset_bits : 3; uint8_t len_bits : 5; - int8_t type; + int8_t type : 5; + uint8_t mapping : 3; } be_ctypes_structure_item_t; typedef struct be_ctypes_structure_t { @@ -78,6 +78,7 @@ typedef struct be_ctypes_class_t { typedef struct be_ctypes_classes_t { uint16_t size; + const char **instance_mapping; /* array of instance class names for automatic instanciation of class */ const be_ctypes_class_t * classes; } be_ctypes_classes_t; @@ -176,7 +177,7 @@ int be_ctypes_member(bvm *vm) { be_pushint(vm, member->len_bits); be_call(vm, 3); be_pop(vm, 3); - be_return(vm); + // int result at top of stack } else { // general int support int size = member->type; // eventually 1/2/4, positive if little endian, negative if big endian @@ -196,8 +197,28 @@ int be_ctypes_member(bvm *vm) { be_pushint(vm, size); be_call(vm, 3); be_pop(vm, 3); - be_return(vm); + // int result at top of stack } + // the int result is at top of the stack + // check if we need an instance mapping + if (member->mapping > 0) { + // find the name of the class + + // get global array of classes from global variable '.ctypes_classes' + be_getglobal(vm, ".ctypes_classes"); + const be_ctypes_classes_t * be_ctypes_classes = (const be_ctypes_classes_t *) be_tocomptr(vm, -1); + be_pop(vm, 1); + + const char * mapping_name = be_ctypes_classes->instance_mapping[member->mapping - 1]; + if (mapping_name) { + be_getglobal(vm, mapping_name); // stack: class + be_pushvalue(vm, -2); // stack: class, value + be_pushint(vm, -1); // stack; class, value, -1 + be_call(vm, 2); // call constructor with 2 parameters + be_pop(vm, 2); // leave new instance on top of stack + } + } + be_return(vm); } be_return_nil(vm); @@ -209,6 +230,22 @@ int be_ctypes_member(bvm *vm) { // 3: value int be_ctypes_setmember(bvm *vm) { int argc = be_top(vm); + + // If the value is an instance, we call 'toint()' and replace the value + if (be_isinstance(vm, 3)) { + + be_getmember(vm, 3, "toint"); + if (!be_isnil(vm, -1)) { + be_pushvalue(vm, 3); + be_call(vm, 1); + be_pop(vm, 1); + be_moveto(vm, -1, 3); + } else { + be_raise(vm, "value_error", "Value is an instance without 'toint()' method"); + } + be_pop(vm, 1); + } + be_getmember(vm, 1, ".def"); const be_ctypes_structure_t *definitions; definitions = (const be_ctypes_structure_t *) be_tocomptr(vm, -1); diff --git a/lib/libesp32/Berry/default/be_lvgl_ctypes_definitions.c b/lib/libesp32/Berry/default/be_lvgl_ctypes_definitions.c index 767e3830e..e40f4edde 100644 --- a/lib/libesp32/Berry/default/be_lvgl_ctypes_definitions.c +++ b/lib/libesp32/Berry/default/be_lvgl_ctypes_definitions.c @@ -7,8 +7,11 @@ #include "lvgl.h" -enum { +/******************************************************************** + * Generated code, don't edit + *******************************************************************/ +enum { ctypes_i32 = 14, ctypes_i16 = 12, ctypes_i8 = 11, @@ -32,7 +35,8 @@ typedef struct be_ctypes_structure_item_t { uint16_t offset_bytes; uint8_t offset_bits : 3; uint8_t len_bits : 5; - int8_t type; + int8_t type : 5; + uint8_t mapping : 3; } be_ctypes_structure_item_t; typedef struct be_ctypes_structure_t { @@ -48,368 +52,337 @@ typedef struct be_ctypes_class_t { typedef struct be_ctypes_classes_t { uint16_t size; + const char **instance_mapping; /* array of instance class names for automatic instanciation of class */ const be_ctypes_class_t * classes; } be_ctypes_classes_t; -// extern const be_ctypes_class_t *g_ctypes_classes; - - BE_EXPORT_VARIABLE extern const bclass be_class_lv_ctypes; - - -// const be_ctypes_structure_t be_lv_area_t = { -// 4, -// (const be_ctypes_structure_item_t[4]) { -// { "x1", 0, 16, ctypes_int }, -// { "x2", 32, 16, ctypes_int }, -// { "y1", 16, 16, ctypes_int }, -// { "y2", 48, 16, ctypes_int }, -// // }}; - -// #if BE_USE_PRECOMPILED_OBJECT -// #include "../generate/be_fixed_be_class_lv_area_t.h" -// #endif - -// void be_load_lvgl_lv_area_t_lib(bvm *vm) { -// #if !BE_USE_PRECOMPILED_OBJECT -// static const bnfuncinfo members[] = { -// { NULL, NULL } -// }; -// be_regclass(vm, "lv_area_t", members); - -// be_getglobal(vm, "lv_area_t"); -// be_getglobal(vm, "lv_ctypes"); -// be_setsuper(vm, -2); -// be_pop(vm, 2); -// #else -// be_pushntvclass(vm, &be_class_lv_area_t); -// be_setglobal(vm, "lv_area_t"); -// be_pop(vm, 1); -// #endif -// } - void ctypes_register_class(bvm *vm, const bclass * ctypes_class, const be_ctypes_structure_t * definitions) { be_pushntvclass(vm, ctypes_class); be_setglobal(vm, str(ctypes_class->name)); be_pop(vm, 1); } -/******************************************************************** - * Generated code, don't edit - *******************************************************************/ +/********************************************************************/ const be_ctypes_structure_t be_lv_point = { 4, /* size in bytes */ 2, /* number of elements */ (const be_ctypes_structure_item_t[2]) { - { "x", 0, 0, 0, 12 }, - { "y", 2, 0, 0, 12 }, + { "x", 0, 0, 0, 12, 0 }, + { "y", 2, 0, 0, 12, 0 }, }}; const be_ctypes_structure_t be_lv_area = { 8, /* size in bytes */ 4, /* number of elements */ (const be_ctypes_structure_item_t[4]) { - { "x1", 0, 0, 0, 12 }, - { "x2", 4, 0, 0, 12 }, - { "y1", 2, 0, 0, 12 }, - { "y2", 6, 0, 0, 12 }, + { "x1", 0, 0, 0, 12, 0 }, + { "x2", 4, 0, 0, 12, 0 }, + { "y1", 2, 0, 0, 12, 0 }, + { "y2", 6, 0, 0, 12, 0 }, }}; const be_ctypes_structure_t be_lv_draw_rect_dsc = { 77, /* size in bytes */ 43, /* number of elements */ (const be_ctypes_structure_item_t[43]) { - { "bg_blend_mode", 12, 0, 0, 1 }, - { "bg_color", 2, 0, 0, 2 }, - { "bg_grad_color", 4, 0, 0, 2 }, - { "bg_grad_color_stop", 9, 0, 0, 12 }, - { "bg_grad_dir", 6, 0, 0, 1 }, - { "bg_main_color_stop", 7, 0, 0, 12 }, - { "bg_opa", 11, 0, 0, 1 }, - { "border_blend_mode", 20, 0, 0, 1 }, - { "border_color", 13, 0, 0, 2 }, - { "border_opa", 19, 0, 0, 1 }, - { "border_post", 21, 0, 1, 0 }, - { "border_side", 17, 0, 0, 12 }, - { "border_width", 15, 0, 0, 12 }, - { "outline_blend_mode", 29, 0, 0, 1 }, - { "outline_color", 22, 0, 0, 2 }, - { "outline_opa", 28, 0, 0, 1 }, - { "outline_pad", 26, 0, 0, 12 }, - { "outline_width", 24, 0, 0, 12 }, - { "pattern_blend_mode", 55, 0, 0, 1 }, - { "pattern_font", 46, 0, 0, 4 }, - { "pattern_image", 42, 0, 0, 4 }, - { "pattern_opa", 52, 0, 0, 1 }, - { "pattern_recolor", 50, 0, 0, 2 }, - { "pattern_recolor_opa", 53, 0, 0, 1 }, - { "pattern_repeat", 54, 0, 1, 0 }, - { "radius", 0, 0, 0, 12 }, - { "shadow_blend_mode", 41, 0, 0, 1 }, - { "shadow_color", 30, 0, 0, 2 }, - { "shadow_ofs_x", 34, 0, 0, 12 }, - { "shadow_ofs_y", 36, 0, 0, 12 }, - { "shadow_opa", 40, 0, 0, 1 }, - { "shadow_spread", 38, 0, 0, 12 }, - { "shadow_width", 32, 0, 0, 12 }, - { "value_align", 75, 0, 0, 1 }, - { "value_blend_mode", 76, 0, 0, 1 }, - { "value_color", 65, 0, 0, 2 }, - { "value_font", 60, 0, 0, 4 }, - { "value_letter_space", 71, 0, 0, 12 }, - { "value_line_space", 73, 0, 0, 12 }, - { "value_ofs_x", 67, 0, 0, 12 }, - { "value_ofs_y", 69, 0, 0, 12 }, - { "value_opa", 64, 0, 0, 1 }, - { "value_str", 56, 0, 0, 4 }, + { "bg_blend_mode", 12, 0, 0, 1, 0 }, + { "bg_color", 2, 0, 0, 2, 1 }, + { "bg_grad_color", 4, 0, 0, 2, 1 }, + { "bg_grad_color_stop", 9, 0, 0, 12, 0 }, + { "bg_grad_dir", 6, 0, 0, 1, 0 }, + { "bg_main_color_stop", 7, 0, 0, 12, 0 }, + { "bg_opa", 11, 0, 0, 1, 0 }, + { "border_blend_mode", 20, 0, 0, 1, 0 }, + { "border_color", 13, 0, 0, 2, 1 }, + { "border_opa", 19, 0, 0, 1, 0 }, + { "border_post", 21, 0, 1, 0, 0 }, + { "border_side", 17, 0, 0, 12, 0 }, + { "border_width", 15, 0, 0, 12, 0 }, + { "outline_blend_mode", 29, 0, 0, 1, 0 }, + { "outline_color", 22, 0, 0, 2, 1 }, + { "outline_opa", 28, 0, 0, 1, 0 }, + { "outline_pad", 26, 0, 0, 12, 0 }, + { "outline_width", 24, 0, 0, 12, 0 }, + { "pattern_blend_mode", 55, 0, 0, 1, 0 }, + { "pattern_font", 46, 0, 0, 4, 0 }, + { "pattern_image", 42, 0, 0, 4, 0 }, + { "pattern_opa", 52, 0, 0, 1, 0 }, + { "pattern_recolor", 50, 0, 0, 2, 1 }, + { "pattern_recolor_opa", 53, 0, 0, 1, 0 }, + { "pattern_repeat", 54, 0, 1, 0, 0 }, + { "radius", 0, 0, 0, 12, 0 }, + { "shadow_blend_mode", 41, 0, 0, 1, 0 }, + { "shadow_color", 30, 0, 0, 2, 1 }, + { "shadow_ofs_x", 34, 0, 0, 12, 0 }, + { "shadow_ofs_y", 36, 0, 0, 12, 0 }, + { "shadow_opa", 40, 0, 0, 1, 0 }, + { "shadow_spread", 38, 0, 0, 12, 0 }, + { "shadow_width", 32, 0, 0, 12, 0 }, + { "value_align", 75, 0, 0, 1, 0 }, + { "value_blend_mode", 76, 0, 0, 1, 0 }, + { "value_color", 65, 0, 0, 2, 1 }, + { "value_font", 60, 0, 0, 4, 0 }, + { "value_letter_space", 71, 0, 0, 12, 0 }, + { "value_line_space", 73, 0, 0, 12, 0 }, + { "value_ofs_x", 67, 0, 0, 12, 0 }, + { "value_ofs_y", 69, 0, 0, 12, 0 }, + { "value_opa", 64, 0, 0, 1, 0 }, + { "value_str", 56, 0, 0, 4, 0 }, }}; const be_ctypes_structure_t be_lv_draw_line_dsc = { 10, /* size in bytes */ 9, /* number of elements */ (const be_ctypes_structure_item_t[9]) { - { "blend_mode", 9, 0, 2, 0 }, - { "color", 0, 0, 0, 2 }, - { "dash_gap", 6, 0, 0, 12 }, - { "dash_width", 4, 0, 0, 12 }, - { "opa", 8, 0, 0, 1 }, - { "raw_end", 9, 4, 1, 0 }, - { "round_end", 9, 3, 1, 0 }, - { "round_start", 9, 2, 1, 0 }, - { "width", 2, 0, 0, 12 }, + { "blend_mode", 9, 0, 2, 0, 0 }, + { "color", 0, 0, 0, 2, 1 }, + { "dash_gap", 6, 0, 0, 12, 0 }, + { "dash_width", 4, 0, 0, 12, 0 }, + { "opa", 8, 0, 0, 1, 0 }, + { "raw_end", 9, 4, 1, 0, 0 }, + { "round_end", 9, 3, 1, 0, 0 }, + { "round_start", 9, 2, 1, 0, 0 }, + { "width", 2, 0, 0, 12, 0 }, }}; const be_ctypes_structure_t be_lv_draw_img_dsc = { 14, /* size in bytes */ 9, /* number of elements */ (const be_ctypes_structure_item_t[9]) { - { "angle", 1, 0, 0, 2 }, - { "antialias", 13, 0, 1, 0 }, - { "blend_mode", 12, 0, 0, 1 }, - { "opa", 0, 0, 0, 1 }, - { "pivot_x", 3, 0, 0, 12 }, - { "pivot_y", 5, 0, 0, 12 }, - { "recolor", 10, 0, 0, 2 }, - { "recolor_opa", 9, 0, 0, 1 }, - { "zoom", 7, 0, 0, 2 }, + { "angle", 1, 0, 0, 2, 0 }, + { "antialias", 13, 0, 1, 0, 0 }, + { "blend_mode", 12, 0, 0, 1, 0 }, + { "opa", 0, 0, 0, 1, 0 }, + { "pivot_x", 3, 0, 0, 12, 0 }, + { "pivot_y", 5, 0, 0, 12, 0 }, + { "recolor", 10, 0, 0, 2, 1 }, + { "recolor_opa", 9, 0, 0, 1, 0 }, + { "zoom", 7, 0, 0, 2, 0 }, }}; const be_ctypes_structure_t be_lv_draw_label_dsc = { 31, /* size in bytes */ 15, /* number of elements */ (const be_ctypes_structure_item_t[15]) { - { "bidi_dir", 27, 0, 0, 1 }, - { "blend_mode", 30, 0, 0, 1 }, - { "color", 0, 0, 0, 2 }, - { "decor", 29, 0, 0, 1 }, - { "flag", 28, 0, 0, 1 }, - { "font", 6, 0, 0, 4 }, - { "letter_space", 13, 0, 0, 12 }, - { "line_space", 11, 0, 0, 12 }, - { "ofs_x", 23, 0, 0, 12 }, - { "ofs_y", 25, 0, 0, 12 }, - { "opa", 10, 0, 0, 1 }, - { "sel_bg_color", 4, 0, 0, 2 }, - { "sel_color", 2, 0, 0, 2 }, - { "sel_end", 19, 0, 0, 4 }, - { "sel_start", 15, 0, 0, 4 }, + { "bidi_dir", 27, 0, 0, 1, 0 }, + { "blend_mode", 30, 0, 0, 1, 0 }, + { "color", 0, 0, 0, 2, 1 }, + { "decor", 29, 0, 0, 1, 0 }, + { "flag", 28, 0, 0, 1, 0 }, + { "font", 6, 0, 0, 4, 0 }, + { "letter_space", 13, 0, 0, 12, 0 }, + { "line_space", 11, 0, 0, 12, 0 }, + { "ofs_x", 23, 0, 0, 12, 0 }, + { "ofs_y", 25, 0, 0, 12, 0 }, + { "opa", 10, 0, 0, 1, 0 }, + { "sel_bg_color", 4, 0, 0, 2, 1 }, + { "sel_color", 2, 0, 0, 2, 1 }, + { "sel_end", 19, 0, 0, 4, 0 }, + { "sel_start", 15, 0, 0, 4, 0 }, }}; const be_ctypes_structure_t be_lv_draw_mask_common_dsc = { 5, /* size in bytes */ 2, /* number of elements */ (const be_ctypes_structure_item_t[2]) { - { "cb", 0, 0, 0, 4 }, - { "type", 4, 0, 0, 1 }, + { "cb", 0, 0, 0, 4, 0 }, + { "type", 4, 0, 0, 1, 0 }, }}; const be_ctypes_structure_t be_lv_draw_mask_line_param_cfg = { 9, /* size in bytes */ 5, /* number of elements */ (const be_ctypes_structure_item_t[5]) { - { "p1_x", 0, 0, 0, 12 }, - { "p1_y", 2, 0, 0, 12 }, - { "p2_x", 4, 0, 0, 12 }, - { "p2_y", 6, 0, 0, 12 }, - { "side", 8, 0, 2, 0 }, + { "p1_x", 0, 0, 0, 12, 0 }, + { "p1_y", 2, 0, 0, 12, 0 }, + { "p2_x", 4, 0, 0, 12, 0 }, + { "p2_y", 6, 0, 0, 12, 0 }, + { "side", 8, 0, 2, 0, 0 }, }}; const be_ctypes_structure_t be_lv_draw_mask_line_param = { 35, /* size in bytes */ 15, /* number of elements */ (const be_ctypes_structure_item_t[15]) { - { "cfg_p1_x", 5, 0, 0, 12 }, - { "cfg_p1_y", 7, 0, 0, 12 }, - { "cfg_p2_x", 9, 0, 0, 12 }, - { "cfg_p2_y", 11, 0, 0, 12 }, - { "cfg_side", 13, 0, 2, 0 }, - { "dsc_cb", 0, 0, 0, 4 }, - { "dsc_type", 4, 0, 0, 1 }, - { "flat", 34, 0, 1, 0 }, - { "inv", 34, 1, 1, 0 }, - { "origo_x", 14, 0, 0, 12 }, - { "origo_y", 16, 0, 0, 12 }, - { "spx", 30, 0, 0, 14 }, - { "steep", 26, 0, 0, 14 }, - { "xy_steep", 18, 0, 0, 14 }, - { "yx_steep", 22, 0, 0, 14 }, + { "cfg_p1_x", 5, 0, 0, 12, 0 }, + { "cfg_p1_y", 7, 0, 0, 12, 0 }, + { "cfg_p2_x", 9, 0, 0, 12, 0 }, + { "cfg_p2_y", 11, 0, 0, 12, 0 }, + { "cfg_side", 13, 0, 2, 0, 0 }, + { "dsc_cb", 0, 0, 0, 4, 0 }, + { "dsc_type", 4, 0, 0, 1, 0 }, + { "flat", 34, 0, 1, 0, 0 }, + { "inv", 34, 1, 1, 0, 0 }, + { "origo_x", 14, 0, 0, 12, 0 }, + { "origo_y", 16, 0, 0, 12, 0 }, + { "spx", 30, 0, 0, 14, 0 }, + { "steep", 26, 0, 0, 14, 0 }, + { "xy_steep", 18, 0, 0, 14, 0 }, + { "yx_steep", 22, 0, 0, 14, 0 }, }}; const be_ctypes_structure_t be_lv_draw_mask_angle_param_cfg = { 8, /* size in bytes */ 4, /* number of elements */ (const be_ctypes_structure_item_t[4]) { - { "end_angle", 6, 0, 0, 12 }, - { "start_angle", 4, 0, 0, 12 }, - { "vertex_p_x", 0, 0, 0, 12 }, - { "vertex_p_y", 2, 0, 0, 12 }, + { "end_angle", 6, 0, 0, 12, 0 }, + { "start_angle", 4, 0, 0, 12, 0 }, + { "vertex_p_x", 0, 0, 0, 12, 0 }, + { "vertex_p_y", 2, 0, 0, 12, 0 }, }}; const be_ctypes_structure_t be_lv_draw_mask_angle_param = { 85, /* size in bytes */ 37, /* number of elements */ (const be_ctypes_structure_item_t[37]) { - { "cfg_end_angle", 11, 0, 0, 12 }, - { "cfg_start_angle", 9, 0, 0, 12 }, - { "cfg_vertex_p_x", 5, 0, 0, 12 }, - { "cfg_vertex_p_y", 7, 0, 0, 12 }, - { "delta_deg", 83, 0, 0, 2 }, - { "dsc_cb", 0, 0, 0, 4 }, - { "dsc_type", 4, 0, 0, 1 }, - { "end_line_cfg_p1_x", 53, 0, 0, 12 }, - { "end_line_cfg_p1_y", 55, 0, 0, 12 }, - { "end_line_cfg_p2_x", 57, 0, 0, 12 }, - { "end_line_cfg_p2_y", 59, 0, 0, 12 }, - { "end_line_cfg_side", 61, 0, 2, 0 }, - { "end_line_dsc_cb", 48, 0, 0, 4 }, - { "end_line_dsc_type", 52, 0, 0, 1 }, - { "end_line_flat", 82, 0, 1, 0 }, - { "end_line_inv", 82, 1, 1, 0 }, - { "end_line_origo_x", 62, 0, 0, 12 }, - { "end_line_origo_y", 64, 0, 0, 12 }, - { "end_line_spx", 78, 0, 0, 14 }, - { "end_line_steep", 74, 0, 0, 14 }, - { "end_line_xy_steep", 66, 0, 0, 14 }, - { "end_line_yx_steep", 70, 0, 0, 14 }, - { "start_line_cfg_p1_x", 18, 0, 0, 12 }, - { "start_line_cfg_p1_y", 20, 0, 0, 12 }, - { "start_line_cfg_p2_x", 22, 0, 0, 12 }, - { "start_line_cfg_p2_y", 24, 0, 0, 12 }, - { "start_line_cfg_side", 26, 0, 2, 0 }, - { "start_line_dsc_cb", 13, 0, 0, 4 }, - { "start_line_dsc_type", 17, 0, 0, 1 }, - { "start_line_flat", 47, 0, 1, 0 }, - { "start_line_inv", 47, 1, 1, 0 }, - { "start_line_origo_x", 27, 0, 0, 12 }, - { "start_line_origo_y", 29, 0, 0, 12 }, - { "start_line_spx", 43, 0, 0, 14 }, - { "start_line_steep", 39, 0, 0, 14 }, - { "start_line_xy_steep", 31, 0, 0, 14 }, - { "start_line_yx_steep", 35, 0, 0, 14 }, + { "cfg_end_angle", 11, 0, 0, 12, 0 }, + { "cfg_start_angle", 9, 0, 0, 12, 0 }, + { "cfg_vertex_p_x", 5, 0, 0, 12, 0 }, + { "cfg_vertex_p_y", 7, 0, 0, 12, 0 }, + { "delta_deg", 83, 0, 0, 2, 0 }, + { "dsc_cb", 0, 0, 0, 4, 0 }, + { "dsc_type", 4, 0, 0, 1, 0 }, + { "end_line_cfg_p1_x", 53, 0, 0, 12, 0 }, + { "end_line_cfg_p1_y", 55, 0, 0, 12, 0 }, + { "end_line_cfg_p2_x", 57, 0, 0, 12, 0 }, + { "end_line_cfg_p2_y", 59, 0, 0, 12, 0 }, + { "end_line_cfg_side", 61, 0, 2, 0, 0 }, + { "end_line_dsc_cb", 48, 0, 0, 4, 0 }, + { "end_line_dsc_type", 52, 0, 0, 1, 0 }, + { "end_line_flat", 82, 0, 1, 0, 0 }, + { "end_line_inv", 82, 1, 1, 0, 0 }, + { "end_line_origo_x", 62, 0, 0, 12, 0 }, + { "end_line_origo_y", 64, 0, 0, 12, 0 }, + { "end_line_spx", 78, 0, 0, 14, 0 }, + { "end_line_steep", 74, 0, 0, 14, 0 }, + { "end_line_xy_steep", 66, 0, 0, 14, 0 }, + { "end_line_yx_steep", 70, 0, 0, 14, 0 }, + { "start_line_cfg_p1_x", 18, 0, 0, 12, 0 }, + { "start_line_cfg_p1_y", 20, 0, 0, 12, 0 }, + { "start_line_cfg_p2_x", 22, 0, 0, 12, 0 }, + { "start_line_cfg_p2_y", 24, 0, 0, 12, 0 }, + { "start_line_cfg_side", 26, 0, 2, 0, 0 }, + { "start_line_dsc_cb", 13, 0, 0, 4, 0 }, + { "start_line_dsc_type", 17, 0, 0, 1, 0 }, + { "start_line_flat", 47, 0, 1, 0, 0 }, + { "start_line_inv", 47, 1, 1, 0, 0 }, + { "start_line_origo_x", 27, 0, 0, 12, 0 }, + { "start_line_origo_y", 29, 0, 0, 12, 0 }, + { "start_line_spx", 43, 0, 0, 14, 0 }, + { "start_line_steep", 39, 0, 0, 14, 0 }, + { "start_line_xy_steep", 31, 0, 0, 14, 0 }, + { "start_line_yx_steep", 35, 0, 0, 14, 0 }, }}; const be_ctypes_structure_t be_lv_draw_mask_radius_param_cfg = { 11, /* size in bytes */ 6, /* number of elements */ (const be_ctypes_structure_item_t[6]) { - { "outer", 10, 0, 1, 0 }, - { "radius", 8, 0, 0, 12 }, - { "rect_x1", 0, 0, 0, 12 }, - { "rect_x2", 4, 0, 0, 12 }, - { "rect_y1", 2, 0, 0, 12 }, - { "rect_y2", 6, 0, 0, 12 }, + { "outer", 10, 0, 1, 0, 0 }, + { "radius", 8, 0, 0, 12, 0 }, + { "rect_x1", 0, 0, 0, 12, 0 }, + { "rect_x2", 4, 0, 0, 12, 0 }, + { "rect_y1", 2, 0, 0, 12, 0 }, + { "rect_y2", 6, 0, 0, 12, 0 }, }}; const be_ctypes_structure_t be_lv_sqrt_res = { 4, /* size in bytes */ 2, /* number of elements */ (const be_ctypes_structure_item_t[2]) { - { "f", 2, 0, 0, 2 }, - { "i", 0, 0, 0, 2 }, + { "f", 2, 0, 0, 2, 0 }, + { "i", 0, 0, 0, 2, 0 }, }}; const be_ctypes_structure_t be_lv_draw_mask_radius_param = { 24, /* size in bytes */ 11, /* number of elements */ (const be_ctypes_structure_item_t[11]) { - { "cfg_outer", 15, 0, 1, 0 }, - { "cfg_radius", 13, 0, 0, 12 }, - { "cfg_rect_x1", 5, 0, 0, 12 }, - { "cfg_rect_x2", 9, 0, 0, 12 }, - { "cfg_rect_y1", 7, 0, 0, 12 }, - { "cfg_rect_y2", 11, 0, 0, 12 }, - { "dsc_cb", 0, 0, 0, 4 }, - { "dsc_type", 4, 0, 0, 1 }, - { "y_prev", 16, 0, 0, 14 }, - { "y_prev_x_f", 22, 0, 0, 2 }, - { "y_prev_x_i", 20, 0, 0, 2 }, + { "cfg_outer", 15, 0, 1, 0, 0 }, + { "cfg_radius", 13, 0, 0, 12, 0 }, + { "cfg_rect_x1", 5, 0, 0, 12, 0 }, + { "cfg_rect_x2", 9, 0, 0, 12, 0 }, + { "cfg_rect_y1", 7, 0, 0, 12, 0 }, + { "cfg_rect_y2", 11, 0, 0, 12, 0 }, + { "dsc_cb", 0, 0, 0, 4, 0 }, + { "dsc_type", 4, 0, 0, 1, 0 }, + { "y_prev", 16, 0, 0, 14, 0 }, + { "y_prev_x_f", 22, 0, 0, 2, 0 }, + { "y_prev_x_i", 20, 0, 0, 2, 0 }, }}; const be_ctypes_structure_t be_lv_draw_mask_fade_param_cfg = { 14, /* size in bytes */ 8, /* number of elements */ (const be_ctypes_structure_item_t[8]) { - { "coords_x1", 0, 0, 0, 12 }, - { "coords_x2", 4, 0, 0, 12 }, - { "coords_y1", 2, 0, 0, 12 }, - { "coords_y2", 6, 0, 0, 12 }, - { "opa_bottom", 13, 0, 0, 1 }, - { "opa_top", 12, 0, 0, 1 }, - { "y_bottom", 10, 0, 0, 12 }, - { "y_top", 8, 0, 0, 12 }, + { "coords_x1", 0, 0, 0, 12, 0 }, + { "coords_x2", 4, 0, 0, 12, 0 }, + { "coords_y1", 2, 0, 0, 12, 0 }, + { "coords_y2", 6, 0, 0, 12, 0 }, + { "opa_bottom", 13, 0, 0, 1, 0 }, + { "opa_top", 12, 0, 0, 1, 0 }, + { "y_bottom", 10, 0, 0, 12, 0 }, + { "y_top", 8, 0, 0, 12, 0 }, }}; const be_ctypes_structure_t be_lv_draw_mask_fade_param = { 19, /* size in bytes */ 10, /* number of elements */ (const be_ctypes_structure_item_t[10]) { - { "cfg_coords_x1", 5, 0, 0, 12 }, - { "cfg_coords_x2", 9, 0, 0, 12 }, - { "cfg_coords_y1", 7, 0, 0, 12 }, - { "cfg_coords_y2", 11, 0, 0, 12 }, - { "cfg_opa_bottom", 18, 0, 0, 1 }, - { "cfg_opa_top", 17, 0, 0, 1 }, - { "cfg_y_bottom", 15, 0, 0, 12 }, - { "cfg_y_top", 13, 0, 0, 12 }, - { "dsc_cb", 0, 0, 0, 4 }, - { "dsc_type", 4, 0, 0, 1 }, + { "cfg_coords_x1", 5, 0, 0, 12, 0 }, + { "cfg_coords_x2", 9, 0, 0, 12, 0 }, + { "cfg_coords_y1", 7, 0, 0, 12, 0 }, + { "cfg_coords_y2", 11, 0, 0, 12, 0 }, + { "cfg_opa_bottom", 18, 0, 0, 1, 0 }, + { "cfg_opa_top", 17, 0, 0, 1, 0 }, + { "cfg_y_bottom", 15, 0, 0, 12, 0 }, + { "cfg_y_top", 13, 0, 0, 12, 0 }, + { "dsc_cb", 0, 0, 0, 4, 0 }, + { "dsc_type", 4, 0, 0, 1, 0 }, }}; const be_ctypes_structure_t be_lv_draw_mask_map_param_cfg = { 12, /* size in bytes */ 5, /* number of elements */ (const be_ctypes_structure_item_t[5]) { - { "coords_x1", 0, 0, 0, 12 }, - { "coords_x2", 4, 0, 0, 12 }, - { "coords_y1", 2, 0, 0, 12 }, - { "coords_y2", 6, 0, 0, 12 }, - { "map", 8, 0, 0, 4 }, + { "coords_x1", 0, 0, 0, 12, 0 }, + { "coords_x2", 4, 0, 0, 12, 0 }, + { "coords_y1", 2, 0, 0, 12, 0 }, + { "coords_y2", 6, 0, 0, 12, 0 }, + { "map", 8, 0, 0, 4, 0 }, }}; const be_ctypes_structure_t be_lv_draw_mask_map_param = { 17, /* size in bytes */ 7, /* number of elements */ (const be_ctypes_structure_item_t[7]) { - { "cfg_coords_x1", 5, 0, 0, 12 }, - { "cfg_coords_x2", 9, 0, 0, 12 }, - { "cfg_coords_y1", 7, 0, 0, 12 }, - { "cfg_coords_y2", 11, 0, 0, 12 }, - { "cfg_map", 13, 0, 0, 4 }, - { "dsc_cb", 0, 0, 0, 4 }, - { "dsc_type", 4, 0, 0, 1 }, + { "cfg_coords_x1", 5, 0, 0, 12, 0 }, + { "cfg_coords_x2", 9, 0, 0, 12, 0 }, + { "cfg_coords_y1", 7, 0, 0, 12, 0 }, + { "cfg_coords_y2", 11, 0, 0, 12, 0 }, + { "cfg_map", 13, 0, 0, 4, 0 }, + { "dsc_cb", 0, 0, 0, 4, 0 }, + { "dsc_type", 4, 0, 0, 1, 0 }, }}; const be_ctypes_structure_t be_lv_draw_mask_saved = { 8, /* size in bytes */ 2, /* number of elements */ (const be_ctypes_structure_item_t[2]) { - { "custom_id", 4, 0, 0, 4 }, - { "param", 0, 0, 0, 4 }, + { "custom_id", 4, 0, 0, 4, 0 }, + { "param", 0, 0, 0, 4, 0 }, }}; +const char * be_ctypes_instance_mappings[] = { + "lv_color", + NULL +}; + const be_ctypes_classes_t be_ctypes_classes[] = { 19, + be_ctypes_instance_mappings, (const be_ctypes_class_t[19]) { { "lv_area", &be_lv_area }, { "lv_draw_img_dsc", &be_lv_draw_img_dsc }, @@ -500,8 +473,6 @@ void be_load_ctypes_definitions_lib(bvm *vm) { static be_define_const_empty_class(be_class_lv_sqrt_res, &be_class_lv_ctypes, lv_sqrt_res); ctypes_register_class(vm, &be_class_lv_sqrt_res, &be_lv_sqrt_res); } - -/*******************************************************************/ - +/********************************************************************/ #endif // USE_LVGL \ No newline at end of file diff --git a/lib/libesp32/Berry/default/be_lvgl_signal_bars_lib.c b/lib/libesp32/Berry/default/be_lvgl_signal_bars_lib.c new file mode 100644 index 000000000..14c1e197a --- /dev/null +++ b/lib/libesp32/Berry/default/be_lvgl_signal_bars_lib.c @@ -0,0 +1,369 @@ +/******************************************************************** + * Tasmota LVGL lv_signal_bars widget + *******************************************************************/ +#include "be_constobj.h" + +#ifdef USE_LVGL + +#include "lvgl.h" + +/******************************************************************** +** Solidified function: my_design_cb +********************************************************************/ +be_local_closure(my_design_cb, /* name */ + be_nested_proto( + 23, /* 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 + }) + ), + 1, /* has constants */ + ( &(const bvalue[34]) { /* 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_const_int(3), + be_const_int(2), + be_nested_string("DESIGN_COVER_CHK", -1298406708, 16), + be_nested_string("ancestor_design", 421545719, 15), + be_nested_string("call", -1276017495, 4), + be_nested_string("DESIGN_DRAW_MAIN", -904475754, 16), + be_nested_string("get_coords", 1044089006, 10), + be_nested_string("x1", 274927234, 2), + be_nested_string("y1", -1939865569, 2), + be_nested_string("draw_line_dsc_init", -428273650, 18), + be_nested_string("line_dsc", -200476318, 8), + be_nested_string("init_draw_line_dsc", -1787031256, 18), + be_nested_string("OBJ_PART_MAIN", 658062838, 13), + be_nested_string("round_start", -1345482912, 11), + be_const_int(1), + be_nested_string("round_end", 985288225, 9), + be_nested_string("width", -1786286561, 5), + be_nested_string("get_style_line_color", 805371932, 20), + be_nested_string("STATE_DEFAULT", 712406428, 13), + be_nested_string("get_style_bg_color", 964794381, 18), + be_const_int(0), + be_nested_string("color", 1031692888, 5), + be_nested_string("percentage", -1756136011, 10), + be_nested_string("p1", -1605446022, 2), + be_nested_string("y", -66302220, 1), + be_nested_string("x", -49524601, 1), + be_nested_string("p2", -1622223641, 2), + be_nested_string("draw_line", 1634465686, 9), + be_nested_string("stop_iteration", -121173395, 14), + be_nested_string("DESIGN_RES_OK", -1265307123, 13), + }), + (be_nested_const_str("my_design_cb", -1173588798, 12)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[111]) { /* 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 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** 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: init +********************************************************************/ +be_local_closure(init, /* name */ + be_nested_proto( + 9, /* nstack */ + 3, /* argc */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[16]) { /* constants */ + be_nested_string("global", 503252654, 6), + be_nested_string("lv", 1529997255, 2), + be_nested_string("lv_obj", -37134147, 6), + be_nested_string("init", 380752755, 4), + be_nested_string("ancestor_design", 421545719, 15), + be_nested_string("get_design_cb", -825649242, 13), + be_nested_string("set_design_cb", 1469311634, 13), + be_nested_string("my_design_cb", -1173588798, 12), + be_nested_string("percentage", -1756136011, 10), + be_nested_string("p1", -1605446022, 2), + be_nested_string("lv_point", -174745506, 8), + be_nested_string("p2", -1622223641, 2), + be_nested_string("line_dsc", -200476318, 8), + be_nested_string("lv_draw_line_dsc", -1872162060, 16), + be_nested_string("area", -1693507260, 4), + be_nested_string("lv_area", -1773816895, 7), + }), + (be_nested_const_str("init", 380752755, 4)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[31]) { /* code */ + 0xA40E0000, // 0000 IMPORT R3 R256 + 0x88100701, // 0001 GETMBR R4 R3 R257 + 0x60140014, // 0002 GETGBL R5 G20 + 0x5C180000, // 0003 MOVE R6 R0 + 0x881C0702, // 0004 GETMBR R7 R3 R258 + 0x7C140400, // 0005 CALL R5 2 + 0x8C140B03, // 0006 GETMET R5 R5 R259 + 0x5C1C0200, // 0007 MOVE R7 R1 + 0x5C200400, // 0008 MOVE R8 R2 + 0x7C140600, // 0009 CALL R5 3 + 0x8C140105, // 000A GETMET R5 R0 R261 + 0x7C140200, // 000B CALL R5 1 + 0x90020805, // 000C SETMBR R0 R260 R5 + 0x8C140106, // 000D GETMET R5 R0 R262 + 0x881C0107, // 000E GETMBR R7 R0 R263 + 0x7C140400, // 000F CALL R5 2 + 0x54160063, // 0010 LDINT R5 100 + 0x90021005, // 0011 SETMBR R0 R264 R5 + 0x8C14070A, // 0012 GETMET R5 R3 R266 + 0x7C140200, // 0013 CALL R5 1 + 0x90021205, // 0014 SETMBR R0 R265 R5 + 0x8C14070A, // 0015 GETMET R5 R3 R266 + 0x7C140200, // 0016 CALL R5 1 + 0x90021605, // 0017 SETMBR R0 R267 R5 + 0x8C14070D, // 0018 GETMET R5 R3 R269 + 0x7C140200, // 0019 CALL R5 1 + 0x90021805, // 001A SETMBR R0 R268 R5 + 0x8C14070F, // 001B GETMET R5 R3 R271 + 0x7C140200, // 001C CALL R5 1 + 0x90021C05, // 001D SETMBR R0 R270 R5 + 0x80000000, // 001E RET 0 R0 + }) + ) +); +/*******************************************************************/ + + +/******************************************************************** +** 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 +********************************************************************/ +extern const bclass be_class_lv_obj; +be_local_class(lv_signal_bars, + 6, + &be_class_lv_obj, + be_nested_map(10, + ( (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("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_const_str("lv_signal_bars", -780994737, 14)) +); +/*******************************************************************/ + +void be_load_lv_signal_bars_class(bvm *vm) { + be_pushntvclass(vm, &be_lv_signal_bars_class); + be_setglobal(vm, "lv_signal_bars"); + be_pop(vm, 1); +} + +#endif // USE_LVGL \ No newline at end of file diff --git a/lib/libesp32/Berry/default/be_modtab.c b/lib/libesp32/Berry/default/be_modtab.c index 1654aa804..103a2d536 100644 --- a/lib/libesp32/Berry/default/be_modtab.c +++ b/lib/libesp32/Berry/default/be_modtab.c @@ -112,6 +112,8 @@ extern void be_load_lvgl_cb_lib(bvm *vm); extern void be_load_lvgl_cb_all_lib(bvm *vm); extern void be_load_lvgl_ctypes_lib(bvm *vm); extern void be_load_ctypes_definitions_lib(bvm *vm); +// custom widgets +extern void be_load_lv_signal_bars_class(bvm *vm); #endif// USE_LVGL /* this code loads the native class definitions */ @@ -143,6 +145,8 @@ BERRY_API void be_load_custom_libs(bvm *vm) be_load_lvgl_cb_all_lib(vm); be_load_lvgl_ctypes_lib(vm); be_load_ctypes_definitions_lib(vm); + // custom widgets + be_load_lv_signal_bars_class(vm); #endif // USE_LVGL } #endif diff --git a/lib/libesp32/Berry/default/be_tasmotalib.c b/lib/libesp32/Berry/default/be_tasmotalib.c index 6f8cb8bc4..40f4ac14b 100644 --- a/lib/libesp32/Berry/default/be_tasmotalib.c +++ b/lib/libesp32/Berry/default/be_tasmotalib.c @@ -1851,54 +1851,47 @@ static const bclosure wire_scan_closure = { /******************************************************************** ** Solidified function: time_str ********************************************************************/ - -/********** Solidified proto: time_str */ -be_define_local_const_str(time_str_str_name, "time_str", -1681139684, 8); -be_define_local_const_str(time_str_str_source, "input", -103256197, 5); -be_define_local_const_str(time_str_str_0, "string", 398550328, 6); -be_define_local_const_str(time_str_str_1, "time_dump", -964556549, 9); -be_define_local_const_str(time_str_str_2, "format", -1180859054, 6); -be_define_local_const_str(time_str_str_3, "%04d-%02d-%02dT%02d:%02d:%02d", -869438695, 29); -be_define_local_const_str(time_str_str_4, "year", -1367388900, 4); -be_define_local_const_str(time_str_str_5, "month", -696646139, 5); -be_define_local_const_str(time_str_str_6, "day", -464576003, 3); -be_define_local_const_str(time_str_str_7, "hour", -1241306097, 4); -be_define_local_const_str(time_str_str_8, "min", -913357481, 3); -be_define_local_const_str(time_str_str_9, "sec", -1155074638, 3); - -static const bvalue time_str_ktab[10] = { - { { .s=be_local_const_str(time_str_str_0) }, BE_STRING}, - { { .s=be_local_const_str(time_str_str_1) }, BE_STRING}, - { { .s=be_local_const_str(time_str_str_2) }, BE_STRING}, - { { .s=be_local_const_str(time_str_str_3) }, BE_STRING}, - { { .s=be_local_const_str(time_str_str_4) }, BE_STRING}, - { { .s=be_local_const_str(time_str_str_5) }, BE_STRING}, - { { .s=be_local_const_str(time_str_str_6) }, BE_STRING}, - { { .s=be_local_const_str(time_str_str_7) }, BE_STRING}, - { { .s=be_local_const_str(time_str_str_8) }, BE_STRING}, - { { .s=be_local_const_str(time_str_str_9) }, BE_STRING}, -}; - -static const uint32_t time_str_code[14] = { - 0xA40A0000, // 0000 IMPORT R2 R256 - 0x8C0C0101, // 0001 GETMET R3 R0 R257 - 0x5C140200, // 0002 MOVE R5 R1 - 0x7C0C0400, // 0003 CALL R3 2 - 0x8C100502, // 0004 GETMET R4 R2 R258 - 0x58180003, // 0005 LDCONST R6 K3 - 0x941C0704, // 0006 GETIDX R7 R3 R260 - 0x94200705, // 0007 GETIDX R8 R3 R261 - 0x94240706, // 0008 GETIDX R9 R3 R262 - 0x94280707, // 0009 GETIDX R10 R3 R263 - 0x942C0708, // 000A GETIDX R11 R3 R264 - 0x94300709, // 000B GETIDX R12 R3 R265 - 0x7C101000, // 000C CALL R4 8 - 0x80040800, // 000D RET 1 R4 -}; - -be_define_local_proto(time_str, 13, 2, 1, 0, 0); -be_define_local_closure(time_str); - +be_local_closure(time_str, /* name */ + be_nested_proto( + 13, /* nstack */ + 2, /* argc */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[10]) { /* constants */ + be_nested_string("string", 398550328, 6), + be_nested_string("time_dump", -964556549, 9), + be_nested_string("format", -1180859054, 6), + be_nested_string("%04d-%02d-%02dT%02d:%02d:%02d", -869438695, 29), + be_nested_string("year", -1367388900, 4), + be_nested_string("month", -696646139, 5), + be_nested_string("day", -464576003, 3), + be_nested_string("hour", -1241306097, 4), + be_nested_string("min", -913357481, 3), + be_nested_string("sec", -1155074638, 3), + }), + (be_nested_const_str("time_str", -1681139684, 8)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[14]) { /* code */ + 0xA40A0000, // 0000 IMPORT R2 R256 + 0x8C0C0101, // 0001 GETMET R3 R0 R257 + 0x5C140200, // 0002 MOVE R5 R1 + 0x7C0C0400, // 0003 CALL R3 2 + 0x8C100502, // 0004 GETMET R4 R2 R258 + 0x58180003, // 0005 LDCONST R6 K3 + 0x941C0704, // 0006 GETIDX R7 R3 R260 + 0x94200705, // 0007 GETIDX R8 R3 R261 + 0x94240706, // 0008 GETIDX R9 R3 R262 + 0x94280707, // 0009 GETIDX R10 R3 R263 + 0x942C0708, // 000A GETIDX R11 R3 R264 + 0x94300709, // 000B GETIDX R12 R3 R265 + 0x7C101000, // 000C CALL R4 8 + 0x80040800, // 000D RET 1 R4 + }) + ) +); /*******************************************************************/ /******************************************************************** @@ -2174,115 +2167,112 @@ static const bclosure set_light_closure = { /*******************************************************************/ - /******************************************************************** ** Solidified function: cb_dispatch ********************************************************************/ - -/********** Solidified proto: cb_dispatch */ -be_define_local_const_str(cb_dispatch_str_name, "cb_dispatch", 1741510499, 11); -be_define_local_const_str(cb_dispatch_str_source, "input", -103256197, 5); -be_define_local_const_str(cb_dispatch_str_0, "_cb", -251666929, 3); -be_define_local_const_str(cb_dispatch_str_2, "find", -1108310694, 4); - -static const bvalue cb_dispatch_ktab[3] = { - { { .s=be_local_const_str(cb_dispatch_str_0) }, BE_STRING}, - { { .i=0 }, BE_INT}, - { { .s=be_local_const_str(cb_dispatch_str_2) }, BE_STRING}, -}; - -static const uint32_t cb_dispatch_code[20] = { - 0x88180100, // 0000 GETMBR R6 R0 R256 - 0x4C1C0000, // 0001 LDNIL 7 - 0x1C180C07, // 0002 EQ R6 R6 R7 - 0x781A0000, // 0003 JMPF R6 #0005 - 0x80060200, // 0004 RET 1 R257 - 0x88180100, // 0005 GETMBR R6 R0 R256 - 0x8C180D02, // 0006 GETMET R6 R6 R258 - 0x5C200200, // 0007 MOVE R8 R1 - 0x7C180400, // 0008 CALL R6 2 - 0x4C1C0000, // 0009 LDNIL 7 - 0x201C0C07, // 000A NE R7 R6 R7 - 0x781E0006, // 000B JMPF R7 #0013 - 0x5C1C0C00, // 000C MOVE R7 R6 - 0x5C200400, // 000D MOVE R8 R2 - 0x5C240600, // 000E MOVE R9 R3 - 0x5C280800, // 000F MOVE R10 R4 - 0x5C2C0A00, // 0010 MOVE R11 R5 - 0x7C1C0800, // 0011 CALL R7 4 - 0x80040E00, // 0012 RET 1 R7 - 0x80060200, // 0013 RET 1 R257 -}; - -be_define_local_proto(cb_dispatch, 12, 6, 1, 0, 0); -be_define_local_closure(cb_dispatch); - +be_local_closure(cb_dispatch, /* name */ + be_nested_proto( + 12, /* nstack */ + 6, /* 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("_cb", -251666929, 3), + be_const_int(0), + be_nested_string("find", -1108310694, 4), + }), + (be_nested_const_str("cb_dispatch", 1741510499, 11)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[20]) { /* code */ + 0x88180100, // 0000 GETMBR R6 R0 R256 + 0x4C1C0000, // 0001 LDNIL 7 + 0x1C180C07, // 0002 EQ R6 R6 R7 + 0x781A0000, // 0003 JMPF R6 #0005 + 0x80060200, // 0004 RET 1 R257 + 0x88180100, // 0005 GETMBR R6 R0 R256 + 0x8C180D02, // 0006 GETMET R6 R6 R258 + 0x5C200200, // 0007 MOVE R8 R1 + 0x7C180400, // 0008 CALL R6 2 + 0x4C1C0000, // 0009 LDNIL 7 + 0x201C0C07, // 000A NE R7 R6 R7 + 0x781E0006, // 000B JMPF R7 #0013 + 0x5C1C0C00, // 000C MOVE R7 R6 + 0x5C200400, // 000D MOVE R8 R2 + 0x5C240600, // 000E MOVE R9 R3 + 0x5C280800, // 000F MOVE R10 R4 + 0x5C2C0A00, // 0010 MOVE R11 R5 + 0x7C1C0800, // 0011 CALL R7 4 + 0x80040E00, // 0012 RET 1 R7 + 0x80060200, // 0013 RET 1 R257 + }) + ) +); /*******************************************************************/ /******************************************************************** ** Solidified function: gen_cb ********************************************************************/ - -/********** Solidified proto: gen_cb */ -be_define_local_const_str(gen_cb_str_name, "gen_cb", -1049739745, 6); -be_define_local_const_str(gen_cb_str_source, "input", -103256197, 5); -be_define_local_const_str(gen_cb_str_0, "_cb", -251666929, 3); -be_define_local_const_str(gen_cb_str_2, "find", -1108310694, 4); -be_define_local_const_str(gen_cb_str_3, "_get_cb", 1448849122, 7); -be_define_local_const_str(gen_cb_str_4, "stop_iteration", -121173395, 14); -be_define_local_const_str(gen_cb_str_5, "internal_error", -1775809127, 14); -be_define_local_const_str(gen_cb_str_6, "No callback available", 633786138, 21); - -static const bvalue gen_cb_ktab[7] = { - { { .s=be_local_const_str(gen_cb_str_0) }, BE_STRING}, - { { .i=0 }, BE_INT}, - { { .s=be_local_const_str(gen_cb_str_2) }, BE_STRING}, - { { .s=be_local_const_str(gen_cb_str_3) }, BE_STRING}, - { { .s=be_local_const_str(gen_cb_str_4) }, BE_STRING}, - { { .s=be_local_const_str(gen_cb_str_5) }, BE_STRING}, - { { .s=be_local_const_str(gen_cb_str_6) }, BE_STRING}, -}; - -static const uint32_t gen_cb_code[34] = { - 0x88080100, // 0000 GETMBR R2 R0 R256 - 0x4C0C0000, // 0001 LDNIL 3 - 0x1C080403, // 0002 EQ R2 R2 R3 - 0x780A0002, // 0003 JMPF R2 #0007 - 0x6008000B, // 0004 GETGBL R2 G11 - 0x7C080000, // 0005 CALL R2 0 - 0x90020002, // 0006 SETMBR R0 R256 R2 - 0x60080000, // 0007 GETGBL R2 G0 - 0x540E0012, // 0008 LDINT R3 19 - 0x400E0203, // 0009 CONNECT R3 R257 R3 - 0x7C080200, // 000A CALL R2 1 - 0xA8020010, // 000B EXBLK 0 #001D - 0x5C0C0400, // 000C MOVE R3 R2 - 0x7C0C0000, // 000D CALL R3 0 - 0x88100100, // 000E GETMBR R4 R0 R256 - 0x8C100902, // 000F GETMET R4 R4 R258 - 0x5C180600, // 0010 MOVE R6 R3 - 0x7C100400, // 0011 CALL R4 2 - 0x4C140000, // 0012 LDNIL 5 - 0x1C100805, // 0013 EQ R4 R4 R5 - 0x78120006, // 0014 JMPF R4 #001C - 0x88100100, // 0015 GETMBR R4 R0 R256 - 0x98100601, // 0016 SETIDX R4 R3 R1 - 0x8C100103, // 0017 GETMET R4 R0 R259 - 0x5C180600, // 0018 MOVE R6 R3 - 0x7C100400, // 0019 CALL R4 2 - 0xA8040001, // 001A EXBLK 1 1 - 0x80040800, // 001B RET 1 R4 - 0x7001FFEE, // 001C JMP #000C - 0x58080004, // 001D LDCONST R2 K4 - 0xAC080200, // 001E CATCH R2 1 0 - 0xB0080000, // 001F RAISE 2 R0 R0 - 0xB0060B06, // 0020 RAISE 1 R261 R262 - 0x80000000, // 0021 RET 0 R0 -}; - -be_define_local_proto(gen_cb, 7, 2, 1, 0, 0); -be_define_local_closure(gen_cb); - +be_local_closure(gen_cb, /* name */ + be_nested_proto( + 7, /* nstack */ + 2, /* argc */ + 0, /* has upvals */ + NULL, /* no upvals */ + 0, /* has sup protos */ + NULL, /* no sub protos */ + 1, /* has constants */ + ( &(const bvalue[ 7]) { /* constants */ + be_nested_string("_cb", -251666929, 3), + be_const_int(0), + be_nested_string("find", -1108310694, 4), + be_nested_string("_get_cb", 1448849122, 7), + be_nested_string("stop_iteration", -121173395, 14), + be_nested_string("internal_error", -1775809127, 14), + be_nested_string("No callback available", 633786138, 21), + }), + (be_nested_const_str("gen_cb", -1049739745, 6)), + (be_nested_const_str("input", -103256197, 5)), + ( &(const binstruction[34]) { /* code */ + 0x88080100, // 0000 GETMBR R2 R0 R256 + 0x4C0C0000, // 0001 LDNIL 3 + 0x1C080403, // 0002 EQ R2 R2 R3 + 0x780A0002, // 0003 JMPF R2 #0007 + 0x6008000B, // 0004 GETGBL R2 G11 + 0x7C080000, // 0005 CALL R2 0 + 0x90020002, // 0006 SETMBR R0 R256 R2 + 0x60080000, // 0007 GETGBL R2 G0 + 0x540E0012, // 0008 LDINT R3 19 + 0x400E0203, // 0009 CONNECT R3 R257 R3 + 0x7C080200, // 000A CALL R2 1 + 0xA8020010, // 000B EXBLK 0 #001D + 0x5C0C0400, // 000C MOVE R3 R2 + 0x7C0C0000, // 000D CALL R3 0 + 0x88100100, // 000E GETMBR R4 R0 R256 + 0x8C100902, // 000F GETMET R4 R4 R258 + 0x5C180600, // 0010 MOVE R6 R3 + 0x7C100400, // 0011 CALL R4 2 + 0x4C140000, // 0012 LDNIL 5 + 0x1C100805, // 0013 EQ R4 R4 R5 + 0x78120006, // 0014 JMPF R4 #001C + 0x88100100, // 0015 GETMBR R4 R0 R256 + 0x98100601, // 0016 SETIDX R4 R3 R1 + 0x8C100103, // 0017 GETMET R4 R0 R259 + 0x5C180600, // 0018 MOVE R6 R3 + 0x7C100400, // 0019 CALL R4 2 + 0xA8040001, // 001A EXBLK 1 1 + 0x80040800, // 001B RET 1 R4 + 0x7001FFEE, // 001C JMP #000C + 0x58080004, // 001D LDCONST R2 K4 + 0xAC080200, // 001E CATCH R2 1 0 + 0xB0080000, // 001F RAISE 2 R0 R0 + 0xB0060B06, // 0020 RAISE 1 R261 R262 + 0x80000000, // 0021 RET 0 R0 + }) + ) +); /*******************************************************************/ diff --git a/lib/libesp32/Berry/generate/be_const_strtab.h b/lib/libesp32/Berry/generate/be_const_strtab.h index 6eba22307..98b95544e 100644 --- a/lib/libesp32/Berry/generate/be_const_strtab.h +++ b/lib/libesp32/Berry/generate/be_const_strtab.h @@ -266,6 +266,7 @@ extern const bcstring be_const_str_load_freetype_font; extern const bcstring be_const_str_lv_draw_mask_map_param; extern const bcstring be_const_str_lv_draw_mask_radius_param; extern const bcstring be_const_str_write; +extern const bcstring be_const_str_toint; extern const bcstring be_const_str_BACKLIGHT; extern const bcstring be_const_str_FALLING; extern const bcstring be_const_str_ROT1B_NP; diff --git a/lib/libesp32/Berry/generate/be_const_strtab_def.h b/lib/libesp32/Berry/generate/be_const_strtab_def.h index e0be7be64..ed636ab69 100644 --- a/lib/libesp32/Berry/generate/be_const_strtab_def.h +++ b/lib/libesp32/Berry/generate/be_const_strtab_def.h @@ -266,6 +266,7 @@ be_define_const_str(load_freetype_font, "load_freetype_font", 2368447592u, 0, 18 be_define_const_str(lv_draw_mask_map_param, "lv_draw_mask_map_param", 1666886804u, 0, 22, &be_const_str_lv_draw_mask_radius_param); be_define_const_str(lv_draw_mask_radius_param, "lv_draw_mask_radius_param", 3777679220u, 0, 25, &be_const_str_write); be_define_const_str(write, "write", 3190202204u, 0, 5, NULL); +be_define_const_str(toint, "toint", 3613182909u, 0, 5, NULL); be_define_const_str(BACKLIGHT, "BACKLIGHT", 3147761926u, 0, 9, &be_const_str_FALLING); be_define_const_str(FALLING, "FALLING", 2851701064u, 0, 7, &be_const_str_ROT1B_NP); be_define_const_str(ROT1B_NP, "ROT1B_NP", 3710079736u, 0, 8, &be_const_str_ZIGBEE_RX); @@ -787,7 +788,7 @@ static const bstring* const m_string_table[] = { (const bstring *)&be_const_str_gamma8, (const bstring *)&be_const_str_BUZZER, (const bstring *)&be_const_str_RDM6300_RX, - NULL, + (const bstring *)&be_const_str_toint, (const bstring *)&be_const_str_BACKLIGHT, (const bstring *)&be_const_str_ILI9341_CS, (const bstring *)&be_const_str_SYMBOL_WARNING, @@ -980,6 +981,6 @@ static const bstring* const m_string_table[] = { static const struct bconststrtab m_const_string_table = { .size = 318, - .count = 636, + .count = 637, .table = m_string_table }; diff --git a/lib/libesp32/Berry/generate/be_fixed_be_class_lv_color.h b/lib/libesp32/Berry/generate/be_fixed_be_class_lv_color.h index fb031e934..e688d2573 100644 --- a/lib/libesp32/Berry/generate/be_fixed_be_class_lv_color.h +++ b/lib/libesp32/Berry/generate/be_fixed_be_class_lv_color.h @@ -3,12 +3,13 @@ static be_define_const_map_slots(be_class_lv_color_map) { { be_const_key(init, -1), be_const_func(lco_init) }, { be_const_key(tostring, 2), be_const_func(lco_tostring) }, - { be_const_key(dot_p, -1), be_const_index(0) }, + { be_const_key(toint, -1), be_const_func(lco_toint) }, + { be_const_key(dot_p, 0), be_const_index(0) }, }; static be_define_const_map( be_class_lv_color_map, - 3 + 4 ); BE_EXPORT_VARIABLE be_define_const_class( diff --git a/lib/libesp32/Berry/src/be_solidifylib.c b/lib/libesp32/Berry/src/be_solidifylib.c index f549604e0..262933de0 100644 --- a/lib/libesp32/Berry/src/be_solidifylib.c +++ b/lib/libesp32/Berry/src/be_solidifylib.c @@ -43,10 +43,18 @@ static void m_solidify_bvalue(bvm *vm, bvalue * value) logfmt("be_const_bool(%i)", var_tobool(value)); break; case BE_INT: +#if BE_INTGER_TYPE == 2 + logfmt("be_const_int(%lli)", var_toint(value)); +#else logfmt("be_const_int(%i)", var_toint(value)); +#endif break; case BE_INDEX: +#if BE_INTGER_TYPE == 2 + logfmt("be_const_index(%lli)", var_toint(value)); +#else logfmt("be_const_index(%i)", var_toint(value)); +#endif break; case BE_REAL: #if BE_USE_SINGLE_FLOAT @@ -199,11 +207,14 @@ static void m_solidify_class(bvm *vm, bclass *cl, int builtins) logfmt("** Solidified class: %s\n", class_name); logfmt("********************************************************************/\n"); + if (cl->super) { + logfmt("extern const bclass be_class_%s;\n", str(cl->super->name)); + } logfmt("be_local_class(%s,\n", class_name); logfmt(" %i,\n", cl->nvar); if (cl->super) { - logfmt(" &be_%s_class,\n", str(cl->super->name)); + logfmt(" &be_class_%s,\n", str(cl->super->name)); } else { logfmt(" NULL,\n"); } diff --git a/lib/libesp32/Berry/src/berry.h b/lib/libesp32/Berry/src/berry.h index ab301a2ea..d71d015f4 100644 --- a/lib/libesp32/Berry/src/berry.h +++ b/lib/libesp32/Berry/src/berry.h @@ -352,20 +352,9 @@ typedef struct bntvmodule { PROTO_VAR_INFO_BLOCK \ } -#define be_define_local_closure(_name) \ - const bclosure _name##_closure = { \ - NULL, /* bgcobject *next */ \ - BE_CLOSURE, /* type BE_CLOSURE */ \ - GC_CONST, /* marked GC_CONST */ \ - 0, /* nupvals */ \ - NULL, /* bgcobject *gray */ \ - (bproto*) &_name##_proto, /* proto */ \ - { NULL } /* upvals */ \ - } - /* new version for more compact literals */ #define be_local_closure(_name, _proto) \ - const bclosure _name##_closure = { \ + static const bclosure _name##_closure = { \ NULL, /* bgcobject *next */ \ BE_CLOSURE, /* type BE_CLOSURE */ \ GC_CONST, /* marked GC_CONST */ \ diff --git a/tasmota/berry/lvgl_examples/lvgl_demo.be b/tasmota/berry/lvgl_examples/lvgl_demo.be new file mode 100644 index 000000000..34b0a735d --- /dev/null +++ b/tasmota/berry/lvgl_examples/lvgl_demo.be @@ -0,0 +1,159 @@ +lv.start() + +hres = lv.get_hor_res() +vres = lv.get_ver_res() + +scr = lv.scr_act() +f20 = lv.montserrat_font(20) + +scr.set_style_local_bg_color(lv.OBJ_PART_MAIN, lv.STATE_DEFAULT, lv_color(0x0000A0)) +scr.set_style_local_bg_grad_color(lv.OBJ_PART_MAIN, lv.STATE_DEFAULT, lv_color(0x000000)) +scr.set_style_local_bg_grad_dir(lv.OBJ_PART_MAIN, lv.STATE_DEFAULT, lv.GRAD_DIR_VER) + +log = lv_label(scr) +if f20 != nil log.set_style_local_text_font(lv.OBJ_PART_MAIN, lv.STATE_DEFAULT, f20) end +log.set_long_mode(lv.LABEL_LONG_SROLL) +log.set_width(hres) +log.set_align(lv.LABEL_ALIGN_LEFT) +log.set_style_local_bg_color(lv.OBJ_PART_MAIN, lv.STATE_DEFAULT, lv_color(0xD00000)) +log.set_style_local_bg_opa(lv.OBJ_PART_MAIN, lv.STATE_DEFAULT, lv.OPA_COVER) +log.set_style_local_text_color(lv.OBJ_PART_MAIN, lv.STATE_DEFAULT, lv_color(0xFFFFFF)) +log.set_text("Welcome to Tasmota") + +tastyle = lv_style() +tastyle.set_bg_color(lv.STATE_DEFAULT, lv_color(0x1fa3ec)) +tastyle.set_border_color(lv.STATE_DEFAULT, lv_color(0x0000FF)) +tastyle.set_bg_color(lv.STATE_FOCUSED, lv_color(0x0000FF)) +tastyle.set_border_color(lv.STATE_FOCUSED, lv_color(0xFFFFFF)) +tastyle.set_text_color(lv.STATE_DEFAULT, lv_color(0xFFFFFF)) +tastyle.set_radius(lv.STATE_DEFAULT, 10) +tastyle.set_bg_opa(lv.STATE_DEFAULT, lv.OPA_COVER) +if f20 != nil tastyle.set_text_font(lv.STATE_DEFAULT, f20) end + +prev_btn = lv_btn(scr) +prev_btn.set_pos(20,vres-40) +prev_btn.set_size(80, 30) +prev_btn.add_style(lv.OBJ_PART_MAIN, tastyle) +prev_label = lv_label(prev_btn) +prev_label.set_text("<") + +next_btn = lv_btn(scr) +next_btn.set_pos(220,vres-40) +next_btn.set_size(80, 30) +next_btn.add_style(lv.OBJ_PART_MAIN, tastyle) +next_label = lv_label(next_btn) +next_label.set_text(">") + +home_btn = lv_btn(scr) +home_btn.set_pos(120,vres-40) +home_btn.set_size(80, 30) +home_btn.add_style(lv.OBJ_PART_MAIN, tastyle) +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) +log.set_style_local_pad_right(lv.OBJ_PART_MAIN, lv.STATE_DEFAULT, log_height+1) + +bars = lv_signal_bars(log) + +bars.set_style_local_bg_color(lv.OBJ_PART_MAIN, lv.STATE_DEFAULT, lv_color(lv.BLACK)) + +bars.set_height(log_height) +bars.set_width(log_height) +bars.set_x(log.get_width() - log_height) + +#bars.get_style_transform_width(lv.OBJ_PART_MAIN) +#bars.get_style_transform_height(lv.OBJ_PART_MAIN) \ No newline at end of file diff --git a/tasmota/berry/lvgl_examples/signal_bars.be b/tasmota/berry/lvgl_examples/signal_bars.be index 4d4a058d2..be108e7b3 100644 --- a/tasmota/berry/lvgl_examples/signal_bars.be +++ b/tasmota/berry/lvgl_examples/signal_bars.be @@ -5,31 +5,38 @@ lv.start() -def max(a,b) if a > b return a else return b end end - 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, lv_obj).init(parent, copy) + 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 - # set default style - self.set_style_local_bg_opa(lv.OBJ_PART_MAIN, lv.STATE_DEFAULT, lv.OPA_TRANSP) + # 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 = max(width / 15, 1) - var bar = max((width - inter_bar * 3) / 4, 1) + 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 @@ -37,29 +44,53 @@ class lv_signal_bars : lv_obj return self.ancestor_design.call(self, area, mode) elif mode == lv.DESIGN_DRAW_MAIN - self.ancestor_design.call(self, area, mode) - var line_dsc = lv_draw_line_dsc() - lv.draw_line_dsc_init(line_dsc) + #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 - line_dsc.round_start = 1 - line_dsc.round_end = 1 - line_dsc.width = bar - line_dsc.color = 0xF0F - var p1 = lv_point() - var p2 = lv_point() + 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 - p1.y = height - 1 - bar_offset - p1.x = i * (bar + inter_bar) + bar_offset - p2.y = ((3 - i) * (height - bar)) / 4 + bar_offset - p2.x = p1.x - lv.draw_line(p1, p2, area, line_dsc) + 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 bars = lv_signal_bars(lv.scr_act()) +bars.set_height(16) +bars.set_width(16) +bars.set_percentage(45) +bars.set_style_local_line_color(lv.OBJ_PART_MAIN, lv.STATE_DEFAULT, lv_color(0xFF8000)) \ No newline at end of file diff --git a/tasmota/berry/modules/ctypes.be b/tasmota/berry/modules/ctypes.be index 5898a4690..15ec12853 100644 --- a/tasmota/berry/modules/ctypes.be +++ b/tasmota/berry/modules/ctypes.be @@ -59,6 +59,13 @@ ctypes.bf_13 = 113 ctypes.bf_14 = 114 ctypes.bf_15 = 115 +def findinlist(l, x) + for i:0..size(l)-1 + if l[i] == x + return i + end + end +end #------------------------------------------------------------- #- 'get_bits' function @@ -151,34 +158,87 @@ end #- print the C types -#1 ctypes.print_types = def () + print("/********************************************************************") + print(" * Generated code, don't edit") + print(" *******************************************************************/") + print() print("enum {") - print(" ctypes_ptr = 0,") - print(" ctypes_uint = 1,") - print(" ctypes_int = 2,") - print(" ctypes_str = 3,") + print(" ctypes_i32 = 14,") + print(" ctypes_i16 = 12,") + print(" ctypes_i8 = 11,") + print(" ctypes_u32 = 4,") + print(" ctypes_u16 = 2,") + print(" ctypes_u8 = 1,") + print("") + print(" // big endian") + print(" ctypes_be_i32 = -14,") + print(" ctypes_be_i16 = -12,") + print(" ctypes_be_i8 = -11,") + print(" ctypes_be_u32 = -4,") + print(" ctypes_be_u16 = -2,") + print(" ctypes_be_u8 = -1,") + print() + print(" ctypes_bf = 0, //bif-field") print("};") print() print("typedef struct be_ctypes_structure_item_t {") - print(" const char * name;") - print(" uint16_t offset_bits;") - print(" uint16_t len_bits : 13;") - print(" uint16_t type : 3;") + print(" const char * name;") + print(" uint16_t offset_bytes;") + print(" uint8_t offset_bits : 3;") + print(" uint8_t len_bits : 5;") + print(" int8_t type : 5;") + print(" uint8_t mapping : 3;") print("} be_ctypes_structure_item_t;") print() print("typedef struct be_ctypes_structure_t {") - print(" uint16_t size_bytes; /* size in bytes */") - print(" uint16_t size_elt; /* number of elements */") - print(" const be_ctypes_structure_item_t * items;") + print(" uint16_t size_bytes; /* size in bytes */") + print(" uint16_t size_elt; /* number of elements */") + print(" const be_ctypes_structure_item_t * items;") print("} be_ctypes_structure_t;") print() + print("typedef struct be_ctypes_class_t {") + print(" const char * name;") + print(" const be_ctypes_structure_t * definitions;") + print("} be_ctypes_class_t;") + print("") + print("typedef struct be_ctypes_classes_t {") + print(" uint16_t size;") + print(" const char **instance_mapping; /* array of instance class names for automatic instanciation of class */") + print(" const be_ctypes_class_t * classes;") + print("} be_ctypes_classes_t;") + print() + print("BE_EXPORT_VARIABLE extern const bclass be_class_lv_ctypes;") + print() + print("void ctypes_register_class(bvm *vm, const bclass * ctypes_class, const be_ctypes_structure_t * definitions) {") + print(" be_pushntvclass(vm, ctypes_class);") + print(" be_setglobal(vm, str(ctypes_class->name));") + print(" be_pop(vm, 1);") + print("}") + print() + print("/********************************************************************/") end -global_classes = [] # track the list of all classes and +global_classes = [] # track the list of all classes and +global_mappings = [] # mapping to Berry classes, ex: lv_color + ctypes.print_classes = def () + # print mappings + if size(global_mappings) > 7 + raise "internal_error", "too many mappings, 7 max" + end + print("const char * be_ctypes_instance_mappings[] = {") + for n:global_mappings.iter() + print(string.format(" \"%s\",", n)) + end + print(" NULL") + print("};") + print() + ctypes.sort(global_classes) print("const be_ctypes_classes_t be_ctypes_classes[] = {") print(string.format(" %i,", size(global_classes))) + print(string.format(" be_ctypes_instance_mappings,")) print(string.format(" (const be_ctypes_class_t[%i]) {", size(global_classes))) for elt:global_classes @@ -207,6 +267,8 @@ ctypes.print_classes = def () end print("}") + print("/********************************************************************/") + print() end #------------------------------------------------------------- @@ -261,7 +323,7 @@ class structure ctypes.sort(names) for n:names var args = self.mapping[n] - print(string.format(" { \"%s\", %i, %i, %i, %i },", n, args[0], args[1], args[2], args[3])) + print(string.format(" { \"%s\", %i, %i, %i, %i, %i },", n, args[0], args[1], args[2], args[3], args[4])) end print("}};") print() @@ -285,14 +347,29 @@ class structure if isinstance(type_obj, ctypes.structure) # nested structure self.nested(name, type_obj) - elif type(type_obj) == 'int' + end + + var mapping_idx = 0 # mapping starts at 1 + if isinstance(type_obj, list) + # it may be a list to denote a mapping to an instance + var mapping_name = type_obj[1] + if findinlist(global_mappings, mapping_name) == nil + global_mappings.push(mapping_name) + end + mapping_idx = findinlist(global_mappings, mapping_name) + 1 + + type_obj = type_obj[0] # take the simple value of first element in the list + end + + if type(type_obj) == 'int' + # simple attibute # TODO check actual type if type_obj > ctypes.bf_0 # bit field - self.get_bitfield_closure(name, type_obj - ctypes.bf_0) + self.get_bitfield_closure(name, type_obj - ctypes.bf_0, mapping_idx) else # multi-bytes - self.get_int_closure(name, type_obj) + self.get_int_closure(name, type_obj, mapping_idx) end end end @@ -329,7 +406,7 @@ class structure # include nested for subname:type_obj.mapping.keys() var val = type_obj.mapping[subname] - self.mapping[name+"_"+subname] = [val[0] + offset, val[1], val[2], val[3]] + self.mapping[name+"_"+subname] = [val[0] + offset, val[1], val[2], val[3], val[4]] end # self.mapping[name] = [offset << 3, sub_size << 3] @@ -339,7 +416,7 @@ class structure self.cur_offset += sub_size end - def get_int_closure(name, type) # can be 1/2/4 + def get_int_closure(name, type, instance_mapping) # can be 1/2/4 #- abs size -# var size_in_bytes = type < 0 ? - type : type var signed = size_in_bytes > 10 @@ -349,7 +426,7 @@ class structure self.align(size_in_bytes) # force alignment var offset = self.cur_offset # prepare variable for capture in closure - self.mapping[name] = [offset, 0, 0, type] + self.mapping[name] = [offset, 0, 0, type, instance_mapping] #- add closures -# if signed @@ -363,10 +440,10 @@ class structure end - def get_bitfield_closure(name, size_in_bits) # can be 1..32 + def get_bitfield_closure(name, size_in_bits, instance_mapping) # can be 1..32 var cur_offset = self.cur_offset # prepare variable for capture in closure var bit_offset = self.bit_offset - self.mapping[name] = [cur_offset, bit_offset, size_in_bits, 0] + self.mapping[name] = [cur_offset, bit_offset, size_in_bits, 0, instance_mapping] self.get_closures[name] = def (b, p) return ctypes.get_bits(b, cur_offset + p, bit_offset, size_in_bits) end self.set_closures[name] = def (b, p, v) return ctypes.set_bits(b, cur_offset+ p, bit_offset, size_in_bits, v) end @@ -520,93 +597,3 @@ return ctypes 16777472 -# - -# def get_bits(b, offset_bytes, offset_bits, len_bits) -# if !isinstance(b, bytes) raise "value_error", "first argument must be of type 'bytes'" end -# if offset_bits < 0 || offset_bits > 7 raise "value_error", "offset_bits must be between 0 and 7" end -# if len_bits <= 0 || len_bits > 32 raise "value_error", "length in bits must be between 0 and 32" end -# var ret = 0 - -# var bit_shift = 0 # bit number to wrtie to - -# while (len_bits > 0) -# var block_bits = 8 - offset_bits # bit number to read in current block (block = byte) -# if block_bits > len_bits block_bits = len_bits end - -# var mask = ( (1<> offset_bits) << bit_shift) - -# # move the input window -# bit_shift += block_bits -# len_bits -= block_bits -# offset_bits = 0 # start at full next byte -# offset_bytes += 1 -# end - -# return ret -# end - -# Test - -# b=bytes("AAFF10") -# assert(get_bits(b, 0, 0, 1) == 0) -# assert(get_bits(b, 0, 1, 1) == 1) -# assert(get_bits(b, 0, 2, 1) == 0) -# assert(get_bits(b, 0, 3, 1) == 1) - -# assert(get_bits(b, 0, 0, 2) == 2) -# assert(get_bits(b, 0, 1, 2) == 1) -# assert(get_bits(b, 0, 2, 2) == 2) - -# assert(get_bits(b, 0, 0, 8) == 0xAA) -# assert(get_bits(b, 0, 0, 10) == 0x3AA) -# assert(get_bits(b, 0, 2, 8) == 0xEA) - -# assert(get_bits(b, 1, 0, 8) == 0xFF) -# assert(get_bits(b, 1, 0, 10) == 0x0FF) - -# assert(get_bits(b, 1, 0, 16) == 0x10FF) - - -# assert(get_bits(b, 1, 7, 4) == 0x01) -# assert(get_bits(b, 1, 7, 6) == 0x21) - -# def set_bits(b, offset_bytes, offset_bits, len_bits, val) -# if !isinstance(b, bytes) raise "value_error", "first argument must be of type 'bytes'" end -# if offset_bits < 0 || offset_bits > 7 raise "value_error", "offset_bits must be between 0 and 7" end -# if len_bits <= 0 || len_bits > 32 raise "value_error", "length in bits must be between 0 and 32" end - -# while (len_bits > 0) -# var block_bits = 8 - offset_bits # how many bits to write in the current block (block = byte) -# if block_bits > len_bits block_bits = len_bits end - -# var mask_val = (1<>= block_bits -# len_bits -= block_bits -# offset_bits = 0 # start at full next byte -# offset_bytes += 1 -# end -# return b -# end - -# b=bytes("00000000") - -# assert(set_bits(b,0,0,1,1) == bytes('01000000')) -# assert(set_bits(b,1,0,1,1) == bytes('01010000')) -# assert(set_bits(b,0,0,1,2) == bytes('00010000')) -# assert(set_bits(b,0,4,1,1) == bytes('10010000')) -# assert(set_bits(b,0,4,1,0) == bytes('00010000')) - -# b=bytes("FF000000") -# assert(set_bits(b,0,4,1,0) == bytes('EF000000')) -# assert(set_bits(b,0,4,1,1) == bytes('FF000000')) - -# b=bytes("00000000") -# assert(set_bits(b,2,6,1,-1) == bytes('00004000')) -# b=bytes("00000000") -# assert(set_bits(b,2,1,6,-1) == bytes('00007E00')) \ No newline at end of file diff --git a/tasmota/berry/modules/lvgl_ctypes.be b/tasmota/berry/modules/lvgl_ctypes.be index 61b3fdf7c..7238ad621 100644 --- a/tasmota/berry/modules/lvgl_ctypes.be +++ b/tasmota/berry/modules/lvgl_ctypes.be @@ -11,7 +11,7 @@ import ctypes ctypes.print_types() lv_style_int = ctypes.i16 -lv_color = ctypes.u16 # depends on colors +lv_color = [ctypes.u16, "lv_color"] # cast to the class instance, constructor is called with 2 args: (nil, value) lv_grad_dir = ctypes.u8 lv_opa = ctypes.u8 lv_blend_mode = ctypes.u8 diff --git a/tasmota/xdrv_52_3_berry_lvgl.ino b/tasmota/xdrv_52_3_berry_lvgl.ino index d7fe05485..2e6c302c3 100644 --- a/tasmota/xdrv_52_3_berry_lvgl.ino +++ b/tasmota/xdrv_52_3_berry_lvgl.ino @@ -439,18 +439,24 @@ extern "C" { return *col; } inline uint32_t lv_color_to_uint32(lv_color_t col) { - uint32_t *p = (uint32_t*) &col; + uint16_t *p = (uint16_t*) &col; return *p; } // lv_color + // First arg is a 24 bits RGB color + // If first arg is `nil` second arg is the native value of color int lco_init(bvm *vm) { int argc = be_top(vm); - uint32_t color = 0x0000; // default to black - if (argc > 1 && be_isint(vm, 2)) { - color = be_toint(vm, 2); + uint32_t color32 = 0x000000; // default to black + + if (argc > 1) { + color32 = be_toint(vm, 2); + } + lv_color_t lv_color = lv_color_hex(color32); + if (argc > 2 && be_toint(vm, 3) == -1) { + lv_color.full = be_toint(vm, 2); } - lv_color_t lv_color = lv_color_hex(color); be_pushint(vm, lv_color_to_uint32(lv_color)); be_setmember(vm, 1, ".p"); be_return_nil(vm); @@ -461,7 +467,7 @@ extern "C" { be_getmember(vm, 1, ".p"); uint32_t ntv_color = be_toint(vm, -1); lv_color = lv_color_from_uint32(ntv_color); - uint32_t color = lv_color_to32(lv_color); + uint32_t color = lv_color_to32(lv_color) & 0xFFFFFF; be_pop(vm, 1); // remove attribute char s[48]; snprintf(s, sizeof(s), "lv_color(0x%06x - native:0x%04x)", color, ntv_color); @@ -469,6 +475,14 @@ extern "C" { be_return(vm); } + int lco_toint(bvm *vm) { + lv_color_t lv_color = {}; + be_getmember(vm, 1, ".p"); + uint32_t ntv_color = be_toint(vm, -1); + be_pushint(vm, ntv_color); + be_return(vm); + } + /*********************************************************************************************\ * Support for lv diff --git a/tools/lv_berry/lv_widgets.h b/tools/lv_berry/lv_widgets.h index 4ec2a10ec..c88a69255 100644 --- a/tools/lv_berry/lv_widgets.h +++ b/tools/lv_berry/lv_widgets.h @@ -1223,6 +1223,7 @@ void lv_draw_mask_radius_init(lv_draw_mask_radius_param_t * param, const lv_area void lv_draw_mask_fade_init(lv_draw_mask_fade_param_t * param, const lv_area_t * coords, lv_opa_t opa_top, lv_coord_t y_top, lv_opa_t opa_bottom, lv_coord_t y_bottom); void lv_draw_mask_map_init(lv_draw_mask_map_param_t * param, const lv_area_t * coords, const lv_opa_t * map); +LV_ATTRIBUTE_FAST_MEM void lv_draw_rect_dsc_init(lv_draw_rect_dsc_t * dsc); void lv_draw_rect(const lv_area_t * coords, const lv_area_t * mask, const lv_draw_rect_dsc_t * dsc); void lv_draw_px(const lv_point_t * point, const lv_area_t * clip_area, const lv_style_t * style); @@ -1247,3 +1248,4 @@ uint32_t lv_img_buf_get_img_size(lv_coord_t w, lv_coord_t h, lv_img_cf_t cf); // ====================================================================== void lv_refr_now(void); +lv_color_t lv_color_mix(lv_color_t c1, lv_color_t c2, uint8_t mix); \ No newline at end of file