diff --git a/CHANGELOG.md b/CHANGELOG.md index 6aedcca29..d21865e83 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ All notable changes to this project will be documented in this file. ### Added - TLS enabled ECDSA by default for ESP8266 (#24009) - Berry add `cb.free_cb` for extension manager (#24014) +- Berry `light.get()` direct access to values ### Breaking Changed diff --git a/lib/libesp32/berry_tasmota/src/embedded/leds.be b/lib/libesp32/berry_tasmota/src/embedded/leds.be index fd0a681a8..400715f65 100644 --- a/lib/libesp32/berry_tasmota/src/embedded/leds.be +++ b/lib/libesp32/berry_tasmota/src/embedded/leds.be @@ -38,7 +38,7 @@ class Leds : Leds_ntv # in such case, `self._p` is equal to `0` self.leds = self.pixel_count() import light - self.bri = light.get()['bri'] + self.bri = light.get(0, 'bri') else # use pure Berry driver leds = int(leds) diff --git a/lib/libesp32/berry_tasmota/src/solidify/solidified_leds.h b/lib/libesp32/berry_tasmota/src/solidify/solidified_leds.h index b8ec11235..8a6cd5c3c 100644 --- a/lib/libesp32/berry_tasmota/src/solidify/solidified_leds.h +++ b/lib/libesp32/berry_tasmota/src/solidify/solidified_leds.h @@ -947,7 +947,7 @@ be_local_closure(class_Leds_init, /* name */ &be_ktab_class_Leds, /* shared constants */ &be_const_str_init, &be_const_str_solidified, - ( &(const binstruction[90]) { /* code */ + ( &(const binstruction[91]) { /* code */ 0xA4161000, // 0000 IMPORT R5 K8 0x50180200, // 0001 LDBOOL R6 1 0 0x90020806, // 0002 SETMBR R0 K4 R6 @@ -962,7 +962,7 @@ be_local_closure(class_Leds_init, /* name */ 0x5824000B, // 000B LDCONST R9 K11 0x7C180600, // 000C CALL R6 3 0x1C180406, // 000D EQ R6 R2 R6 - 0x781A000A, // 000E JMPF R6 #001A + 0x781A000B, // 000E JMPF R6 #001B 0x8C18010C, // 000F GETMET R6 R0 K12 0x7C180200, // 0010 CALL R6 1 0x8C180102, // 0011 GETMET R6 R0 K2 @@ -970,74 +970,75 @@ be_local_closure(class_Leds_init, /* name */ 0x90021A06, // 0013 SETMBR R0 K13 R6 0xA41A1C00, // 0014 IMPORT R6 K14 0x8C1C0D10, // 0015 GETMET R7 R6 K16 - 0x7C1C0200, // 0016 CALL R7 1 - 0x941C0F0F, // 0017 GETIDX R7 R7 K15 - 0x90021E07, // 0018 SETMBR R0 K15 R7 - 0x70020039, // 0019 JMP #0054 - 0x60180009, // 001A GETGBL R6 G9 - 0x5C1C0200, // 001B MOVE R7 R1 - 0x7C180200, // 001C CALL R6 1 - 0x5C040C00, // 001D MOVE R1 R6 - 0x90021A01, // 001E SETMBR R0 K13 R1 - 0x541A007E, // 001F LDINT R6 127 - 0x90021E06, // 0020 SETMBR R0 K15 R6 - 0xB81A2200, // 0021 GETNGBL R6 K17 - 0x8C180D12, // 0022 GETMET R6 R6 K18 - 0x58200013, // 0023 LDCONST R8 K19 - 0x7C180400, // 0024 CALL R6 2 - 0x741A0003, // 0025 JMPT R6 #002A - 0xB81A2200, // 0026 GETNGBL R6 K17 - 0x601C0013, // 0027 GETGBL R7 G19 - 0x7C1C0000, // 0028 CALL R7 0 - 0x901A2607, // 0029 SETMBR R6 K19 R7 - 0xB81A2200, // 002A GETNGBL R6 K17 - 0x88180D13, // 002B GETMBR R6 R6 K19 - 0x8C180D14, // 002C GETMET R6 R6 K20 - 0x5C200200, // 002D MOVE R8 R1 - 0x7C180400, // 002E CALL R6 2 - 0x4C1C0000, // 002F LDNIL R7 - 0x20180C07, // 0030 NE R6 R6 R7 - 0x781A0016, // 0031 JMPF R6 #0049 - 0xB81A2200, // 0032 GETNGBL R6 K17 - 0x88180D13, // 0033 GETMBR R6 R6 K19 - 0x8C180D14, // 0034 GETMET R6 R6 K20 - 0x5C200200, // 0035 MOVE R8 R1 - 0x7C180400, // 0036 CALL R6 2 - 0x881C010D, // 0037 GETMBR R7 R0 K13 - 0x88200D0D, // 0038 GETMBR R8 R6 K13 - 0x201C0E08, // 0039 NE R7 R7 R8 - 0x781E0005, // 003A JMPF R7 #0041 - 0x601C0018, // 003B GETGBL R7 G24 - 0x58200015, // 003C LDCONST R8 K21 - 0x8824010D, // 003D GETMBR R9 R0 K13 - 0x88280D0D, // 003E GETMBR R10 R6 K13 - 0x7C1C0600, // 003F CALL R7 3 - 0xB0062C07, // 0040 RAISE 1 K22 R7 - 0x881C0D17, // 0041 GETMBR R7 R6 K23 - 0x90022E07, // 0042 SETMBR R0 K23 R7 - 0x881C0D07, // 0043 GETMBR R7 R6 K7 - 0x90020E07, // 0044 SETMBR R0 K7 R7 - 0xB81E2200, // 0045 GETNGBL R7 K17 - 0x881C0F13, // 0046 GETMBR R7 R7 K19 - 0x981C0200, // 0047 SETIDX R7 R1 R0 - 0x7002000A, // 0048 JMP #0054 - 0x8C18010C, // 0049 GETMET R6 R0 K12 - 0x5C200200, // 004A MOVE R8 R1 - 0x5C240400, // 004B MOVE R9 R2 - 0x5C280600, // 004C MOVE R10 R3 - 0x5C2C0800, // 004D MOVE R11 R4 - 0x7C180A00, // 004E CALL R6 5 - 0xB81A2200, // 004F GETNGBL R6 K17 - 0x88180D13, // 0050 GETMBR R6 R6 K19 - 0x98180200, // 0051 SETIDX R6 R1 R0 - 0x8C180118, // 0052 GETMET R6 R0 K24 - 0x7C180200, // 0053 CALL R6 1 - 0x88180117, // 0054 GETMBR R6 R0 K23 - 0x4C1C0000, // 0055 LDNIL R7 - 0x1C180C07, // 0056 EQ R6 R6 R7 - 0x781A0000, // 0057 JMPF R6 #0059 - 0xB006331A, // 0058 RAISE 1 K25 K26 - 0x80000000, // 0059 RET 0 + 0x5824000B, // 0016 LDCONST R9 K11 + 0x5828000F, // 0017 LDCONST R10 K15 + 0x7C1C0600, // 0018 CALL R7 3 + 0x90021E07, // 0019 SETMBR R0 K15 R7 + 0x70020039, // 001A JMP #0055 + 0x60180009, // 001B GETGBL R6 G9 + 0x5C1C0200, // 001C MOVE R7 R1 + 0x7C180200, // 001D CALL R6 1 + 0x5C040C00, // 001E MOVE R1 R6 + 0x90021A01, // 001F SETMBR R0 K13 R1 + 0x541A007E, // 0020 LDINT R6 127 + 0x90021E06, // 0021 SETMBR R0 K15 R6 + 0xB81A2200, // 0022 GETNGBL R6 K17 + 0x8C180D12, // 0023 GETMET R6 R6 K18 + 0x58200013, // 0024 LDCONST R8 K19 + 0x7C180400, // 0025 CALL R6 2 + 0x741A0003, // 0026 JMPT R6 #002B + 0xB81A2200, // 0027 GETNGBL R6 K17 + 0x601C0013, // 0028 GETGBL R7 G19 + 0x7C1C0000, // 0029 CALL R7 0 + 0x901A2607, // 002A SETMBR R6 K19 R7 + 0xB81A2200, // 002B GETNGBL R6 K17 + 0x88180D13, // 002C GETMBR R6 R6 K19 + 0x8C180D14, // 002D GETMET R6 R6 K20 + 0x5C200200, // 002E MOVE R8 R1 + 0x7C180400, // 002F CALL R6 2 + 0x4C1C0000, // 0030 LDNIL R7 + 0x20180C07, // 0031 NE R6 R6 R7 + 0x781A0016, // 0032 JMPF R6 #004A + 0xB81A2200, // 0033 GETNGBL R6 K17 + 0x88180D13, // 0034 GETMBR R6 R6 K19 + 0x8C180D14, // 0035 GETMET R6 R6 K20 + 0x5C200200, // 0036 MOVE R8 R1 + 0x7C180400, // 0037 CALL R6 2 + 0x881C010D, // 0038 GETMBR R7 R0 K13 + 0x88200D0D, // 0039 GETMBR R8 R6 K13 + 0x201C0E08, // 003A NE R7 R7 R8 + 0x781E0005, // 003B JMPF R7 #0042 + 0x601C0018, // 003C GETGBL R7 G24 + 0x58200015, // 003D LDCONST R8 K21 + 0x8824010D, // 003E GETMBR R9 R0 K13 + 0x88280D0D, // 003F GETMBR R10 R6 K13 + 0x7C1C0600, // 0040 CALL R7 3 + 0xB0062C07, // 0041 RAISE 1 K22 R7 + 0x881C0D17, // 0042 GETMBR R7 R6 K23 + 0x90022E07, // 0043 SETMBR R0 K23 R7 + 0x881C0D07, // 0044 GETMBR R7 R6 K7 + 0x90020E07, // 0045 SETMBR R0 K7 R7 + 0xB81E2200, // 0046 GETNGBL R7 K17 + 0x881C0F13, // 0047 GETMBR R7 R7 K19 + 0x981C0200, // 0048 SETIDX R7 R1 R0 + 0x7002000A, // 0049 JMP #0055 + 0x8C18010C, // 004A GETMET R6 R0 K12 + 0x5C200200, // 004B MOVE R8 R1 + 0x5C240400, // 004C MOVE R9 R2 + 0x5C280600, // 004D MOVE R10 R3 + 0x5C2C0800, // 004E MOVE R11 R4 + 0x7C180A00, // 004F CALL R6 5 + 0xB81A2200, // 0050 GETNGBL R6 K17 + 0x88180D13, // 0051 GETMBR R6 R6 K19 + 0x98180200, // 0052 SETIDX R6 R1 R0 + 0x8C180118, // 0053 GETMET R6 R0 K24 + 0x7C180200, // 0054 CALL R6 1 + 0x88180117, // 0055 GETMBR R6 R0 K23 + 0x4C1C0000, // 0056 LDNIL R7 + 0x1C180C07, // 0057 EQ R6 R6 R7 + 0x781A0000, // 0058 JMPF R6 #005A + 0xB006331A, // 0059 RAISE 1 K25 K26 + 0x80000000, // 005A RET 0 }) ) ); diff --git a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_light.ino b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_light.ino index 31eb37125..da75b5511 100644 --- a/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_light.ino +++ b/tasmota/tasmota_xdrv_driver/xdrv_52_3_berry_light.ino @@ -32,9 +32,18 @@ extern "C" { // push the light status object on the vm stack - void push_getlight(bvm *vm, uint32_t light_num) { + void push_getlight(bvm *vm, uint32_t light_num, int32_t idx_name) { // idx_name is the index of name parameter, or 0 if none bool data_present = false; // do we have relevant data - be_newobject(vm, "map"); + + if (idx_name != 0) { // argument is name + be_pushnil(vm); + be_pushvalue(vm, 2); + // (-2) nil, (-1) string -> if key matches then update (-2) + } else { + be_newobject(vm, "map"); + // (-2) map instance, (-1) map + } + // check if the light exist // TasmotaGlobal.devices_present // Light.device @@ -128,12 +137,19 @@ extern "C" { int32_t l_getlight(bvm *vm); int32_t l_getlight(bvm *vm) { int32_t top = be_top(vm); // Get the number of arguments - if (top == 0 || (top == 1 && be_isint(vm, 1))) { + if (top == 0 || (top >= 1 && be_isint(vm, 1))) { int32_t light_num = 0; - if (top > 0) { + if (top >= 1) { light_num = be_toint(vm, 1); } - push_getlight(vm, light_num); + + if (top >= 2 && be_isstring(vm, 2)) { // argument is name + push_getlight(vm, light_num, 2); // pass the name to filter value + } else { + be_newobject(vm, "map"); + push_getlight(vm, light_num, 0); // request the full map + } + be_return(vm); // Return } be_raise(vm, kTypeError, nullptr); @@ -289,7 +305,7 @@ extern "C" { } } - push_getlight(vm, idx); + push_getlight(vm, idx, 0); be_return(vm); // Return } be_raise(vm, kTypeError, nullptr);