diff --git a/platformio.ini b/platformio.ini index 37b1267d..4d3dbd4b 100644 --- a/platformio.ini +++ b/platformio.ini @@ -139,7 +139,6 @@ upload_speed = 256000 build_flags = ${env.build_flags} ; -DARDUINO_ARCH_ESP32 ; no proof of necessity yet... - ; -DARDUINO_ARCH_ESP32S3 ; no proof of necessity yet... -DCONFIG_IDF_TARGET_ESP32S2=1 -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_DFU_ON_BOOT=1 -DARDUINO_USB_MSC_ON_BOOT=0 ;; for debugging over USB ; -DARDUINO_USB_CDC_ON_BOOT=0 -DARDUINO_USB_DFU_ON_BOOT=1 -DARDUINO_USB_MSC_ON_BOOT=0 ;; with serial-to-USB moddule (use in case your board hangs without USB connection) @@ -165,7 +164,18 @@ build_flags = ; -D DEBUG=1 -D CORE_DEBUG_LEVEL=1 -D ARDUINOJSON_DEBUG=1 ;; for more debug output - +;; for Waveshare ESP32-S3 Mini/Zero https://www.waveshare.com/esp32-s3-zero.htm +;; --> 4MB Flash, has PSRAM, memory type "qio_qspi", USB-CDC only +[env:esp32_s3_mini] +platform = espressif32@6.3.0 ;; this one behaves better for debugging +board = lolin_s3_mini ;https://github.com/platformio/platform-espressif32/blob/develop/boards/lolin_s3_mini.json +upload_speed = 256000 +build_flags = + ${env.build_flags} + -DCONFIG_IDF_TARGET_ESP32S3=1 + -DARDUINO_USB_CDC_ON_BOOT=1 -DARDUINO_USB_MODE=1 -DARDUINO_USB_DFU_ON_BOOT=0 -DARDUINO_USB_MSC_ON_BOOT=0 ;; for debugging over USB + ; -D DEBUG=1 -D CORE_DEBUG_LEVEL=1 -D ARDUINOJSON_DEBUG=1 ;; for more debug output + ; -DSTARMOD_LOLIN_WIFI_FIX ;; I don't trust the tiny ceramic antenna - use workaround for LOLIN C3/S2/S3 wifi instability. https://www.wemos.cc/en/latest/c3/c3_mini_1_0_0.html#about-wifi diff --git a/src/App/AppModFixtureGen.h b/src/App/AppModFixtureGen.h index 55cfa84b..e3b30f64 100644 --- a/src/App/AppModFixtureGen.h +++ b/src/App/AppModFixtureGen.h @@ -565,10 +565,24 @@ class AppModFixtureGen:public SysModule { default: return false; }}); //fixtureGen - ui->initText(parentVar, "pinList", "16", 32, false, [](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun + // gpio2 seems to be a safe choice on all esp32 variants + ui->initText(parentVar, "pinList", "2", 32, false, [](JsonObject var, uint8_t rowNr, uint8_t funType) { switch (funType) { //varFun case f_UIFun: ui->setComment(var, "One or more e.g. 12,13,14"); return true; +#if 0 // @ewowi did not get this to work + case f_ValueFun: + #if CONFIG_IDF_TARGET_ESP32 && (defined(BOARD_HAS_PSRAM) || defined(ARDUINO_ESP32_PICO)) // + ui->setValue(var, "2"); // gpio16 is reserved on pico and on esp32 with PSRAM + #elif CONFIG_IDF_TARGET_ESP32S3 + ui->setValue(var, "21"); // gpio21 = builtin neopixel on some -S3 boards + #elif CONFIG_IDF_TARGET_ESP32C3 + ui->setValue(var, "10"); // gpio10 = builtin neopixel on some -C3 boards + #else + ui->setValue(var, "16"); // default on universal shield (classic esp32, or esp32-S2) + #endif + return true; +#endif default: return false; }}); diff --git a/src/App/AppModLeds.h b/src/App/AppModLeds.h index 39183bf2..3cda06f2 100644 --- a/src/App/AppModLeds.h +++ b/src/App/AppModLeds.h @@ -468,6 +468,66 @@ class AppModLeds:public SysModule { case 21: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; #endif //CONFIG_IDF_TARGET_ESP32S2 + #if CONFIG_IDF_TARGET_ESP32S3 + case 0: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 1: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 2: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 3: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 4: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 5: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 6: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 7: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 8: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 9: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 10: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 11: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 12: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 13: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 14: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 15: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 16: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 17: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 18: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + #if !ARDUINO_USB_CDC_ON_BOOT + // 19 + 20 = USB-JTAG. Not recommended for other uses. + case 19: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 20: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + #endif + case 21: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + // // 22 to 32: not connected, or SPI FLASH + // case 22: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + // case 23: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + // case 24: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + // case 25: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + // case 26: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + // case 27: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + // case 28: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + // case 29: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + // case 30: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + // case 31: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + // case 32: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + #if !defined(BOARD_HAS_PSRAM) + // 33 to 37: reserved if using _octal_ SPI Flash or _octal_ PSRAM + case 33: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 34: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 35: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 36: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 37: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + #endif + case 38: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 39: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 40: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 41: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 42: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + // 43+44 = Serial RX+TX --> don't use for LEDS when serial-to-USB is needed + case 43: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 44: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 45: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 46: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 47: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + case 48: FastLED.addLeds(fixture.ledsP, startLed, nrOfLeds).setCorrection(TypicalLEDStrip); break; + #endif //CONFIG_IDF_TARGET_ESP32S3 + default: USER_PRINTF("FastLedPin assignment: pin not supported %d\n", pinNr); } } diff --git a/src/Sys/SysModPins.cpp b/src/Sys/SysModPins.cpp index ce02a675..a3d1dc2a 100644 --- a/src/Sys/SysModPins.cpp +++ b/src/Sys/SysModPins.cpp @@ -18,10 +18,13 @@ PinObject SysModPins::pinObjects[NUM_PINS]; bool SysModPins::pinsChanged = false; SysModPins::SysModPins() :SysModule("Pins") { - pinMode(2, OUTPUT); +#if CONFIG_IDF_TARGET_ESP32 + // softhack007: configuring these pins on S3/C3/S2 may cause major problems (crashes included) + // pinMode(2, OUTPUT); // softhack007 default LED pin on some boards, so don't play around with gpio2 pinMode(4, OUTPUT); pinMode(19, OUTPUT); pinMode(33, OUTPUT); +#endif //start with no pins allocated for (int i=0; iinitCheckBox(parentVar, "pin2", true, UINT8_MAX, false, nullptr, updateGPIO); // ui->initCheckBox(parentVar, "pin4"); +#if CONFIG_IDF_TARGET_ESP32 ui->initCheckBox(parentVar, "pin19", true, false, updateGPIO); +#endif // ui->initCheckBox(parentVar, "pin33", true); } @@ -131,10 +136,13 @@ bool SysModPins::updateGPIO(JsonObject var, uint8_t rowNr, uint8_t funType) { sw USER_PRINTF("updateGPIO %s:=%d\n", id.c_str(), pinValue); - if (id == "pin2") digitalWrite(2, pinValue?HIGH:LOW); +#if CONFIG_IDF_TARGET_ESP32 + // softhack007: writing these pins on S3/C3/S2 may cause major problems (crashes included) + // if (id == "pin2") digitalWrite(2, pinValue?HIGH:LOW); // softhack007 default LED pin on some boards, so don't play around with gpio2 if (id == "pin4") digitalWrite(4, pinValue?HIGH:LOW); if (id == "pin19") digitalWrite(19, pinValue?HIGH:LOW); if (id == "pin33") digitalWrite(33, pinValue?HIGH:LOW); +#endif } return true; default: return false; @@ -142,7 +150,7 @@ bool SysModPins::updateGPIO(JsonObject var, uint8_t rowNr, uint8_t funType) { sw void SysModPins::allocatePin(uint8_t pinNr, const char * owner, const char * details) { USER_PRINTF("allocatePin %d %s %s\n", pinNr, owner, details); - if (pinNr < NUM_PINS) { + if ((pinNr < NUM_PINS) && (digitalPinIsValid(pinNr))) { if (strcmp(pinObjects[pinNr].owner, "") != 0 && strcmp(pinObjects[pinNr].owner, owner) != 0) USER_PRINTF("allocatePin %d: not owner %s!=%s", pinNr, owner, pinObjects[pinNr].owner); else { diff --git a/src/Sys/SysModPins.h b/src/Sys/SysModPins.h index 0a617be0..a0702e0a 100644 --- a/src/Sys/SysModPins.h +++ b/src/Sys/SysModPins.h @@ -12,7 +12,7 @@ #pragma once #include "SysModule.h" -#define NUM_PINS 50 +#define NUM_PINS NUM_DIGITAL_PINS // softhack007 NUM_DIGITAL_PINS comes from the arduino framework //info stored per pin struct PinObject {