From 3a3853cfc7f9899e159b03ae224ea78a7defa496 Mon Sep 17 00:00:00 2001 From: TANAKA Masayuki Date: Thu, 15 May 2025 12:23:01 +0900 Subject: [PATCH 01/10] feat(core): Add wait time before setup Added initialization time for UART, etc. Default value is 0. --- cores/esp32/main.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cores/esp32/main.cpp b/cores/esp32/main.cpp index 6c4d50a9a84..9247a4dcb16 100644 --- a/cores/esp32/main.cpp +++ b/cores/esp32/main.cpp @@ -44,10 +44,15 @@ __attribute__((weak)) bool shouldPrintChipDebugReport(void) { return false; } +__attribute__((weak)) uint64_t getArduinoSetupWaitTick(void) { + return 0; +} + void loopTask(void *pvParameters) { #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL) // sets UART0 (default console) RX/TX pins as already configured in boot or as defined in variants/pins_arduino.h Serial0.setPins(gpioNumberToDigitalPin(SOC_RX0), gpioNumberToDigitalPin(SOC_TX0)); + vTaskDelay(getArduinoSetupWaitTick()); #endif #if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG printBeforeSetupInfo(); From eaec282ac4bb63ab8d0fb0166a66f47c81bba9c6 Mon Sep 17 00:00:00 2001 From: TANAKA Masayuki Date: Thu, 15 May 2025 17:41:19 +0900 Subject: [PATCH 02/10] Update Arduino.h Add function definition and SET_SETUP_WAIT_TICH function --- cores/esp32/Arduino.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cores/esp32/Arduino.h b/cores/esp32/Arduino.h index 9048249a873..c95ab23cda6 100644 --- a/cores/esp32/Arduino.h +++ b/cores/esp32/Arduino.h @@ -228,6 +228,12 @@ bool shouldPrintChipDebugReport(void); return true; \ } +uint64_t getArduinoSetupWaitTick(void); +#define SET_SETUP_WAIT_TICH(tick) \ + uint64_t getArduinoSetupWaitTick() { \ + return tick; \ + } + // allows user to bypass esp_spiram_test() bool esp_psram_extram_test(void); #define BYPASS_SPIRAM_TEST(bypass) \ From 756bde2ee5dc45b94ab8ab86d75039d90c65194b Mon Sep 17 00:00:00 2001 From: TANAKA Masayuki Date: Thu, 15 May 2025 18:31:59 +0900 Subject: [PATCH 03/10] Update Arduino.h typo --- cores/esp32/Arduino.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp32/Arduino.h b/cores/esp32/Arduino.h index c95ab23cda6..b3a1be98cb6 100644 --- a/cores/esp32/Arduino.h +++ b/cores/esp32/Arduino.h @@ -229,7 +229,7 @@ bool shouldPrintChipDebugReport(void); } uint64_t getArduinoSetupWaitTick(void); -#define SET_SETUP_WAIT_TICH(tick) \ +#define SET_SETUP_WAIT_TICK(tick) \ uint64_t getArduinoSetupWaitTick() { \ return tick; \ } From 22fba0ce48efcc5b0c6593532d58389730036262 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Sat, 21 Jun 2025 18:39:16 -0300 Subject: [PATCH 04/10] feat(arduino): changing it to use time in ms --- cores/esp32/Arduino.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cores/esp32/Arduino.h b/cores/esp32/Arduino.h index b3a1be98cb6..be59a9734c1 100644 --- a/cores/esp32/Arduino.h +++ b/cores/esp32/Arduino.h @@ -228,10 +228,12 @@ bool shouldPrintChipDebugReport(void); return true; \ } -uint64_t getArduinoSetupWaitTick(void); -#define SET_SETUP_WAIT_TICK(tick) \ - uint64_t getArduinoSetupWaitTick() { \ - return tick; \ +// macro SET_TIME_BEFORE_STARTING_SKETCH_MS(time_ms) can set a time in milliseconds +// before the sketch would start its execution. It gives the user time to open the Serial Monitor +uint64_t getArduinoSetupWaitTime_ms(void); +#define SET_TIME_BEFORE_STARTING_SKETCH_MS(time_ms) \ + uint64_t getArduinoSetupWaitTime_ms() { \ + return time_ms; \ } // allows user to bypass esp_spiram_test() From a258a1e9712ec8072d37b9fe929c656d91741a3f Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Sat, 21 Jun 2025 18:39:52 -0300 Subject: [PATCH 05/10] feat(arduino): changing it to use time in ms --- cores/esp32/main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cores/esp32/main.cpp b/cores/esp32/main.cpp index 9247a4dcb16..ea7fd47dba0 100644 --- a/cores/esp32/main.cpp +++ b/cores/esp32/main.cpp @@ -44,7 +44,8 @@ __attribute__((weak)) bool shouldPrintChipDebugReport(void) { return false; } -__attribute__((weak)) uint64_t getArduinoSetupWaitTick(void) { +// this function can be changed by the skectch using the macro SET_TIME_BEFORE_STARTING_SKETCH_MS(time_ms) +__attribute__((weak)) uint64_t getArduinoSetupWaitTime_ms(void) { return 0; } From 12d7cdec2b31520b423ec8389614eacbaa201c9c Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Sat, 21 Jun 2025 18:40:15 -0300 Subject: [PATCH 06/10] feat(arduino): changing it to use time in ms --- cores/esp32/main.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cores/esp32/main.cpp b/cores/esp32/main.cpp index ea7fd47dba0..5934762a5e5 100644 --- a/cores/esp32/main.cpp +++ b/cores/esp32/main.cpp @@ -53,7 +53,9 @@ void loopTask(void *pvParameters) { #if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL) // sets UART0 (default console) RX/TX pins as already configured in boot or as defined in variants/pins_arduino.h Serial0.setPins(gpioNumberToDigitalPin(SOC_RX0), gpioNumberToDigitalPin(SOC_TX0)); - vTaskDelay(getArduinoSetupWaitTick()); + // time in ms that the sketch may wait before starting its execution - default is zero + // usually done for opening the Serial Monitor and seeing all debug messages + delay(getArduinoSetupWaitTime_ms()); #endif #if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG printBeforeSetupInfo(); From ea28f54fc486b2242b09cff4042753300ff04484 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Sat, 21 Jun 2025 18:46:35 -0300 Subject: [PATCH 07/10] feat(arduino): example for SET_TIME_BEFORE_STARTING_SEKETCH_MS --- .../ArduinoWaitTimeBeforeStartingSketch.ino | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 libraries/ESP32/examples/ArduinoWaitTimeBeforeStartingSketch/ArduinoWaitTimeBeforeStartingSketch.ino diff --git a/libraries/ESP32/examples/ArduinoWaitTimeBeforeStartingSketch/ArduinoWaitTimeBeforeStartingSketch.ino b/libraries/ESP32/examples/ArduinoWaitTimeBeforeStartingSketch/ArduinoWaitTimeBeforeStartingSketch.ino new file mode 100644 index 00000000000..1c57be78cd2 --- /dev/null +++ b/libraries/ESP32/examples/ArduinoWaitTimeBeforeStartingSketch/ArduinoWaitTimeBeforeStartingSketch.ino @@ -0,0 +1,15 @@ +// macro SET_TIME_BEFORE_STARTING_SKETCH_MS(time_ms) can set a time in milliseconds +// before the sketch would start its execution. It gives the user time to open the Serial Monitor + +// This will force the Sketch execution to wait for 5 seconds before starting it execution +// setup() will be execute only after this time +SET_TIME_BEFORE_STARTING_SKETCH_MS(5000); + + +void setup() { + Serial.begin(115200); + Serial.println("After 5 seconds... this message will be seen in the Serial Monitor."); +} + +void loop() { +} From 1f7d4496cae8c8b2a166e5de23863471b6c7e835 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Sat, 21 Jun 2025 18:49:28 -0300 Subject: [PATCH 08/10] feat(arduino): changing it to use time in ms Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- cores/esp32/Arduino.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp32/Arduino.h b/cores/esp32/Arduino.h index be59a9734c1..70021330f35 100644 --- a/cores/esp32/Arduino.h +++ b/cores/esp32/Arduino.h @@ -233,7 +233,7 @@ bool shouldPrintChipDebugReport(void); uint64_t getArduinoSetupWaitTime_ms(void); #define SET_TIME_BEFORE_STARTING_SKETCH_MS(time_ms) \ uint64_t getArduinoSetupWaitTime_ms() { \ - return time_ms; \ + return (time_ms); \ } // allows user to bypass esp_spiram_test() From e8004622701cac16745a158a380aad86deb1f9e1 Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Sat, 21 Jun 2025 18:50:18 -0300 Subject: [PATCH 09/10] fix(arduino): spacing and commentary error Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- cores/esp32/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cores/esp32/main.cpp b/cores/esp32/main.cpp index 5934762a5e5..fb11ff4a5c7 100644 --- a/cores/esp32/main.cpp +++ b/cores/esp32/main.cpp @@ -44,7 +44,7 @@ __attribute__((weak)) bool shouldPrintChipDebugReport(void) { return false; } -// this function can be changed by the skectch using the macro SET_TIME_BEFORE_STARTING_SKETCH_MS(time_ms) +// this function can be changed by the sketch using the macro SET_TIME_BEFORE_STARTING_SKETCH_MS(time_ms) __attribute__((weak)) uint64_t getArduinoSetupWaitTime_ms(void) { return 0; } From 6638ed6d636bb68a6683d61eff8261b2d69968ed Mon Sep 17 00:00:00 2001 From: Sugar Glider Date: Sat, 21 Jun 2025 18:52:38 -0300 Subject: [PATCH 10/10] fix(arduino): spacing and commentary error Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- .../ArduinoWaitTimeBeforeStartingSketch.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/ESP32/examples/ArduinoWaitTimeBeforeStartingSketch/ArduinoWaitTimeBeforeStartingSketch.ino b/libraries/ESP32/examples/ArduinoWaitTimeBeforeStartingSketch/ArduinoWaitTimeBeforeStartingSketch.ino index 1c57be78cd2..550f2675990 100644 --- a/libraries/ESP32/examples/ArduinoWaitTimeBeforeStartingSketch/ArduinoWaitTimeBeforeStartingSketch.ino +++ b/libraries/ESP32/examples/ArduinoWaitTimeBeforeStartingSketch/ArduinoWaitTimeBeforeStartingSketch.ino @@ -2,7 +2,7 @@ // before the sketch would start its execution. It gives the user time to open the Serial Monitor // This will force the Sketch execution to wait for 5 seconds before starting it execution -// setup() will be execute only after this time +// setup() will be executed only after this time SET_TIME_BEFORE_STARTING_SKETCH_MS(5000);