Fix for PWM issue

This commit is contained in:
fvanroie 2022-04-24 03:12:09 +02:00
parent 36194b715d
commit 6eaf52f9b0
7 changed files with 36 additions and 36 deletions

View File

@ -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) #if defined(ARDUINO_ARCH_ESP32)
#include "driver/uart.h" #include "driver/uart.h"
#include "driver/ledc.h"
#include <driver/dac.h> #include <driver/dac.h>
volatile bool touchdetected = false; 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->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; gpio->val = gpio->inverted ? 0 : gpio->max;
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)
if(pwm_channel < 16) { if(pwm_channel < LEDC_CHANNEL_MAX) {
// configure LED PWM functionalitites // configure LED PWM functionalitites
ledcSetup(pwm_channel, 20000, 12); ledcSetup(pwm_channel, 20000, 10);
// attach the channel to the GPIO to be controlled // attach the channel to the GPIO to be controlled
ledcAttachPin(gpio->pin, pwm_channel); ledcAttachPin(gpio->pin, pwm_channel);
gpio->channel = 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) static inline bool gpio_set_analog_value(hasp_gpio_config_t* gpio)
{ {
uint16_t val = 0; uint16_t val = 0;
#if defined(ARDUINO_ARCH_ESP32) #if 0 && defined(ARDUINO_ARCH_ESP32)
if(gpio->max == 255) if(gpio->max == 255)
val = SCALE_8BIT_TO_12BIT(gpio->val); 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 ledcWrite(gpio->channel, val); // 12 bits
return true; // sent return true; // sent
#elif defined(ARDUINO_ARCH_ESP8266) #elif defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_ESP8266)
if(gpio->max == 255) if(gpio->max == 255)
val = SCALE_8BIT_TO_10BIT(gpio->val); val = SCALE_8BIT_TO_10BIT(gpio->val);
@ -777,17 +778,17 @@ bool gpioIsSystemPin(uint8_t gpio)
#ifdef TFT_D15 #ifdef TFT_D15
|| (gpio == TFT_D15) || (gpio == TFT_D15)
#endif #endif
//Cant assign the touch pins to the generic GPIO. Maybe in future if sensors are added // Cant assign the touch pins to the generic GPIO. Maybe in future if sensors are added
#ifdef TOUCH_SDA #ifdef TOUCH_SDA
|| (gpio == TOUCH_SDA) || (gpio == TOUCH_SDA)
#endif #endif
#ifdef TOUCH_SCL #ifdef TOUCH_SCL
|| (gpio == TOUCH_SCL) || (gpio == TOUCH_SCL)
#endif #endif
#ifdef TOUCH_IRQ #ifdef TOUCH_IRQ
|| (gpio == TOUCH_IRQ) || (gpio == TOUCH_IRQ)
#endif #endif
#ifdef TOUCH_RST #ifdef TOUCH_RST
|| (gpio == TOUCH_RST) || (gpio == TOUCH_RST)
#endif #endif
@ -801,24 +802,24 @@ bool gpioIsSystemPin(uint8_t gpio)
// Serial GPIOs // Serial GPIOs
// Tasmota Client 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. // 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 #ifdef ARDUINO_ARCH_ESP32
if((gpio == 37) || (gpio == 38)) return true; // unavailable if((gpio >= 6) && (gpio <= 11)) return true; // integrated SPI flash
if(psramFound()) { if((gpio == 37) || (gpio == 38)) return true; // unavailable
if((gpio == 16) || (gpio == 17)) return true; // PSRAM 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
#endif #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; if(haspDevice.is_system_pin(gpio)) return true;

View File

@ -987,7 +987,7 @@ static void handleFileList()
} }
String path = webServer.arg(F("dir")); 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(); path.clear();
#if defined(ARDUINO_ARCH_ESP32) #if defined(ARDUINO_ARCH_ESP32)

View File

@ -127,7 +127,6 @@ board_build.partitions = user_setups/esp32/partitions_16MB.csv
[arduino_esp32_v2] [arduino_esp32_v2]
framework = arduino framework = arduino
platform = https://github.com/tasmota/platform-espressif32 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 = board_build.embed_files =
data/edit.htm.gz data/edit.htm.gz
data/style.css.gz data/style.css.gz

View File

@ -6,7 +6,7 @@
;***************************************************; ;***************************************************;
[env:esp32dev-mrb3511] [env:esp32dev-mrb3511]
extends = esp32_4mb extends = esp32_4mb_v2
board = esp32dev board = esp32dev
build_flags = build_flags =

View File

@ -13,7 +13,7 @@ build_flags =
-D HASP_MODEL="FreeTouchDeck" -D HASP_MODEL="FreeTouchDeck"
-DBOARD_HAS_PSRAM ; uses 78kB -DBOARD_HAS_PSRAM ; uses 78kB
;-mfix-esp32-psram-cache-issue ; uses 24kB ;-mfix-esp32-psram-cache-issue ; uses 24kB
;region -- TFT_eSPI build options ------------------------ ;region -- TFT_eSPI build options ------------------------
-D USER_SETUP_LOADED=1 -D USER_SETUP_LOADED=1
;-D LGFX_USE_V1=1 ;-D LGFX_USE_V1=1
@ -43,18 +43,18 @@ build_flags =
lib_deps = lib_deps =
${env.lib_deps} ${env.lib_deps}
${esp32.lib_deps} ${esp32.lib_deps}
${arduino_esp32_v1.lib_deps} ${arduino_esp32_v2.lib_deps}
${tft_espi.lib_deps} ${tft_espi.lib_deps}
lib_ignore = lib_ignore =
${env.lib_ignore} ${env.lib_ignore}
${esp32.lib_ignore} ${esp32.lib_ignore}
${arduino_esp32_v1.lib_ignore} ${arduino_esp32_v2.lib_ignore}
;endregion ;endregion
[env:freetouchdeck_4MB] [env:freetouchdeck_4MB]
extends = freetouchdeck, esp32_4mb extends = freetouchdeck, esp32_4mb_v2
[env:freetouchdeck_8MB] [env:freetouchdeck_8MB]
extends = freetouchdeck, esp32_8mb extends = freetouchdeck, esp32_8mb_v2

View File

@ -51,7 +51,7 @@ lib_ignore =
;endregion ;endregion
[env:wt32-sc01_4MB] [env:wt32-sc01_4MB]
extends = wt32-sc01, esp32_4mb extends = wt32-sc01, esp32s2_4mb_v2
[env:wt32-sc01_16MB] [env:wt32-sc01_16MB]
extends = wt32-sc01, esp32_16mb extends = wt32-sc01, esp32s2_16mb_v2

View File

@ -94,7 +94,7 @@ fspi =
; -- The Arduino ESP32S2 v2.0.2 with 3 available flash sizes: ; -- The Arduino ESP32S2 v2.0.2 with 3 available flash sizes:
[arduino_esp32s2_v2] [arduino_esp32s2_v2]
framework = arduino 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 = board_build.embed_files =
data/edit.htm.gz data/edit.htm.gz
data/style.css.gz data/style.css.gz