File tree Expand file tree Collapse file tree 3 files changed +29
-0
lines changed
libraries/ESP32/examples/ArduinoWaitTimeBeforeStartingSketch Expand file tree Collapse file tree 3 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -228,6 +228,14 @@ bool shouldPrintChipDebugReport(void);
228228 return true ; \
229229 }
230230
231+ // macro SET_TIME_BEFORE_STARTING_SKETCH_MS(time_ms) can set a time in milliseconds
232+ // before the sketch would start its execution. It gives the user time to open the Serial Monitor
233+ uint64_t getArduinoSetupWaitTime_ms (void );
234+ #define SET_TIME_BEFORE_STARTING_SKETCH_MS (time_ms ) \
235+ uint64_t getArduinoSetupWaitTime_ms () { \
236+ return (time_ms); \
237+ }
238+
231239// allows user to bypass esp_spiram_test()
232240bool esp_psram_extram_test (void );
233241#define BYPASS_SPIRAM_TEST (bypass ) \
Original file line number Diff line number Diff line change @@ -44,10 +44,18 @@ __attribute__((weak)) bool shouldPrintChipDebugReport(void) {
4444 return false ;
4545}
4646
47+ // this function can be changed by the sketch using the macro SET_TIME_BEFORE_STARTING_SKETCH_MS(time_ms)
48+ __attribute__ ((weak)) uint64_t getArduinoSetupWaitTime_ms(void ) {
49+ return 0 ;
50+ }
51+
4752void loopTask (void *pvParameters) {
4853#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
4954 // sets UART0 (default console) RX/TX pins as already configured in boot or as defined in variants/pins_arduino.h
5055 Serial0.setPins (gpioNumberToDigitalPin (SOC_RX0), gpioNumberToDigitalPin (SOC_TX0));
56+ // time in ms that the sketch may wait before starting its execution - default is zero
57+ // usually done for opening the Serial Monitor and seeing all debug messages
58+ delay (getArduinoSetupWaitTime_ms ());
5159#endif
5260#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
5361 printBeforeSetupInfo ();
Original file line number Diff line number Diff line change 1+ // macro SET_TIME_BEFORE_STARTING_SKETCH_MS(time_ms) can set a time in milliseconds
2+ // before the sketch would start its execution. It gives the user time to open the Serial Monitor
3+
4+ // This will force the Sketch execution to wait for 5 seconds before starting it execution
5+ // setup() will be executed only after this time
6+ SET_TIME_BEFORE_STARTING_SKETCH_MS (5000 );
7+
8+ void setup () {
9+ Serial.begin (115200 );
10+ Serial.println (" After 5 seconds... this message will be seen in the Serial Monitor." );
11+ }
12+
13+ void loop () {}
You can’t perform that action at this time.
0 commit comments