Add debug logging for setup()

This commit is contained in:
Scott Lahteine 2020-03-07 22:33:38 -06:00
parent 13118dbd8d
commit b5530775c9

View file

@ -959,48 +959,69 @@ void setup() {
// UI must be initialized before EEPROM // UI must be initialized before EEPROM
// (because EEPROM code calls the UI). // (because EEPROM code calls the UI).
#if ENABLED(MARLIN_DEV_MODE)
auto log_current_ms = [&](PGM_P const msg) {
SERIAL_ECHO_START();
SERIAL_CHAR('['); SERIAL_ECHO(millis()); SERIAL_ECHO("] ");
serialprintPGM(msg);
SERIAL_EOL();
};
#define SETUP_LOG(M) log_current_ms(PSTR(M))
#else
#define SETUP_LOG(...) NOOP
#endif
#define SETUP_RUN(C) do{ SETUP_LOG(STRINGIFY(C)); C; }while(0)
// Set up LEDs early // Set up LEDs early
#if HAS_COLOR_LEDS #if HAS_COLOR_LEDS
leds.setup(); SETUP_RUN(leds.setup());
#endif #endif
ui.init(); SETUP_RUN(ui.init());
#if HAS_SPI_LCD && ENABLED(SHOW_BOOTSCREEN) #if HAS_SPI_LCD && ENABLED(SHOW_BOOTSCREEN)
ui.show_bootscreen(); SETUP_RUN(ui.show_bootscreen());
#endif #endif
ui.reset_status(); // Load welcome message early. (Retained if no errors exist.) #if !HAS_SERVICE_INTERVALS
SETUP_RUN(ui.reset_status()); // Load welcome message early. (Retained if no errors exist.)
#endif
#if ENABLED(SDSUPPORT) #if ENABLED(SDSUPPORT)
card.mount(); // Mount the SD card before settings.first_load SETUP_RUN(card.mount()); // Mount the SD card before settings.first_load
#endif
SETUP_RUN(settings.first_load()); // Load data from EEPROM if available (or use defaults)
// This also updates variables in the planner, elsewhere
#if HAS_SERVICE_INTERVALS
SETUP_RUN(ui.reset_status(true)); // Show service messages or keep current status
#endif #endif
// Load data from EEPROM if available (or use defaults)
settings.first_load(); // This also updates variables in the planner, elsewhere
#if ENABLED(TOUCH_BUTTONS) #if ENABLED(TOUCH_BUTTONS)
touch.init(); SETUP_RUN(touch.init());
#endif #endif
#if HAS_M206_COMMAND // Initialize current position based on home_offset #if HAS_M206_COMMAND
current_position += home_offset; current_position += home_offset; // Init current position based on home_offset
#endif #endif
sync_plan_position(); // Vital to init stepper/planner equivalent for current_position sync_plan_position(); // Vital to init stepper/planner equivalent for current_position
thermalManager.init(); // Initialize temperature loop SETUP_RUN(thermalManager.init()); // Initialize temperature loop
print_job_timer.init(); // Initial setup of print job timer SETUP_RUN(print_job_timer.init()); // Initial setup of print job timer
endstops.init(); // Init endstops and pullups SETUP_RUN(endstops.init()); // Init endstops and pullups
stepper.init(); // Init stepper. This enables interrupts! SETUP_RUN(stepper.init()); // Init stepper. This enables interrupts!
#if HAS_SERVOS #if HAS_SERVOS
servo_init(); SETUP_RUN(servo_init());
#endif #endif
#if HAS_Z_SERVO_PROBE #if HAS_Z_SERVO_PROBE
probe.servo_probe_init(); SETUP_RUN(probe.servo_probe_init());
#endif #endif
#if HAS_PHOTOGRAPH #if HAS_PHOTOGRAPH
@ -1008,7 +1029,7 @@ void setup() {
#endif #endif
#if HAS_CUTTER #if HAS_CUTTER
cutter.init(); SETUP_RUN(cutter.init());
#endif #endif
#if ENABLED(COOLANT_MIST) #if ENABLED(COOLANT_MIST)
@ -1019,7 +1040,7 @@ void setup() {
#endif #endif
#if HAS_BED_PROBE #if HAS_BED_PROBE
endstops.enable_z_probe(false); SETUP_RUN(endstops.enable_z_probe(false));
#endif #endif
#if ENABLED(USE_CONTROLLER_FAN) #if ENABLED(USE_CONTROLLER_FAN)
@ -1027,15 +1048,15 @@ void setup() {
#endif #endif
#if HAS_STEPPER_RESET #if HAS_STEPPER_RESET
enableStepperDrivers(); SETUP_RUN(enableStepperDrivers());
#endif #endif
#if ENABLED(DIGIPOT_I2C) #if ENABLED(DIGIPOT_I2C)
digipot_i2c_init(); SETUP_RUN(digipot_i2c_init());
#endif #endif
#if ENABLED(DAC_STEPPER_CURRENT) #if ENABLED(DAC_STEPPER_CURRENT)
dac_init(); SETUP_RUN(dac_init());
#endif #endif
#if EITHER(Z_PROBE_SLED, SOLENOID_PROBE) && HAS_SOLENOID_1 #if EITHER(Z_PROBE_SLED, SOLENOID_PROBE) && HAS_SOLENOID_1
@ -1058,41 +1079,44 @@ void setup() {
#if DISABLED(CASE_LIGHT_USE_NEOPIXEL) #if DISABLED(CASE_LIGHT_USE_NEOPIXEL)
if (PWM_PIN(CASE_LIGHT_PIN)) SET_PWM(CASE_LIGHT_PIN); else SET_OUTPUT(CASE_LIGHT_PIN); if (PWM_PIN(CASE_LIGHT_PIN)) SET_PWM(CASE_LIGHT_PIN); else SET_OUTPUT(CASE_LIGHT_PIN);
#endif #endif
update_case_light(); SETUP_RUN(update_case_light());
#endif #endif
#if ENABLED(MK2_MULTIPLEXER) #if ENABLED(MK2_MULTIPLEXER)
SETUP_LOG("MK2_MULTIPLEXER");
SET_OUTPUT(E_MUX0_PIN); SET_OUTPUT(E_MUX0_PIN);
SET_OUTPUT(E_MUX1_PIN); SET_OUTPUT(E_MUX1_PIN);
SET_OUTPUT(E_MUX2_PIN); SET_OUTPUT(E_MUX2_PIN);
#endif #endif
#if HAS_FANMUX #if HAS_FANMUX
fanmux_init(); SETUP_RUN(fanmux_init());
#endif #endif
#if ENABLED(MIXING_EXTRUDER) #if ENABLED(MIXING_EXTRUDER)
mixer.init(); SETUP_RUN(mixer.init());
#endif #endif
#if ENABLED(BLTOUCH) #if ENABLED(BLTOUCH)
bltouch.init(/*set_voltage=*/true); SETUP_RUN(bltouch.init(/*set_voltage=*/true));
#endif #endif
#if ENABLED(I2C_POSITION_ENCODERS) #if ENABLED(I2C_POSITION_ENCODERS)
I2CPEM.init(); SETUP_RUN(I2CPEM.init());
#endif #endif
#if ENABLED(EXPERIMENTAL_I2CBUS) && I2C_SLAVE_ADDRESS > 0 #if ENABLED(EXPERIMENTAL_I2CBUS) && I2C_SLAVE_ADDRESS > 0
SETUP_LOG("i2c...");
i2c.onReceive(i2c_on_receive); i2c.onReceive(i2c_on_receive);
i2c.onRequest(i2c_on_request); i2c.onRequest(i2c_on_request);
#endif #endif
#if DO_SWITCH_EXTRUDER #if DO_SWITCH_EXTRUDER
move_extruder_servo(0); // Initialize extruder servo SETUP_RUN(move_extruder_servo(0)); // Initialize extruder servo
#endif #endif
#if ENABLED(SWITCHING_NOZZLE) #if ENABLED(SWITCHING_NOZZLE)
SETUP_LOG("SWITCHING_NOZZLE");
// Initialize nozzle servo(s) // Initialize nozzle servo(s)
#if SWITCHING_NOZZLE_TWO_SERVOS #if SWITCHING_NOZZLE_TWO_SERVOS
lower_nozzle(0); lower_nozzle(0);
@ -1103,11 +1127,11 @@ void setup() {
#endif #endif
#if ENABLED(MAGNETIC_PARKING_EXTRUDER) #if ENABLED(MAGNETIC_PARKING_EXTRUDER)
mpe_settings_init(); SETUP_RUN(mpe_settings_init());
#endif #endif
#if ENABLED(PARKING_EXTRUDER) #if ENABLED(PARKING_EXTRUDER)
pe_solenoid_init(); SETUP_RUN(pe_solenoid_init());
#endif #endif
#if ENABLED(SWITCHING_TOOLHEAD) #if ENABLED(SWITCHING_TOOLHEAD)
@ -1115,48 +1139,47 @@ void setup() {
#endif #endif
#if ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD) #if ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
est_init(); SETUP_RUN(est_init());
#endif #endif
#if ENABLED(POWER_LOSS_RECOVERY) #if ENABLED(POWER_LOSS_RECOVERY)
recovery.check(); SETUP_RUN(recovery.check());
#endif #endif
#if ENABLED(USE_WATCHDOG) #if ENABLED(USE_WATCHDOG)
watchdog_init(); // Reinit watchdog after HAL_get_reset_source call SETUP_RUN(watchdog_init()); // Reinit watchdog after HAL_get_reset_source call
#endif #endif
#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER) #if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
init_closedloop(); SETUP_RUN(init_closedloop());
#endif #endif
#ifdef STARTUP_COMMANDS #ifdef STARTUP_COMMANDS
SETUP_LOG("STARTUP_COMMANDS");
queue.inject_P(PSTR(STARTUP_COMMANDS)); queue.inject_P(PSTR(STARTUP_COMMANDS));
#endif #endif
#if ENABLED(INIT_SDCARD_ON_BOOT) && !HAS_SPI_LCD #if ENABLED(INIT_SDCARD_ON_BOOT) && !HAS_SPI_LCD
card.beginautostart(); SETUP_RUN(card.beginautostart());
#endif #endif
#if ENABLED(HOST_PROMPT_SUPPORT) #if ENABLED(HOST_PROMPT_SUPPORT)
host_action_prompt_end(); SETUP_RUN(host_action_prompt_end());
#endif #endif
#if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF) #if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF)
test_tmc_connection(true, true, true, true); SETUP_RUN(test_tmc_connection(true, true, true, true));
#endif #endif
#if ENABLED(PRUSA_MMU2) #if ENABLED(PRUSA_MMU2)
mmu2.init(); SETUP_RUN(mmu2.init());
#endif
#if HAS_SERVICE_INTERVALS
ui.reset_status(true); // Show service messages or keep current status
#endif #endif
#if ENABLED(MAX7219_DEBUG) #if ENABLED(MAX7219_DEBUG)
max7219.init(); SETUP_RUN(max7219.init());
#endif #endif
SETUP_LOG("setup() completed.");
} }
/** /**