Add debug logging for setup()
This commit is contained in:
parent
13118dbd8d
commit
b5530775c9
@ -959,48 +959,69 @@ void setup() {
|
||||
// UI must be initialized before EEPROM
|
||||
// (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
|
||||
#if HAS_COLOR_LEDS
|
||||
leds.setup();
|
||||
SETUP_RUN(leds.setup());
|
||||
#endif
|
||||
|
||||
ui.init();
|
||||
SETUP_RUN(ui.init());
|
||||
|
||||
#if HAS_SPI_LCD && ENABLED(SHOW_BOOTSCREEN)
|
||||
ui.show_bootscreen();
|
||||
SETUP_RUN(ui.show_bootscreen());
|
||||
#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)
|
||||
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
|
||||
// Load data from EEPROM if available (or use defaults)
|
||||
settings.first_load(); // This also updates variables in the planner, elsewhere
|
||||
|
||||
#if ENABLED(TOUCH_BUTTONS)
|
||||
touch.init();
|
||||
SETUP_RUN(touch.init());
|
||||
#endif
|
||||
|
||||
#if HAS_M206_COMMAND // Initialize current position based on home_offset
|
||||
current_position += home_offset;
|
||||
#if HAS_M206_COMMAND
|
||||
current_position += home_offset; // Init current position based on home_offset
|
||||
#endif
|
||||
|
||||
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
|
||||
servo_init();
|
||||
SETUP_RUN(servo_init());
|
||||
#endif
|
||||
|
||||
#if HAS_Z_SERVO_PROBE
|
||||
probe.servo_probe_init();
|
||||
SETUP_RUN(probe.servo_probe_init());
|
||||
#endif
|
||||
|
||||
#if HAS_PHOTOGRAPH
|
||||
@ -1008,7 +1029,7 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if HAS_CUTTER
|
||||
cutter.init();
|
||||
SETUP_RUN(cutter.init());
|
||||
#endif
|
||||
|
||||
#if ENABLED(COOLANT_MIST)
|
||||
@ -1019,7 +1040,7 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
endstops.enable_z_probe(false);
|
||||
SETUP_RUN(endstops.enable_z_probe(false));
|
||||
#endif
|
||||
|
||||
#if ENABLED(USE_CONTROLLER_FAN)
|
||||
@ -1027,15 +1048,15 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if HAS_STEPPER_RESET
|
||||
enableStepperDrivers();
|
||||
SETUP_RUN(enableStepperDrivers());
|
||||
#endif
|
||||
|
||||
#if ENABLED(DIGIPOT_I2C)
|
||||
digipot_i2c_init();
|
||||
SETUP_RUN(digipot_i2c_init());
|
||||
#endif
|
||||
|
||||
#if ENABLED(DAC_STEPPER_CURRENT)
|
||||
dac_init();
|
||||
SETUP_RUN(dac_init());
|
||||
#endif
|
||||
|
||||
#if EITHER(Z_PROBE_SLED, SOLENOID_PROBE) && HAS_SOLENOID_1
|
||||
@ -1058,41 +1079,44 @@ void setup() {
|
||||
#if DISABLED(CASE_LIGHT_USE_NEOPIXEL)
|
||||
if (PWM_PIN(CASE_LIGHT_PIN)) SET_PWM(CASE_LIGHT_PIN); else SET_OUTPUT(CASE_LIGHT_PIN);
|
||||
#endif
|
||||
update_case_light();
|
||||
SETUP_RUN(update_case_light());
|
||||
#endif
|
||||
|
||||
#if ENABLED(MK2_MULTIPLEXER)
|
||||
SETUP_LOG("MK2_MULTIPLEXER");
|
||||
SET_OUTPUT(E_MUX0_PIN);
|
||||
SET_OUTPUT(E_MUX1_PIN);
|
||||
SET_OUTPUT(E_MUX2_PIN);
|
||||
#endif
|
||||
|
||||
#if HAS_FANMUX
|
||||
fanmux_init();
|
||||
SETUP_RUN(fanmux_init());
|
||||
#endif
|
||||
|
||||
#if ENABLED(MIXING_EXTRUDER)
|
||||
mixer.init();
|
||||
SETUP_RUN(mixer.init());
|
||||
#endif
|
||||
|
||||
#if ENABLED(BLTOUCH)
|
||||
bltouch.init(/*set_voltage=*/true);
|
||||
SETUP_RUN(bltouch.init(/*set_voltage=*/true));
|
||||
#endif
|
||||
|
||||
#if ENABLED(I2C_POSITION_ENCODERS)
|
||||
I2CPEM.init();
|
||||
SETUP_RUN(I2CPEM.init());
|
||||
#endif
|
||||
|
||||
#if ENABLED(EXPERIMENTAL_I2CBUS) && I2C_SLAVE_ADDRESS > 0
|
||||
SETUP_LOG("i2c...");
|
||||
i2c.onReceive(i2c_on_receive);
|
||||
i2c.onRequest(i2c_on_request);
|
||||
#endif
|
||||
|
||||
#if DO_SWITCH_EXTRUDER
|
||||
move_extruder_servo(0); // Initialize extruder servo
|
||||
SETUP_RUN(move_extruder_servo(0)); // Initialize extruder servo
|
||||
#endif
|
||||
|
||||
#if ENABLED(SWITCHING_NOZZLE)
|
||||
SETUP_LOG("SWITCHING_NOZZLE");
|
||||
// Initialize nozzle servo(s)
|
||||
#if SWITCHING_NOZZLE_TWO_SERVOS
|
||||
lower_nozzle(0);
|
||||
@ -1103,11 +1127,11 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if ENABLED(MAGNETIC_PARKING_EXTRUDER)
|
||||
mpe_settings_init();
|
||||
SETUP_RUN(mpe_settings_init());
|
||||
#endif
|
||||
|
||||
#if ENABLED(PARKING_EXTRUDER)
|
||||
pe_solenoid_init();
|
||||
SETUP_RUN(pe_solenoid_init());
|
||||
#endif
|
||||
|
||||
#if ENABLED(SWITCHING_TOOLHEAD)
|
||||
@ -1115,48 +1139,47 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
|
||||
est_init();
|
||||
SETUP_RUN(est_init());
|
||||
#endif
|
||||
|
||||
#if ENABLED(POWER_LOSS_RECOVERY)
|
||||
recovery.check();
|
||||
SETUP_RUN(recovery.check());
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
|
||||
init_closedloop();
|
||||
SETUP_RUN(init_closedloop());
|
||||
#endif
|
||||
|
||||
#ifdef STARTUP_COMMANDS
|
||||
SETUP_LOG("STARTUP_COMMANDS");
|
||||
queue.inject_P(PSTR(STARTUP_COMMANDS));
|
||||
#endif
|
||||
|
||||
#if ENABLED(INIT_SDCARD_ON_BOOT) && !HAS_SPI_LCD
|
||||
card.beginautostart();
|
||||
SETUP_RUN(card.beginautostart());
|
||||
#endif
|
||||
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT)
|
||||
host_action_prompt_end();
|
||||
SETUP_RUN(host_action_prompt_end());
|
||||
#endif
|
||||
|
||||
#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
|
||||
|
||||
#if ENABLED(PRUSA_MMU2)
|
||||
mmu2.init();
|
||||
#endif
|
||||
|
||||
#if HAS_SERVICE_INTERVALS
|
||||
ui.reset_status(true); // Show service messages or keep current status
|
||||
SETUP_RUN(mmu2.init());
|
||||
#endif
|
||||
|
||||
#if ENABLED(MAX7219_DEBUG)
|
||||
max7219.init();
|
||||
SETUP_RUN(max7219.init());
|
||||
#endif
|
||||
|
||||
SETUP_LOG("setup() completed.");
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user