From 6eaf52f9b0cf288eddbd46cdd217449864b7a435 Mon Sep 17 00:00:00 2001 From: fvanroie Date: Sun, 24 Apr 2022 03:12:09 +0200 Subject: [PATCH] Fix for PWM issue --- src/sys/gpio/hasp_gpio.cpp | 51 ++++++++++--------- src/sys/svc/hasp_http.cpp | 2 +- user_setups/esp32/_esp32.ini | 1 - .../esp32/esp32-dev_ili9488_parallel.ini | 2 +- user_setups/esp32/freetouchdeck.ini | 10 ++-- user_setups/esp32/wt32-sc01.ini | 4 +- user_setups/esp32s2/_esp32s2.ini | 2 +- 7 files changed, 36 insertions(+), 36 deletions(-) diff --git a/src/sys/gpio/hasp_gpio.cpp b/src/sys/gpio/hasp_gpio.cpp index 9ddc6182..dd8e6570 100644 --- a/src/sys/gpio/hasp_gpio.cpp +++ b/src/sys/gpio/hasp_gpio.cpp @@ -48,6 +48,7 @@ static inline void gpio_update_group(uint8_t group, lv_obj_t* obj, bool power, i #if defined(ARDUINO_ARCH_ESP32) #include "driver/uart.h" +#include "driver/ledc.h" #include volatile bool touchdetected = false; @@ -256,9 +257,9 @@ static void gpio_setup_pin(uint8_t index) gpio->power = gpio->inverted; // gpio is off, state is set to reflect the true output state of the gpio gpio->val = gpio->inverted ? 0 : gpio->max; #if defined(ARDUINO_ARCH_ESP32) - if(pwm_channel < 16) { + if(pwm_channel < LEDC_CHANNEL_MAX) { // configure LED PWM functionalitites - ledcSetup(pwm_channel, 20000, 12); + ledcSetup(pwm_channel, 20000, 10); // attach the channel to the GPIO to be controlled ledcAttachPin(gpio->pin, pwm_channel); gpio->channel = pwm_channel++; @@ -445,7 +446,7 @@ static inline int32_t gpio_limit(int32_t val, int32_t min, int32_t max) static inline bool gpio_set_analog_value(hasp_gpio_config_t* gpio) { uint16_t val = 0; -#if defined(ARDUINO_ARCH_ESP32) +#if 0 && defined(ARDUINO_ARCH_ESP32) if(gpio->max == 255) val = SCALE_8BIT_TO_12BIT(gpio->val); @@ -458,7 +459,7 @@ static inline bool gpio_set_analog_value(hasp_gpio_config_t* gpio) ledcWrite(gpio->channel, val); // 12 bits return true; // sent -#elif defined(ARDUINO_ARCH_ESP8266) +#elif defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266) if(gpio->max == 255) val = SCALE_8BIT_TO_10BIT(gpio->val); @@ -777,17 +778,17 @@ bool gpioIsSystemPin(uint8_t gpio) #ifdef TFT_D15 || (gpio == TFT_D15) #endif -//Cant assign the touch pins to the generic GPIO. Maybe in future if sensors are added -#ifdef TOUCH_SDA +// Cant assign the touch pins to the generic GPIO. Maybe in future if sensors are added +#ifdef TOUCH_SDA || (gpio == TOUCH_SDA) #endif -#ifdef TOUCH_SCL +#ifdef TOUCH_SCL || (gpio == TOUCH_SCL) #endif -#ifdef TOUCH_IRQ +#ifdef TOUCH_IRQ || (gpio == TOUCH_IRQ) #endif -#ifdef TOUCH_RST +#ifdef TOUCH_RST || (gpio == TOUCH_RST) #endif @@ -801,24 +802,24 @@ bool gpioIsSystemPin(uint8_t gpio) // Serial GPIOs // Tasmota Client GPIOs -//NG. Remove the checks here since the is_system_pin function does the same check. Best to keep the code in 1 place only. -/* -#ifdef ARDUINO_ARCH_ESP32 - if((gpio >= 6) && (gpio <= 11)) return true; // integrated SPI flash - if((gpio == 37) || (gpio == 38)) return true; // unavailable - if(psramFound()) { - if((gpio == 16) || (gpio == 17)) return true; // PSRAM - } -#endif - -#ifdef ARDUINO_ARCH_ESP8266 - if((gpio >= 6) && (gpio <= 11)) return true; // integrated SPI flash - #ifndef TFT_SPI_OVERLAP - if((gpio >= 12) && (gpio <= 14)) return true; // HSPI + // NG. Remove the checks here since the is_system_pin function does the same check. Best to keep the code in 1 place + // only. + /* + #ifdef ARDUINO_ARCH_ESP32 + if((gpio >= 6) && (gpio <= 11)) return true; // integrated SPI flash + if((gpio == 37) || (gpio == 38)) return true; // unavailable + if(psramFound()) { + if((gpio == 16) || (gpio == 17)) return true; // PSRAM + } #endif -#endif -*/ + #ifdef ARDUINO_ARCH_ESP8266 + if((gpio >= 6) && (gpio <= 11)) return true; // integrated SPI flash + #ifndef TFT_SPI_OVERLAP + if((gpio >= 12) && (gpio <= 14)) return true; // HSPI + #endif + #endif + */ if(haspDevice.is_system_pin(gpio)) return true; diff --git a/src/sys/svc/hasp_http.cpp b/src/sys/svc/hasp_http.cpp index 84d5ac99..a5786dae 100644 --- a/src/sys/svc/hasp_http.cpp +++ b/src/sys/svc/hasp_http.cpp @@ -987,7 +987,7 @@ static void handleFileList() } String path = webServer.arg(F("dir")); - // LOG_TRACE(TAG_HTTP, F("handleFileList: %s"), path.c_str()); + // LOG_TRACE(TAG_HTTP, F("handleFileList: %s"), path.c_str()); path.clear(); #if defined(ARDUINO_ARCH_ESP32) diff --git a/user_setups/esp32/_esp32.ini b/user_setups/esp32/_esp32.ini index 55602e10..606b6a3f 100644 --- a/user_setups/esp32/_esp32.ini +++ b/user_setups/esp32/_esp32.ini @@ -127,7 +127,6 @@ board_build.partitions = user_setups/esp32/partitions_16MB.csv [arduino_esp32_v2] framework = arduino platform = https://github.com/tasmota/platform-espressif32 -platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#2.0.3-RC1 board_build.embed_files = data/edit.htm.gz data/style.css.gz diff --git a/user_setups/esp32/esp32-dev_ili9488_parallel.ini b/user_setups/esp32/esp32-dev_ili9488_parallel.ini index 167a3685..15c1ef23 100644 --- a/user_setups/esp32/esp32-dev_ili9488_parallel.ini +++ b/user_setups/esp32/esp32-dev_ili9488_parallel.ini @@ -6,7 +6,7 @@ ;***************************************************; [env:esp32dev-mrb3511] -extends = esp32_4mb +extends = esp32_4mb_v2 board = esp32dev build_flags = diff --git a/user_setups/esp32/freetouchdeck.ini b/user_setups/esp32/freetouchdeck.ini index 78f832e1..09f7d60b 100644 --- a/user_setups/esp32/freetouchdeck.ini +++ b/user_setups/esp32/freetouchdeck.ini @@ -13,7 +13,7 @@ build_flags = -D HASP_MODEL="FreeTouchDeck" -DBOARD_HAS_PSRAM ; uses 78kB ;-mfix-esp32-psram-cache-issue ; uses 24kB - + ;region -- TFT_eSPI build options ------------------------ -D USER_SETUP_LOADED=1 ;-D LGFX_USE_V1=1 @@ -43,18 +43,18 @@ build_flags = lib_deps = ${env.lib_deps} ${esp32.lib_deps} - ${arduino_esp32_v1.lib_deps} + ${arduino_esp32_v2.lib_deps} ${tft_espi.lib_deps} lib_ignore = ${env.lib_ignore} ${esp32.lib_ignore} - ${arduino_esp32_v1.lib_ignore} + ${arduino_esp32_v2.lib_ignore} ;endregion [env:freetouchdeck_4MB] -extends = freetouchdeck, esp32_4mb +extends = freetouchdeck, esp32_4mb_v2 [env:freetouchdeck_8MB] -extends = freetouchdeck, esp32_8mb +extends = freetouchdeck, esp32_8mb_v2 diff --git a/user_setups/esp32/wt32-sc01.ini b/user_setups/esp32/wt32-sc01.ini index db837c12..9e98b4ce 100644 --- a/user_setups/esp32/wt32-sc01.ini +++ b/user_setups/esp32/wt32-sc01.ini @@ -51,7 +51,7 @@ lib_ignore = ;endregion [env:wt32-sc01_4MB] -extends = wt32-sc01, esp32_4mb +extends = wt32-sc01, esp32s2_4mb_v2 [env:wt32-sc01_16MB] -extends = wt32-sc01, esp32_16mb +extends = wt32-sc01, esp32s2_16mb_v2 diff --git a/user_setups/esp32s2/_esp32s2.ini b/user_setups/esp32s2/_esp32s2.ini index d91b64f1..dab93bc5 100644 --- a/user_setups/esp32s2/_esp32s2.ini +++ b/user_setups/esp32s2/_esp32s2.ini @@ -94,7 +94,7 @@ fspi = ; -- The Arduino ESP32S2 v2.0.2 with 3 available flash sizes: [arduino_esp32s2_v2] framework = arduino -platform = https://github.com/tasmota/platform-espressif32/releases/download/v2.0.3rc1/platform-espressif32-2.0.3.zip +platform = https://github.com/tasmota/platform-espressif32 board_build.embed_files = data/edit.htm.gz data/style.css.gz