From 7a4108ef93d755e3ea07f48ab518dc47ec2b28f5 Mon Sep 17 00:00:00 2001 From: Stephan Hadinger Date: Sun, 6 Mar 2022 15:50:24 +0100 Subject: [PATCH] Fix WS2812 multi-strip support --- lib/libesp32/berry_tasmota/src/be_leds_lib.c | 51 +++++++++++-------- .../berry_tasmota/src/embedded/leds.be | 12 +++-- tasmota/berry/include/be_gpio_defines.h | 4 +- tasmota/tasmota_template.h | 2 +- tools/lv_gpio/lv_gpio_enum.h | 2 + 5 files changed, 45 insertions(+), 26 deletions(-) diff --git a/lib/libesp32/berry_tasmota/src/be_leds_lib.c b/lib/libesp32/berry_tasmota/src/be_leds_lib.c index 58b0a991e..ee158e4d9 100644 --- a/lib/libesp32/berry_tasmota/src/be_leds_lib.c +++ b/lib/libesp32/berry_tasmota/src/be_leds_lib.c @@ -1203,9 +1203,9 @@ be_local_closure(Leds_show, /* name */ ********************************************************************/ be_local_closure(Leds_ctor, /* name */ be_nested_proto( - 10, /* nstack */ - 4, /* argc */ - 0, /* varg */ + 12, /* nstack */ + 5, /* argc */ + 2, /* varg */ 0, /* has upvals */ NULL, /* no upvals */ 0, /* has sup protos */ @@ -1217,23 +1217,34 @@ be_local_closure(Leds_ctor, /* name */ }), &be_const_str_ctor, &be_const_str_solidified, - ( &(const binstruction[16]) { /* code */ - 0x4C100000, // 0000 LDNIL R4 - 0x1C100604, // 0001 EQ R4 R3 R4 - 0x78120005, // 0002 JMPF R4 #0009 - 0x8C100100, // 0003 GETMET R4 R0 K0 - 0x58180001, // 0004 LDCONST R6 K1 - 0x5C1C0200, // 0005 MOVE R7 R1 - 0x5C200400, // 0006 MOVE R8 R2 - 0x7C100800, // 0007 CALL R4 4 - 0x70020005, // 0008 JMP #000F - 0x8C100100, // 0009 GETMET R4 R0 K0 - 0x58180001, // 000A LDCONST R6 K1 - 0x5C1C0200, // 000B MOVE R7 R1 - 0x5C200400, // 000C MOVE R8 R2 - 0x5C240600, // 000D MOVE R9 R3 - 0x7C100A00, // 000E CALL R4 5 - 0x80000000, // 000F RET 0 + ( &(const binstruction[27]) { /* code */ + 0x4C140000, // 0000 LDNIL R5 + 0x1C140605, // 0001 EQ R5 R3 R5 + 0x78160005, // 0002 JMPF R5 #0009 + 0x8C140100, // 0003 GETMET R5 R0 K0 + 0x581C0001, // 0004 LDCONST R7 K1 + 0x5C200200, // 0005 MOVE R8 R1 + 0x5C240400, // 0006 MOVE R9 R2 + 0x7C140800, // 0007 CALL R5 4 + 0x70020010, // 0008 JMP #001A + 0x4C140000, // 0009 LDNIL R5 + 0x1C140805, // 000A EQ R5 R4 R5 + 0x78160006, // 000B JMPF R5 #0013 + 0x8C140100, // 000C GETMET R5 R0 K0 + 0x581C0001, // 000D LDCONST R7 K1 + 0x5C200200, // 000E MOVE R8 R1 + 0x5C240400, // 000F MOVE R9 R2 + 0x5C280600, // 0010 MOVE R10 R3 + 0x7C140A00, // 0011 CALL R5 5 + 0x70020006, // 0012 JMP #001A + 0x8C140100, // 0013 GETMET R5 R0 K0 + 0x581C0001, // 0014 LDCONST R7 K1 + 0x5C200200, // 0015 MOVE R8 R1 + 0x5C240400, // 0016 MOVE R9 R2 + 0x5C280600, // 0017 MOVE R10 R3 + 0x5C2C0800, // 0018 MOVE R11 R4 + 0x7C140C00, // 0019 CALL R5 6 + 0x80000000, // 001A RET 0 }) ) ); diff --git a/lib/libesp32/berry_tasmota/src/embedded/leds.be b/lib/libesp32/berry_tasmota/src/embedded/leds.be index 11a0489af..a0bad7435 100644 --- a/lib/libesp32/berry_tasmota/src/embedded/leds.be +++ b/lib/libesp32/berry_tasmota/src/embedded/leds.be @@ -4,7 +4,7 @@ # Native commands -# 00 : ctor (leds:int, gpio:int) -> void +# 00 : ctor (leds:int, gpio:int[, type:int, rmt:int]) -> void # 01 : begin void -> void # 02 : show void -> void # 03 : CanShow void -> bool @@ -57,11 +57,15 @@ class Leds : Leds_ntv self.show() end - def ctor(leds, gpio, rmt) - if rmt == nil + def ctor(leds, gpio, type, rmt) + if type == nil self.call_native(0, leds, gpio) else - self.call_native(0, leds, gpio, rmt) + if rmt == nil + self.call_native(0, leds, gpio, type) + else + self.call_native(0, leds, gpio, type, rmt) + end end end def begin() diff --git a/tasmota/berry/include/be_gpio_defines.h b/tasmota/berry/include/be_gpio_defines.h index 8906f90a0..c3b07a7fc 100644 --- a/tasmota/berry/include/be_gpio_defines.h +++ b/tasmota/berry/include/be_gpio_defines.h @@ -14,7 +14,6 @@ const be_const_member_t lv_gpio_constants[] = { { "ADC_INPUT", (int32_t) GPIO_ADC_INPUT }, { "ADC_JOY", (int32_t) GPIO_ADC_JOY }, { "ADC_LIGHT", (int32_t) GPIO_ADC_LIGHT }, - { "ADC_MQ", (int32_t) GPIO_ADC_MQ }, { "ADC_PH", (int32_t) GPIO_ADC_PH }, { "ADC_RANGE", (int32_t) GPIO_ADC_RANGE }, { "ADC_TEMP", (int32_t) GPIO_ADC_TEMP }, @@ -39,6 +38,8 @@ const be_const_member_t lv_gpio_constants[] = { { "CC1101_GDO0", (int32_t) GPIO_CC1101_GDO0 }, { "CC1101_GDO2", (int32_t) GPIO_CC1101_GDO2 }, { "CHANGE", CHANGE }, + { "CM11_RXD", (int32_t) GPIO_CM11_RXD }, + { "CM11_TXD", (int32_t) GPIO_CM11_TXD }, { "CNTR1", (int32_t) GPIO_CNTR1 }, { "CNTR1_NP", (int32_t) GPIO_CNTR1_NP }, { "CSE7761_RX", (int32_t) GPIO_CSE7761_RX }, @@ -130,6 +131,7 @@ const be_const_member_t lv_gpio_constants[] = { { "MAX7219CLK", (int32_t) GPIO_MAX7219CLK }, { "MAX7219CS", (int32_t) GPIO_MAX7219CS }, { "MAX7219DIN", (int32_t) GPIO_MAX7219DIN }, + { "MAX_RMT", MAX_RMT }, { "MCP2515_CS", (int32_t) GPIO_MCP2515_CS }, { "MCP39F5_RST", (int32_t) GPIO_MCP39F5_RST }, { "MCP39F5_RX", (int32_t) GPIO_MCP39F5_RX }, diff --git a/tasmota/tasmota_template.h b/tasmota/tasmota_template.h index d5a589bf6..490ff9bdf 100644 --- a/tasmota/tasmota_template.h +++ b/tasmota/tasmota_template.h @@ -616,7 +616,7 @@ const uint16_t kGpioNiceList[] PROGMEM = { AGPIO(GPIO_P9813_CLK), // P9813 CLOCK AGPIO(GPIO_P9813_DAT), // P9813 DATA #else - AGPIO(GPIO_WS2812) + MAX_RMT,// WS2812 Led string, using RMT on ESP32 + AGPIO(GPIO_WS2812) + (MAX_RMT ? MAX_RMT + 1 : 0),// WS2812 Led string, using RMT on ESP32 #endif // NEO_HW_P9813 #endif #ifdef USE_ARILUX_RF diff --git a/tools/lv_gpio/lv_gpio_enum.h b/tools/lv_gpio/lv_gpio_enum.h index 51e83ae7e..3f56ef2b2 100644 --- a/tools/lv_gpio/lv_gpio_enum.h +++ b/tools/lv_gpio/lv_gpio_enum.h @@ -17,6 +17,8 @@ RISING FALLING CHANGE +MAX_RMT + NONE = GPIO_NONE KEY1 = GPIO_KEY1 KEY1_NP = GPIO_KEY1_NP