diff --git a/boards/lilygo-t7-s3.json b/boards/lilygo-t7-s3.json new file mode 100644 index 0000000000..4bf071fc7e --- /dev/null +++ b/boards/lilygo-t7-s3.json @@ -0,0 +1,47 @@ +{ + "build": { + "arduino":{ + "ldscript": "esp32s3_out.ld", + "memory_type": "qio_opi", + "partitions": "default_16MB.csv" + }, + "core": "esp32", + "extra_flags": [ + "-DARDUINO_TTGO_T7_S3", + "-DBOARD_HAS_PSRAM", + "-DARDUINO_USB_MODE=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "qio", + "hwids": [ + [ + "0X303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "esp32s3" + }, + "connectivity": [ + "wifi", + "bluetooth" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "LILYGO T3-S3", + "upload": { + "flash_size": "16MB", + "maximum_ram_size": 327680, + "maximum_size": 16777216, + "require_upload_port": true, + "speed": 921600 + }, + "url": "https://www.aliexpress.us/item/3256804591247074.html", + "vendor": "LILYGO" +} \ No newline at end of file diff --git a/wled00/FX_2Dfcn.cpp b/wled00/FX_2Dfcn.cpp index 56d81443d2..ea5c4307a5 100644 --- a/wled00/FX_2Dfcn.cpp +++ b/wled00/FX_2Dfcn.cpp @@ -351,9 +351,9 @@ void IRAM_ATTR_YN Segment::setPixelColorXY(int x, int y, uint32_t col) //WLEDMM: return; } - const int_fast16_t glen_ = groupLength(); // WLEDMM optimization - const int_fast16_t wid_ = width(); - const int_fast16_t hei_ = height(); + const uint_fast16_t glen_ = groupLength(); // WLEDMM optimization + const uint_fast16_t wid_ = width(); + const uint_fast16_t hei_ = height(); x *= glen_; // expand to physical pixels y *= glen_; // expand to physical pixels diff --git a/wled00/FX_fcn.cpp b/wled00/FX_fcn.cpp index 95e0028ccd..e2250a47e4 100644 --- a/wled00/FX_fcn.cpp +++ b/wled00/FX_fcn.cpp @@ -1413,12 +1413,12 @@ void __attribute__((hot)) Segment::fill(uint32_t c) { if (_bri_t < 255) scaled_col = color_fade(c, _bri_t); } // fill 2D segment - for(int y = 0; y < rows; y++) for (int x = 0; x < cols; x++) { + for(unsigned y = 0; y < rows; y++) for (unsigned x = 0; x < cols; x++) { if (simpleSegment) setPixelColorXY_fast(x, y, c, scaled_col, cols, rows); else setPixelColorXY_slow(x, y, c); } } else { // fill 1D strip - for (int x = 0; x < cols; x++) setPixelColor(x, c); + for (unsigned x = 0; x < cols; x++) setPixelColor(int(x), c); } } @@ -1471,8 +1471,8 @@ void __attribute__((hot)) Segment::fade_out(uint8_t rate) { int g2 = G(color2); int b2 = B(color2); - for (int y = 0; y < rows; y++) for (int x = 0; x < cols; x++) { - uint32_t color = is2D() ? getPixelColorXY(x, y) : getPixelColor(x); + for (unsigned y = 0; y < rows; y++) for (unsigned x = 0; x < cols; x++) { + uint32_t color = is2D() ? getPixelColorXY(int(x), int(y)) : getPixelColor(int(x)); if (color == color2) continue; // WLEDMM speedup - pixel color = target color, so nothing to do int w1 = W(color); int r1 = R(color); @@ -1492,8 +1492,8 @@ void __attribute__((hot)) Segment::fade_out(uint8_t rate) { uint32_t colorNew = RGBW32(r1 + rdelta, g1 + gdelta, b1 + bdelta, w1 + wdelta); // WLEDMM if (colorNew != color) { // WLEDMM speedup - do not repaint the same color - if (is2D()) setPixelColorXY(x, y, colorNew); - else setPixelColor(x, colorNew); + if (is2D()) setPixelColorXY(int(x), int(y), colorNew); + else setPixelColor(int(x), colorNew); } } } @@ -1507,11 +1507,11 @@ void __attribute__((hot)) Segment::fadeToBlackBy(uint8_t fadeBy) { // WLEDMM minor optimization if(is2D()) { - for (int y = 0; y < rows; y++) for (int x = 0; x < cols; x++) { - uint32_t cc = getPixelColorXY(x,y); // WLEDMM avoid RGBW32 -> CRGB -> RGBW32 conversion + for (unsigned y = 0; y < rows; y++) for (unsigned x = 0; x < cols; x++) { + uint32_t cc = getPixelColorXY(int(x),int(y)); // WLEDMM avoid RGBW32 -> CRGB -> RGBW32 conversion uint32_t cc2 = color_fade(cc, scaledown); // fade //if (cc2 != cc) // WLEDMM only re-paint if faded color is different - disabled - causes problem with text overlay - setPixelColorXY((uint16_t)x, (uint16_t)y, cc2); + setPixelColorXY(int(x), int(y), cc2); } } else { for (uint_fast16_t x = 0; x < cols; x++) { diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index b336088196..b7a50cf0ea 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -65,7 +65,7 @@ struct BusConfig { else if (type > 47) nPins = 2; else if (type > 40 && type < 46) nPins = NUM_PWM_PINS(type); else if (type >= TYPE_HUB75MATRIX && type <= (TYPE_HUB75MATRIX + 10)) nPins = 0; - for (uint8_t i = 0; i < nPins; i++) pins[i] = ppins[i]; + for (uint8_t i = 0; i < min(unsigned(nPins),5U); i++) pins[i] = ppins[i]; //softhack007 fix for potential array out-of-bounds access } //validates start and length and extends total if needed @@ -135,21 +135,21 @@ class Bus { virtual void setStatusPixel(uint32_t c) {} virtual void setPixelColor(uint16_t pix, uint32_t c) = 0; virtual uint32_t getPixelColor(uint16_t pix) const { return 0; } - virtual void setBrightness(uint8_t b, bool immediate=false) { _bri = b; }; + virtual void setBrightness(uint8_t b, bool immediate=false) { _bri = b; } virtual void cleanup() = 0; virtual uint8_t getPins(uint8_t* pinArray) const { return 0; } - virtual uint16_t getLength() const { return _len; } + virtual inline uint16_t getLength() const { return _len; } virtual void setColorOrder() {} virtual uint8_t getColorOrder() const { return COL_ORDER_RGB; } - virtual uint8_t skippedLeds() { return 0; } + virtual uint8_t skippedLeds() const { return 0; } virtual uint16_t getFrequency() const { return 0U; } inline uint16_t getStart() const { return _start; } inline void setStart(uint16_t start) { _start = start; } inline uint8_t getType() const { return _type; } inline bool isOk() const { return _valid; } inline bool isOffRefreshRequired() const { return _needsRefresh; } - bool containsPixel(uint16_t pix) const { return pix >= _start && pix < _start+_len; } - virtual uint16_t getMaxPixels() const { return MAX_LEDS_PER_BUS; }; + //inline bool containsPixel(uint16_t pix) const { return pix >= _start && pix < _start+_len; } // WLEDMM not used, plus wrong - it does not consider skipped pixels + virtual uint16_t getMaxPixels() const { return MAX_LEDS_PER_BUS; } virtual bool hasRGB() const { if ((_type >= TYPE_WS2812_1CH && _type <= TYPE_WS2812_WWA) || _type == TYPE_ANALOG_1CH || _type == TYPE_ANALOG_2CH || _type == TYPE_ONOFF) return false; @@ -207,7 +207,7 @@ class BusDigital : public Bus { inline void show(); - bool canShow() const; + bool canShow() override; void setBrightness(uint8_t b, bool immediate); @@ -215,13 +215,13 @@ class BusDigital : public Bus { void setPixelColor(uint16_t pix, uint32_t c); - uint32_t getPixelColor(uint16_t pix) const; + uint32_t getPixelColor(uint16_t pix) const override; uint8_t getColorOrder() const { return _colorOrder; } - uint16_t getLength() const { + uint16_t getLength() const override { return _len - _skip; } @@ -229,11 +229,11 @@ class BusDigital : public Bus { void setColorOrder(uint8_t colorOrder); - uint8_t skippedLeds() const { + uint8_t skippedLeds() const override { return _skip; } - uint16_t getFrequency() const { return _frequencykHz; } + uint16_t getFrequency() const override { return _frequencykHz; } void reinit(); @@ -267,7 +267,7 @@ class BusPwm : public Bus { uint8_t getPins(uint8_t* pinArray) const; - uint16_t getFrequency() const { return _frequency; } + uint16_t getFrequency() const override { return _frequency; } void cleanup() { deallocatePins(); @@ -329,14 +329,14 @@ class BusNetwork : public Bus { void show(); - bool canShow() const { + bool canShow() override { // this should be a return value from UDP routine if it is still sending data out return !_broadcastLock; } uint8_t getPins(uint8_t* pinArray) const; - uint16_t getLength() const { + uint16_t getLength() const override { return _len; } diff --git a/wled00/pin_manager.cpp b/wled00/pin_manager.cpp index d1e7a18b45..b9d90a7dd4 100644 --- a/wled00/pin_manager.cpp +++ b/wled00/pin_manager.cpp @@ -113,13 +113,18 @@ String PinManagerClass::getPinSpecialText(int gpio) { // special purpose PIN in #ifdef ARDUINO_ARCH_ESP32 #if defined(CONFIG_IDF_TARGET_ESP32S3) // ESP32-S3 - if (gpio > 18 && gpio < 21) return (F("USB (CDC) / JTAG")); - #if !defined(BOARD_HAS_PSRAM) - if (gpio > 32 && gpio < 38) return (F("(optional) Octal Flash or PSRAM")); - #else + if (gpio > 18 && gpio < 21) return (F("USB (CDC) or JTAG")); + #if CONFIG_SPIRAM_MODE_OCT && defined(BOARD_HAS_PSRAM) if (gpio > 32 && gpio < 38) return (F("(reserved) Octal PSRAM or Octal Flash")); #endif //if (gpio == 0 || gpio == 3 || gpio == 45 || gpio == 46) return (F("(strapping pin)")); + #ifdef ARDUINO_TTGO_T7_S3 + // experimental: a few special pins of the T7-S3 board + if (gpio == 2) return (F("(reserved) _VBAT voltage monitoring")); + if (gpio == 17) return (F("onboard LED")); + //if (gpio == 3) return (F("(cross-connected to pin 3-1)")); // WLEDMM experimental + //if (gpio == 12) return (F("(cross-connected to pin 12-1)")); // WLEDMM experimental + #endif #elif defined(CONFIG_IDF_TARGET_ESP32S2) // ESP32-S2 @@ -129,7 +134,7 @@ String PinManagerClass::getPinSpecialText(int gpio) { // special purpose PIN in #elif defined(CONFIG_IDF_TARGET_ESP32C3) // ESP32-C3 - if (gpio > 17 && gpio < 20) return (F("USB (CDC) / JTAG")); + if (gpio > 17 && gpio < 20) return (F("USB (CDC) or JTAG")); //if (gpio == 2 || gpio == 8 || gpio == 9) return (F("(strapping pin)")); #else @@ -730,12 +735,18 @@ bool PinManagerClass::isPinOk(byte gpio, bool output) const #if defined(CONFIG_IDF_TARGET_ESP32C3) // strapping pins: 2, 8, & 9 if (gpio > 11 && gpio < 18) return false; // 11-17 SPI FLASH + #if ARDUINO_USB_CDC_ON_BOOT == 1 || ARDUINO_USB_DFU_ON_BOOT == 1 if (gpio > 17 && gpio < 20) return false; // 18-19 USB-JTAG + #endif #elif defined(CONFIG_IDF_TARGET_ESP32S3) // 00 to 18 are for general use. Be careful about straping pins GPIO0 and GPIO3 - these may be pulled-up or pulled-down on your board. + #if ARDUINO_USB_CDC_ON_BOOT == 1 || ARDUINO_USB_DFU_ON_BOOT == 1 if (gpio > 18 && gpio < 21) return false; // 19 + 20 = USB-JTAG. Not recommended for other uses. + #endif if (gpio > 21 && gpio < 33) return false; // 22 to 32: not connected + SPI FLASH - //if (gpio > 32 && gpio < 38) return false; // 33 to 37: not available if using _octal_ SPI Flash or _octal_ PSRAM + // #if CONFIG_SPIRAM_MODE_OCT && defined(BOARD_HAS_PSRAM) + // if (gpio > 32 && gpio < 38) return !psramFound(); // 33 to 37: not available if using _octal_ SPI Flash or _octal_ PSRAM + // #endif // 38 to 48 are for general use. Be careful about straping pins GPIO45 and GPIO46 - these may be pull-up or pulled-down on your board. #elif defined(CONFIG_IDF_TARGET_ESP32S2) // strapping pins: 0, 45 & 46 diff --git a/wled00/wled.cpp b/wled00/wled.cpp index 9d54631f76..52eb569a6d 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -594,9 +594,11 @@ void WLED::setup() #if defined(ARDUINO_ARCH_ESP32) && defined(BOARD_HAS_PSRAM) //psramInit(); //WLEDMM?? softhack007: not sure if explicit init is really needed ... lets disable it here and see if that works #if defined(CONFIG_IDF_TARGET_ESP32S3) - // S3: reserve GPIO 33-37 for "octal" PSRAM - managed_pin_type pins[] = { {33, true}, {34, true}, {35, true}, {36, true}, {37, true} }; - pinManager.allocateMultiplePins(pins, sizeof(pins)/sizeof(managed_pin_type), PinOwner::SPI_RAM); + #if CONFIG_SPIRAM_MODE_OCT && defined(BOARD_HAS_PSRAM) + // S3: reserve GPIO 33-37 for "octal" PSRAM + managed_pin_type pins[] = { {33, true}, {34, true}, {35, true}, {36, true}, {37, true} }; + pinManager.allocateMultiplePins(pins, sizeof(pins)/sizeof(managed_pin_type), PinOwner::SPI_RAM); + #endif #elif defined(CONFIG_IDF_TARGET_ESP32S2) // S2: reserve GPIO 26-32 for PSRAM (may fail due to isPinOk() but that will also prevent other allocation) //managed_pin_type pins[] = { {26, true}, {27, true}, {28, true}, {29, true}, {30, true}, {31, true}, {32, true} }; @@ -815,7 +817,11 @@ void WLED::setup() USER_PRINTLN(F("\nGPIO\t| Assigned to\t\t| Info")); USER_PRINTLN(F("--------|-----------------------|------------")); for(int pinNr = 0; pinNr < WLED_NUM_PINS; pinNr++) { // 49 = highest PIN on ESP32-S3 +#if defined(CONFIG_IDF_TARGET_ESP32S3) + if((pinManager.isPinOk(pinNr, false)) || (pinNr > 18 && pinNr < 21)) { // softhack007: list USB pins +#else if(pinManager.isPinOk(pinNr, false)) { +#endif //if ((!pinManager.isPinAllocated(pinNr)) && (pinManager.getPinSpecialText(pinNr).length() == 0)) continue; // un-comment to hide no-name,unused GPIO pins bool is_inOut = pinManager.isPinOk(pinNr, true); #if 0 // for testing