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);
228
228
return true ; \
229
229
}
230
230
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
+
231
239
// allows user to bypass esp_spiram_test()
232
240
bool esp_psram_extram_test (void );
233
241
#define BYPASS_SPIRAM_TEST (bypass ) \
Original file line number Diff line number Diff line change @@ -44,10 +44,18 @@ __attribute__((weak)) bool shouldPrintChipDebugReport(void) {
44
44
return false ;
45
45
}
46
46
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
+
47
52
void loopTask (void *pvParameters) {
48
53
#if !defined(NO_GLOBAL_INSTANCES) && !defined(NO_GLOBAL_SERIAL)
49
54
// sets UART0 (default console) RX/TX pins as already configured in boot or as defined in variants/pins_arduino.h
50
55
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 ());
51
59
#endif
52
60
#if ARDUHAL_LOG_LEVEL >= ARDUHAL_LOG_LEVEL_DEBUG
53
61
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