diff --git a/.gitignore b/.gitignore index 2dbf50516..1dd51a787 100644 --- a/.gitignore +++ b/.gitignore @@ -19,14 +19,10 @@ data unpacked_fs tasmota/user_config_override.h build -build_output +build_output/* firmware.map firmware.asm tasmota/tasmota.ino.cpp -tasmota*.bin -tasmota*.bin.gz -tasmota*.map -tasmota*.map.gz platformio_override.ini platformio_tasmota_cenv.ini diff --git a/boards/esp32_4M_2APP.json b/boards/esp32_4M_2APP.json new file mode 100644 index 000000000..34e8248e6 --- /dev/null +++ b/boards/esp32_4M_2APP.json @@ -0,0 +1,46 @@ +{ + "build": { + "arduino":{ + "ldscript": "esp32_out.ld" + }, + "core": "esp32", + "extra_flags": "-DARDUINO_ESP32_DEV -DBOARD_HAS_PSRAM -DARDUINO_USB_CDC_ON_BOOT=0 -DESP32_4M", + "f_cpu": "80000000L", + "f_flash": "40000000L", + "flash_mode": "dout", + "mcu": "esp32", + "variant": "esp32", + "partitions": "esp32_partition_app2880k_spiffs320k.csv" + }, + "connectivity": [ + "wifi", + "bluetooth", + "ethernet", + "can" + ], + "debug": { + "openocd_target": "esp32.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "Espressif Generic ESP32 4M Flash, Tasmota 2880k Code/OTA, 320k FS", + "upload": { + "arduino": { + "flash_extra_images": [ + [ + "0x2E0000", + "variants/tasmota/tasmota32-minicustom.bin" + ] + ] + }, + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "require_upload_port": true, + "speed": 460800 + }, + "url": "https://en.wikipedia.org/wiki/ESP32", + "vendor": "Espressif" + } diff --git a/esp32_partition_app2880k_spiffs320k.csv b/esp32_partition_app2880k_spiffs320k.csv new file mode 100644 index 000000000..511ce01a1 --- /dev/null +++ b/esp32_partition_app2880k_spiffs320k.csv @@ -0,0 +1,6 @@ +# Name, Type, SubType, Offset, Size, Flags +nvs, data, nvs, 0x9000, 0x5000, +otadata, data, ota, 0xe000, 0x2000, +app0, app, ota_0, 0x10000, 0x2D0000, +factory, app, factory, 0x2E0000,0xD0000, +spiffs, data, spiffs, 0x3B0000,0x50000, diff --git a/lib/libesp32/berry/src/be_bytecode.c b/lib/libesp32/berry/src/be_bytecode.c index 90ff79c6f..14599441d 100644 --- a/lib/libesp32/berry/src/be_bytecode.c +++ b/lib/libesp32/berry/src/be_bytecode.c @@ -214,8 +214,10 @@ static void save_proto_table(bvm *vm, void *fp, bproto *proto) { bproto **p = proto->ptab, **end; save_long(fp, proto->nproto); /* proto count */ - for (end = p + proto->nproto; p < end; ++p) { - save_proto(vm, fp, *p); + if (p) { + for (end = p + proto->nproto; p < end; ++p) { + save_proto(vm, fp, *p); + } } } @@ -223,9 +225,11 @@ static void save_upvals(void *fp, bproto *proto) { bupvaldesc *uv = proto->upvals, *end; save_byte(fp, proto->nupvals); /* upvals count */ - for (end = uv + proto->nupvals; uv < end; ++uv) { - save_byte(fp, uv->instack); - save_byte(fp, uv->idx); + if (uv) { + for (end = uv + proto->nupvals; uv < end; ++uv) { + save_byte(fp, uv->instack); + save_byte(fp, uv->idx); + } } } @@ -492,7 +496,7 @@ static void load_constant(bvm *vm, void *fp, bproto *proto, int version) } } -static void load_proto_table(bvm *vm, void *fp, bproto *proto, int version) +static void load_proto_table(bvm *vm, void *fp, bproto *proto, int info, int version) { int size = (int)load_long(fp); /* proto count */ if (size) { @@ -501,7 +505,7 @@ static void load_proto_table(bvm *vm, void *fp, bproto *proto, int version) proto->ptab = p; proto->nproto = size; while (size--) { - load_proto(vm, fp, p++, -1, version); + load_proto(vm, fp, p++, info, version); } } } @@ -538,7 +542,7 @@ static bbool load_proto(bvm *vm, void *fp, bproto **proto, int info, int version } load_bytecode(vm, fp, *proto, info); load_constant(vm, fp, *proto, version); - load_proto_table(vm, fp, *proto, version); + load_proto_table(vm, fp, *proto, info, version); load_upvals(vm, fp, *proto); return btrue; } diff --git a/lib/libesp32/berry/src/be_var.c b/lib/libesp32/berry/src/be_var.c index 9960e7cc3..1a8e5b18c 100644 --- a/lib/libesp32/berry/src/be_var.c +++ b/lib/libesp32/berry/src/be_var.c @@ -12,6 +12,7 @@ #include "be_map.h" #include "be_gc.h" #include "be_class.h" +#include #define global(vm) ((vm)->gbldesc.global) #define builtin(vm) ((vm)->gbldesc.builtin) diff --git a/lib/libesp32/berry_tasmota/src/be_lv_openhasp.c b/lib/libesp32/berry_tasmota/src/be_lv_openhasp.c index f925d6325..5ead9fc0c 100644 --- a/lib/libesp32/berry_tasmota/src/be_lv_openhasp.c +++ b/lib/libesp32/berry_tasmota/src/be_lv_openhasp.c @@ -1968,7 +1968,7 @@ be_local_closure(lvh_obj_get_obj, /* name */ ********************************************************************/ be_local_closure(lvh_obj_get_action, /* name */ be_nested_proto( - 2, /* nstack */ + 3, /* nstack */ 1, /* argc */ 2, /* varg */ 0, /* has upvals */ @@ -1976,14 +1976,19 @@ be_local_closure(lvh_obj_get_action, /* name */ 0, /* has sup protos */ NULL, /* no sub protos */ 1, /* has constants */ - ( &(const bvalue[ 1]) { /* constants */ + ( &(const bvalue[ 2]) { /* constants */ /* K0 */ be_nested_str_literal("_action"), + /* K1 */ be_nested_str_literal(""), }), be_str_literal("get_action"), &be_const_str_solidified, - ( &(const binstruction[ 2]) { /* code */ + ( &(const binstruction[ 6]) { /* code */ 0x88040100, // 0000 GETMBR R1 R0 K0 - 0x80040200, // 0001 RET 1 R1 + 0x78060001, // 0001 JMPF R1 #0004 + 0x5C080200, // 0002 MOVE R2 R1 + 0x70020000, // 0003 JMP #0005 + 0x58080001, // 0004 LDCONST R2 K1 + 0x80040400, // 0005 RET 1 R2 }) ) ); @@ -3438,66 +3443,66 @@ be_local_closure(lvh_obj_event_cb, /* name */ ), }), 1, /* has constants */ - ( &(const bvalue[16]) { /* constants */ + ( &(const bvalue[17]) { /* constants */ /* K0 */ be_nested_str_literal("_page"), /* K1 */ be_nested_str_literal("_oh"), /* K2 */ be_nested_str_literal("code"), /* K3 */ be_nested_str_literal("action"), - /* K4 */ be_nested_str_literal("lv"), - /* K5 */ be_nested_str_literal("EVENT_CLICKED"), - /* K6 */ be_nested_str_literal("tasmota"), - /* K7 */ be_nested_str_literal("set_timer"), - /* K8 */ be_const_int(0), - /* K9 */ be_nested_str_literal("_event_map"), - /* K10 */ be_nested_str_literal("find"), - /* K11 */ be_nested_str_literal("string"), - /* K12 */ be_nested_str_literal("format"), - /* K13 */ be_nested_str_literal("{\"hasp\":{\"p%ib%i\":\"%s\"}}"), - /* K14 */ be_nested_str_literal("_page_id"), - /* K15 */ be_nested_str_literal("id"), + /* K4 */ be_nested_str_literal(""), + /* K5 */ be_nested_str_literal("lv"), + /* K6 */ be_nested_str_literal("EVENT_CLICKED"), + /* K7 */ be_nested_str_literal("tasmota"), + /* K8 */ be_nested_str_literal("set_timer"), + /* K9 */ be_const_int(0), + /* K10 */ be_nested_str_literal("_event_map"), + /* K11 */ be_nested_str_literal("find"), + /* K12 */ be_nested_str_literal("string"), + /* K13 */ be_nested_str_literal("format"), + /* K14 */ be_nested_str_literal("{\"hasp\":{\"p%ib%i\":\"%s\"}}"), + /* K15 */ be_nested_str_literal("_page_id"), + /* K16 */ be_nested_str_literal("id"), }), be_str_literal("event_cb"), &be_const_str_solidified, - ( &(const binstruction[39]) { /* code */ + ( &(const binstruction[38]) { /* code */ 0x88080100, // 0000 GETMBR R2 R0 K0 0x88080501, // 0001 GETMBR R2 R2 K1 0x880C0302, // 0002 GETMBR R3 R1 K2 0x88100103, // 0003 GETMBR R4 R0 K3 - 0x4C140000, // 0004 LDNIL R5 - 0x20100805, // 0005 NE R4 R4 R5 - 0x78120008, // 0006 JMPF R4 #0010 - 0xB8120800, // 0007 GETNGBL R4 K4 - 0x88100905, // 0008 GETMBR R4 R4 K5 - 0x1C100604, // 0009 EQ R4 R3 R4 - 0x78120004, // 000A JMPF R4 #0010 - 0xB8120C00, // 000B GETNGBL R4 K6 - 0x8C100907, // 000C GETMET R4 R4 K7 - 0x58180008, // 000D LDCONST R6 K8 - 0x841C0000, // 000E CLOSURE R7 P0 - 0x7C100600, // 000F CALL R4 3 - 0x88100109, // 0010 GETMBR R4 R0 K9 - 0x8C10090A, // 0011 GETMET R4 R4 K10 - 0x5C180600, // 0012 MOVE R6 R3 - 0x7C100400, // 0013 CALL R4 2 - 0x4C140000, // 0014 LDNIL R5 - 0x20140805, // 0015 NE R5 R4 R5 - 0x7816000D, // 0016 JMPF R5 #0025 - 0xA4161600, // 0017 IMPORT R5 K11 - 0x8C180B0C, // 0018 GETMET R6 R5 K12 - 0x5820000D, // 0019 LDCONST R8 K13 - 0x88240100, // 001A GETMBR R9 R0 K0 - 0x8824130E, // 001B GETMBR R9 R9 K14 - 0x8828010F, // 001C GETMBR R10 R0 K15 - 0x5C2C0800, // 001D MOVE R11 R4 - 0x7C180A00, // 001E CALL R6 5 - 0xB81E0C00, // 001F GETNGBL R7 K6 - 0x8C1C0F07, // 0020 GETMET R7 R7 K7 - 0x58240008, // 0021 LDCONST R9 K8 - 0x84280001, // 0022 CLOSURE R10 P1 - 0x7C1C0600, // 0023 CALL R7 3 - 0xA0140000, // 0024 CLOSE R5 - 0xA0000000, // 0025 CLOSE R0 - 0x80000000, // 0026 RET 0 + 0x20100904, // 0004 NE R4 R4 K4 + 0x78120008, // 0005 JMPF R4 #000F + 0xB8120A00, // 0006 GETNGBL R4 K5 + 0x88100906, // 0007 GETMBR R4 R4 K6 + 0x1C100604, // 0008 EQ R4 R3 R4 + 0x78120004, // 0009 JMPF R4 #000F + 0xB8120E00, // 000A GETNGBL R4 K7 + 0x8C100908, // 000B GETMET R4 R4 K8 + 0x58180009, // 000C LDCONST R6 K9 + 0x841C0000, // 000D CLOSURE R7 P0 + 0x7C100600, // 000E CALL R4 3 + 0x8810010A, // 000F GETMBR R4 R0 K10 + 0x8C10090B, // 0010 GETMET R4 R4 K11 + 0x5C180600, // 0011 MOVE R6 R3 + 0x7C100400, // 0012 CALL R4 2 + 0x4C140000, // 0013 LDNIL R5 + 0x20140805, // 0014 NE R5 R4 R5 + 0x7816000D, // 0015 JMPF R5 #0024 + 0xA4161800, // 0016 IMPORT R5 K12 + 0x8C180B0D, // 0017 GETMET R6 R5 K13 + 0x5820000E, // 0018 LDCONST R8 K14 + 0x88240100, // 0019 GETMBR R9 R0 K0 + 0x8824130F, // 001A GETMBR R9 R9 K15 + 0x88280110, // 001B GETMBR R10 R0 K16 + 0x5C2C0800, // 001C MOVE R11 R4 + 0x7C180A00, // 001D CALL R6 5 + 0xB81E0E00, // 001E GETNGBL R7 K7 + 0x8C1C0F08, // 001F GETMET R7 R7 K8 + 0x58240009, // 0020 LDCONST R9 K9 + 0x84280001, // 0021 CLOSURE R10 P1 + 0x7C1C0600, // 0022 CALL R7 3 + 0xA0140000, // 0023 CLOSE R5 + 0xA0000000, // 0024 CLOSE R0 + 0x80000000, // 0025 RET 0 }) ) ); diff --git a/pio-tools/copy_safemode.py b/pio-tools/copy_safemode.py new file mode 100644 index 000000000..ea676af9f --- /dev/null +++ b/pio-tools/copy_safemode.py @@ -0,0 +1,20 @@ +import os +import shutil +from os.path import join +from SCons.Script import DefaultEnvironment + +env = DefaultEnvironment() +platform = env.PioPlatform() + +FRAMEWORK_DIR = platform.get_package_dir("framework-arduinoespressif32") + +safemode_dir = join(env["PROJECT_DIR"], "safemode") +variants_dir = join(FRAMEWORK_DIR, "variants", "tasmota") + +if env["PIOPLATFORM"] == "espressif32": + if os.path.exists(safemode_dir): +# print("safemode.bin dir exists") + if os.path.exists(variants_dir): +# print("variants/tasmota exists") + shutil.rmtree(variants_dir) + shutil.copytree(safemode_dir, variants_dir) diff --git a/platformio_override_sample.ini b/platformio_override_sample.ini index 35e0708e4..629f03e67 100644 --- a/platformio_override_sample.ini +++ b/platformio_override_sample.ini @@ -91,7 +91,7 @@ lib_extra_dirs = ${library.lib_extra_dirs} [env:tasmota32_base] ; *** Uncomment next lines ";" to enable development Tasmota Arduino version ESP32 ;platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.3rc1/platform-espressif32-2.0.3new.zip -;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/822/framework-arduinoespressif32-v4.4_work-c4b83228a5.tar.gz +;platform_packages = framework-arduinoespressif32 @ https://github.com/Jason2866/esp32-arduino-lib-builder/releases/download/825/framework-arduinoespressif32-v4.4_work-c4b83228a5.tar.gz build_unflags = ${esp32_defaults.build_unflags} build_flags = ${esp32_defaults.build_flags} diff --git a/platformio_tasmota32.ini b/platformio_tasmota32.ini index 8c604f663..38f17ebd3 100644 --- a/platformio_tasmota32.ini +++ b/platformio_tasmota32.ini @@ -34,6 +34,7 @@ build_flags = ${esp_defaults.build_flags} -Wl,--wrap=panicHandler -Wl,--wrap=xt_unhandled_exception -Wl,--wrap=_Z11analogWritehi ; `analogWrite(unsigned char, int)` use the Tasmota version of analogWrite for deeper integration and phase control extra_scripts = pre:pio-tools/add_c_flags.py + pre:pio-tools/copy_safemode.py post:pio-tools/post_esp32.py ${esp_defaults.extra_scripts} diff --git a/safemode/tasmota32-minicustom.bin b/safemode/tasmota32-minicustom.bin new file mode 100644 index 000000000..e614201ff Binary files /dev/null and b/safemode/tasmota32-minicustom.bin differ diff --git a/tasmota/berry/drivers/i2c_axp192_M5StackCore2.be b/tasmota/berry/drivers/AXP192_M5Stack_Core2.be similarity index 98% rename from tasmota/berry/drivers/i2c_axp192_M5StackCore2.be rename to tasmota/berry/drivers/AXP192_M5Stack_Core2.be index 212fc8e32..309006987 100644 --- a/tasmota/berry/drivers/i2c_axp192_M5StackCore2.be +++ b/tasmota/berry/drivers/AXP192_M5Stack_Core2.be @@ -73,6 +73,8 @@ class AXP192_M5Stack_Core2 : AXP192 # bus power mode_output self.set_buf_power_mode(false) + + tasmota.add_driver(self) end end @@ -132,5 +134,4 @@ class AXP192_M5Stack_Core2 : AXP192 end -axp = AXP192_M5Stack_Core2() -tasmota.add_driver(axp) +return AXP192_M5Stack_Core2() diff --git a/tasmota/berry/drivers/i2c_axp192_M5StackTough.be b/tasmota/berry/drivers/AXP192_M5Stack_Tough.be similarity index 98% rename from tasmota/berry/drivers/i2c_axp192_M5StackTough.be rename to tasmota/berry/drivers/AXP192_M5Stack_Tough.be index cace43a89..5444b9eda 100644 --- a/tasmota/berry/drivers/i2c_axp192_M5StackTough.be +++ b/tasmota/berry/drivers/AXP192_M5Stack_Tough.be @@ -88,6 +88,8 @@ class AXP192_M5Stack_Tough : AXP192 else self.set_buf_power_mode(false) end + + tasmota.add_driver(self) end end @@ -147,5 +149,4 @@ class AXP192_M5Stack_Tough : AXP192 end -axp = AXP192_M5Stack_Tough() -tasmota.add_driver(axp) +return AXP192_M5Stack_Tough() diff --git a/tasmota/berry/drivers/i2c_axp192_M5StickC.be b/tasmota/berry/drivers/AXP192_M5StickC.be similarity index 98% rename from tasmota/berry/drivers/i2c_axp192_M5StickC.be rename to tasmota/berry/drivers/AXP192_M5StickC.be index 1d243feb6..f5c2856df 100644 --- a/tasmota/berry/drivers/i2c_axp192_M5StickC.be +++ b/tasmota/berry/drivers/AXP192_M5StickC.be @@ -67,6 +67,8 @@ class AXP192_M5StickC : AXP192 # Bit 1: APS voltage ADC enable # Bit 0: TS pin ADC function enable self.write8(0x82, 0xFF) + + tasmota.add_driver(self) end end @@ -103,5 +105,4 @@ class AXP192_M5StickC : AXP192 end end -axp = AXP192_M5StickC() -tasmota.add_driver(axp) +return AXP192_M5StickC() diff --git a/tasmota/berry/drivers/i2c_axp202_LilyGO_TWatch_2020V3.be b/tasmota/berry/drivers/AXP202_LilyGo_TWatch_2020V3.be similarity index 96% rename from tasmota/berry/drivers/i2c_axp202_LilyGO_TWatch_2020V3.be rename to tasmota/berry/drivers/AXP202_LilyGo_TWatch_2020V3.be index 63fecc51e..2d853f428 100644 --- a/tasmota/berry/drivers/i2c_axp202_LilyGO_TWatch_2020V3.be +++ b/tasmota/berry/drivers/AXP202_LilyGo_TWatch_2020V3.be @@ -40,6 +40,8 @@ class AXP202_LilyGo_TWatch_2020V3 : AXP202 # // No use # power->setPowerOutPut(AXP202_LDO3, false); self.set_ldo_enable(3, false) + + tasmota.add_driver(self) end end @@ -66,5 +68,4 @@ class AXP202_LilyGo_TWatch_2020V3 : AXP202 end end -axp202 = AXP202_LilyGo_TWatch_2020V3() -tasmota.add_driver(axp202) +return AXP202_LilyGo_TWatch_2020V3() diff --git a/tasmota/berry/drivers/CHSC6540.be b/tasmota/berry/drivers/CHSC6540.be new file mode 100644 index 000000000..7fd1cf785 --- /dev/null +++ b/tasmota/berry/drivers/CHSC6540.be @@ -0,0 +1,78 @@ +#- + - I2C driver for the Touch Screen driver CHSC6540 of the M5Stack Tough + - + - This is based on + - https://github.com/m5stack/M5Tough/blob/master/src/M5Touch.cpp + - https://github.com/m5stack/M5Tough/blob/master/src/M5Touch.h + -# + + class CHSC6540 : I2C_Driver + var tp_int # gpio used as INT - going low when the screen is touched + # prevous values + var touched, x, y # previous values (bool, int, int) to be repeated when not touched + + def init() + # set current values + self.x = 0 + self.y = 0 + self.touched = false + + self.tp_int = gpio.pin(gpio.INTERRUPT, 0) + super(self).init("CHSC6540", 0x2E) + + tasmota.add_driver(self) + # check that display is present + import introspect + if !introspect.module("display") + tasmota.log("I2C: can't start CHSC6540 without display enabled", 3) + self.wire = nil + end + + if self.tp_int < 0 + tasmota.log("I2C: can't start CHSC6540 without INTERRUPT-1 gpio configured", 3) + self.wire = nil + else + gpio.pin_mode(self.tp_int, gpio.INPUT_PULLUP) + end + + # all good, configure device + if self.wire + self.write8(0x5A, 0x5A) # INT mode change + + tasmota.add_driver(self) + end + end + + # is the screen pressed - i.e. TP_INT is low + def is_pressed() + if self.wire == nil return end + return gpio.digital_read(self.tp_int) == 0 + end + + def every_50ms() + if self.wire == nil return end + + self.touched = self.is_pressed() + # tasmota.log("DEBUG> int="+str(self.tp_int)+" touched="+str(self.touched), 2) + if self.touched + import string + var raw_read = self.wire.read_bytes(self.addr, 0x02, 11) # read a series of 11 bytes at from register 0x02 + var pts = raw_read[0] + if pts <= 0 || pts > 2 return end # wrong + # supports multi-touch + #var p0f = (raw_read[4] & 0x10) != 0 # unused for now + self.x = raw_read.get(1,-2) & 0x0FFF + self.y = raw_read.get(3,-2) & 0x0FFF + # tasmota.log(string.format("I2C: screen pressed x=%i y=%i", self.x, self.y), 2) + # var p1x = raw_read.get(7,2) & 0x0FFF + # var p1y = raw_read.get(9,2) & 0x0FFF + end + + # return values + import display + display.touch_update(self.touched ? 1 : 0, self.x, self.y, 0) + end + +end + +return CHSC6540() diff --git a/tasmota/berry/drivers/mpu_accel.be b/tasmota/berry/drivers/MPU6886_9250.be similarity index 98% rename from tasmota/berry/drivers/mpu_accel.be rename to tasmota/berry/drivers/MPU6886_9250.be index 7c2c1353a..9e5cb400c 100644 --- a/tasmota/berry/drivers/mpu_accel.be +++ b/tasmota/berry/drivers/MPU6886_9250.be @@ -5,7 +5,7 @@ - Alternative to xsns_85_mpu6886.ino -# -class MPU6886 : I2C_Driver +class MPU6886_9250 : I2C_Driver var device var gres, ares var accel, gyro @@ -49,6 +49,8 @@ class MPU6886 : I2C_Driver self.gres = 2000.0/32768.0 self.ares = 8.0/32678.0 + + tasmota.add_driver(self) end end @@ -133,5 +135,4 @@ class MPU6886 : I2C_Driver end -mpu_accel = MPU6886() -tasmota.add_driver(mpu_accel) +return MPU6886_9250() diff --git a/tasmota/berry/drivers/Shift595.be b/tasmota/berry/drivers/Shift595.be index 3e22f9b33..55082165d 100644 --- a/tasmota/berry/drivers/Shift595.be +++ b/tasmota/berry/drivers/Shift595.be @@ -77,4 +77,4 @@ class Shift595 end -return Shift595 # allow using 'import' instead of 'load()' +return Shift595() # allow using 'import' instead of 'load()' diff --git a/tasmota/berry/lvgl_examples/lv_3_touch_buttons.be b/tasmota/berry/drivers/lv_touch_3_buttons.be similarity index 88% rename from tasmota/berry/lvgl_examples/lv_3_touch_buttons.be rename to tasmota/berry/drivers/lv_touch_3_buttons.be index 354c17313..c33ed0aff 100644 --- a/tasmota/berry/lvgl_examples/lv_3_touch_buttons.be +++ b/tasmota/berry/drivers/lv_touch_3_buttons.be @@ -24,6 +24,10 @@ class lv_touch_3_buttons # Pre-condition: # LVGL must be already started def init(btn1, btn2, btn3, active_low) + import global + if !global.contains("lv") return end # abort if LVGL is not there + lv.start() # make sure LVGL is started, or things can go really wrong + # set current values self.x = 0 self.y = 0 @@ -44,6 +48,9 @@ class lv_touch_3_buttons var vres = lv.get_ver_res() # should be 240 self.x_coords = [ hres / 6, hres / 2, hres * 5 / 6] self.y_coords = [ vres - 10, vres - 10, vres - 10] + + # add self to drivers + tasmota.add_driver(self) end # scan every 50ms @@ -78,9 +85,9 @@ class lv_touch_3_buttons end end -return lv_touch_3_buttons +return lv_touch_3_buttons(gpio.pin(gpio.INPUT, 0), gpio.pin(gpio.INPUT, 1), gpio.pin(gpio.INPUT, 2), true) #- lv_btn3 = lv_touch_3_buttons(gpio.pin(gpio.INPUT, 0), gpio.pin(gpio.INPUT, 1), gpio.pin(gpio.INPUT, 2), lv_touch_3_buttons.ACTIVE_LOW) tasmota.add_driver(lv_btn3) --# \ No newline at end of file +-# diff --git a/tasmota/berry/modules/partition.be b/tasmota/berry/modules/partition.be index b1990ea86..d81a9950d 100644 --- a/tasmota/berry/modules/partition.be +++ b/tasmota/berry/modules/partition.be @@ -532,8 +532,8 @@ class Partition_manager_UI webserver.content_send(string.format("

Used: %i KB

", used / 1024)) webserver.content_send(string.format("

Free: %i KB

", (slot.size - used) / 1024)) else - webserver.content_send("

Used: unknwon

") - webserver.content_send("

Free: unknwon

") + webserver.content_send("

Used: unknown

") + webserver.content_send("

Free: unknown

") end if !active && used > 0 webserver.content_send("

self.action_cb(obj, event), lv.EVENT_CLICKED, 0) end def get_action() - return self._action + var action = self._action + return action ? action : "" # cannot be `nil` as it would mean no member end #==================================================================== @@ -305,7 +308,7 @@ class lvh_obj # print("-> CB fired","self",self,"obj",obj,"event",event.tomap(),"code",event.code) var oh = self._page._oh # openhasp global object var code = event.code # materialize to a local variable, otherwise the value can change (and don't capture event object) - if self.action != nil && code == lv.EVENT_CLICKED + if self.action != "" && code == lv.EVENT_CLICKED # if clicked and action is declared, do the page change event tasmota.set_timer(0, /-> oh.do_action(self, code)) end @@ -1397,11 +1400,11 @@ class OpenHASP # Arg2: LVGL event fired # Returns: nil #==================================================================== - def do_action(lvh_obj, event_code) + def do_action(lvh_object, event_code) if event_code != lv.EVENT_CLICKED return end - var action = lvh_obj._action + var action = lvh_object._action var cur_page = self.lvh_pages[self.lvh_page_cur_idx] - # print("do_action","lvh_obj",lvh_obj,"action",action,"cur_page",cur_page,self.lvh_page_cur_idx) + # print("do_action","lvh_object",lvh_object,"action",action,"cur_page",cur_page,self.lvh_page_cur_idx) # action can be `prev`, `next`, `back`, or `p` like `p1` var to_page = nil diff --git a/tasmota/berry/openhasp_src/openhasp_demo.tapp b/tasmota/berry/openhasp_src/openhasp_demo.tapp index ab08c9e18..b8ca5eb75 100644 Binary files a/tasmota/berry/openhasp_src/openhasp_demo.tapp and b/tasmota/berry/openhasp_src/openhasp_demo.tapp differ diff --git a/tasmota/berry/openhasp_src/openhasp_demo/autoexec.be b/tasmota/berry/openhasp_src/openhasp_demo/autoexec.be index 90fc68d50..0d3a90376 100644 --- a/tasmota/berry/openhasp_src/openhasp_demo/autoexec.be +++ b/tasmota/berry/openhasp_src/openhasp_demo/autoexec.be @@ -39,6 +39,7 @@ end run_watch() def p5_in() + import global global.p0b101.bg_opa = 0 global.p0b102.bg_opa = 0 global.p0b103.bg_opa = 0 @@ -46,6 +47,7 @@ def p5_in() end def p5_out() + import global global.p0b101.bg_opa = 255 global.p0b102.bg_opa = 255 global.p0b103.bg_opa = 255 diff --git a/tasmota/support.ino b/tasmota/support.ino index 75f461fe5..c89c6f237 100644 --- a/tasmota/support.ino +++ b/tasmota/support.ino @@ -1898,14 +1898,17 @@ void SetSerialBegin(void) { SetSerialSwap(); #endif // ESP8266 #ifdef ESP32 +#ifdef ARDUINO_USB_CDC_ON_BOOT +// Serial.end(); +// Serial.begin(); + // Above sequence ends in "Exception":5,"Reason":"Load access fault" + AddLog(LOG_LEVEL_INFO, PSTR(D_LOG_SERIAL "HWCDC supports 115200 bit/s only")); +#else delay(10); // Allow time to cleanup queues - if not used hangs ESP32 Serial.end(); delay(10); // Allow time to cleanup queues - if not used hangs ESP32 -#ifdef ARDUINO_USB_CDC_ON_BOOT - Serial.begin(TasmotaGlobal.baudrate); -#else Serial.begin(TasmotaGlobal.baudrate, ConvertSerialConfig(Settings->serial_config)); -#endif // ARDUINO_USB_CDC_ON_BOOT +#endif // Not ARDUINO_USB_CDC_ON_BOOT #endif // ESP32 } diff --git a/tasmota/tasmota_configurations_ESP32.h b/tasmota/tasmota_configurations_ESP32.h index 59084cc52..c79d7f287 100644 --- a/tasmota/tasmota_configurations_ESP32.h +++ b/tasmota/tasmota_configurations_ESP32.h @@ -99,7 +99,7 @@ #ifdef FIRMWARE_LVGL #undef CODE_IMAGE_STR -#define CODE_IMAGE_STR "lvgl" +#define CODE_IMAGE_STR "lvgl-openhasp" #undef MODULE #define MODULE WEMOS // [Module] Select default module from tasmota_template.h @@ -115,6 +115,7 @@ #define USE_I2S #define USE_SPI #define USE_LVGL +#define USE_LVGL_OPENHASP #define USE_LVGL_FREETYPE #undef SET_ESP32_STACK_SIZE #define SET_ESP32_STACK_SIZE (24 * 1024)