Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit a42f4a7

Browse files
Merge pull request #11367 from tanakamasayuki/patch-3
feat(core): Add wait time before setup
2 parents a39d1bd + a77a94b commit a42f4a7

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

‎cores/esp32/Arduino.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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()
232240
bool esp_psram_extram_test(void);
233241
#define BYPASS_SPIRAM_TEST(bypass) \

‎cores/esp32/main.cpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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+
4752
void 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();
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
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() {}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /