Merge upstream changes from Marlin 2.1.1
This commit is contained in:
@@ -39,17 +39,13 @@
|
||||
#endif
|
||||
#include <math.h>
|
||||
|
||||
#include "core/utility.h"
|
||||
|
||||
#include "module/endstops.h"
|
||||
#include "module/motion.h"
|
||||
#include "module/planner.h"
|
||||
#include "module/endstops.h"
|
||||
#include "module/temperature.h"
|
||||
#include "module/settings.h"
|
||||
#include "module/printcounter.h" // PrintCounter or Stopwatch
|
||||
|
||||
#include "module/settings.h"
|
||||
#include "module/stepper.h"
|
||||
#include "module/stepper/indirection.h"
|
||||
#include "module/temperature.h"
|
||||
|
||||
#include "gcode/gcode.h"
|
||||
#include "gcode/parser.h"
|
||||
@@ -74,8 +70,8 @@
|
||||
#include "lcd/e3v2/common/encoder.h"
|
||||
#if ENABLED(DWIN_CREALITY_LCD)
|
||||
#include "lcd/e3v2/creality/dwin.h"
|
||||
#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
|
||||
#include "lcd/e3v2/enhanced/dwin.h"
|
||||
#elif ENABLED(DWIN_LCD_PROUI)
|
||||
#include "lcd/e3v2/proui/dwin.h"
|
||||
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
|
||||
#include "lcd/e3v2/jyersui/dwin.h"
|
||||
#endif
|
||||
@@ -97,7 +93,7 @@
|
||||
#include "feature/host_actions.h"
|
||||
#endif
|
||||
|
||||
#if USE_BEEPER
|
||||
#if HAS_BEEPER
|
||||
#include "libs/buzzer.h"
|
||||
#endif
|
||||
|
||||
@@ -125,6 +121,10 @@
|
||||
#include "feature/bltouch.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(BD_SENSOR)
|
||||
#include "feature/bedlevel/bdl/bdl.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(POLL_JOG)
|
||||
#include "feature/joystick.h"
|
||||
#endif
|
||||
@@ -145,7 +145,7 @@
|
||||
#include "feature/encoder_i2c.h"
|
||||
#endif
|
||||
|
||||
#if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF)
|
||||
#if (HAS_TRINAMIC_CONFIG || HAS_TMC_SPI) && DISABLED(PSU_DEFAULT_OFF)
|
||||
#include "feature/tmc_util.h"
|
||||
#endif
|
||||
|
||||
@@ -212,16 +212,20 @@
|
||||
|
||||
#include "module/tool_change.h"
|
||||
|
||||
#if HAS_FANCHECK
|
||||
#include "feature/fancheck.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(USE_CONTROLLER_FAN)
|
||||
#include "feature/controllerfan.h"
|
||||
#endif
|
||||
|
||||
#if HAS_PRUSA_MMU2
|
||||
#include "feature/mmu/mmu2.h"
|
||||
#if HAS_PRUSA_MMU1
|
||||
#include "feature/mmu/mmu.h"
|
||||
#endif
|
||||
|
||||
#if HAS_L64XX
|
||||
#include "libs/L64XX/L64XX_Marlin.h"
|
||||
#if HAS_PRUSA_MMU2
|
||||
#include "feature/mmu/mmu2.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(PASSWORD_FEATURE)
|
||||
@@ -240,6 +244,14 @@
|
||||
#include "feature/power.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(EASYTHREED_UI)
|
||||
#include "feature/easythreed_ui.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(MARLIN_TEST_BUILD)
|
||||
#include "tests/marlin_tests.h"
|
||||
#endif
|
||||
|
||||
// PATCH START: Knutwurst
|
||||
#if ENABLED(ANYCUBIC_TOUCHSCREEN)
|
||||
#include "lcd/anycubic_touchscreen.h"
|
||||
@@ -265,6 +277,7 @@ bool wait_for_heatup = true;
|
||||
while (wait_for_user && !(ms && ELAPSED(millis(), ms)))
|
||||
idle(TERN_(ADVANCED_PAUSE_FEATURE, no_sleep));
|
||||
wait_for_user = false;
|
||||
while (ui.button_pressed()) safe_delay(50);
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -314,6 +327,10 @@ bool pin_is_protected(const pin_t pin) {
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
bool printer_busy() {
|
||||
return planner.movesplanned() || printingIsActive();
|
||||
}
|
||||
|
||||
/**
|
||||
* A Print Job exists when the timer is running or SD is printing
|
||||
*/
|
||||
@@ -363,15 +380,15 @@ void startOrResumeJob() {
|
||||
TERN_(POWER_LOSS_RECOVERY, recovery.purge());
|
||||
|
||||
#ifdef EVENT_GCODE_SD_ABORT
|
||||
queue.inject_P(PSTR(EVENT_GCODE_SD_ABORT));
|
||||
queue.inject(F(EVENT_GCODE_SD_ABORT));
|
||||
#endif
|
||||
|
||||
TERN_(PASSWORD_AFTER_SD_PRINT_ABORT, password.lock_machine());
|
||||
}
|
||||
|
||||
inline void finishSDPrinting() {
|
||||
if (queue.enqueue_one_P(PSTR("M1001"))) { // Keep trying until it gets queued
|
||||
marlin_state = MF_RUNNING; // Signal to stop trying
|
||||
if (queue.enqueue_one(F("M1001"))) { // Keep trying until it gets queued
|
||||
marlin_state = MF_RUNNING; // Signal to stop trying
|
||||
TERN_(PASSWORD_AFTER_SD_PRINT_END, password.lock_machine());
|
||||
TERN_(DGUS_LCD_UI_MKS, ScreenHandler.SDPrintingFinished());
|
||||
}
|
||||
@@ -494,38 +511,44 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
||||
if (do_reset_timeout) gcode.reset_stepper_timeout(ms);
|
||||
|
||||
if (gcode.stepper_max_timed_out(ms)) {
|
||||
SERIAL_ERROR_MSG(STR_KILL_INACTIVE_TIME, parser.command_ptr);
|
||||
SERIAL_ERROR_START();
|
||||
SERIAL_ECHOPGM(STR_KILL_PRE);
|
||||
SERIAL_ECHOLNPGM(STR_KILL_INACTIVE_TIME, parser.command_ptr);
|
||||
kill();
|
||||
}
|
||||
|
||||
const bool has_blocks = planner.has_blocks_queued(); // Any moves in the planner?
|
||||
if (has_blocks) gcode.reset_stepper_timeout(ms); // Reset timeout for M18/M84, M85 max 'kill', and laser.
|
||||
|
||||
// M18 / M84 : Handle steppers inactive time timeout
|
||||
if (gcode.stepper_inactive_time) {
|
||||
#if HAS_DISABLE_INACTIVE_AXIS
|
||||
if (gcode.stepper_inactive_time) {
|
||||
|
||||
static bool already_shutdown_steppers; // = false
|
||||
static bool already_shutdown_steppers; // = false
|
||||
|
||||
// Any moves in the planner? Resets both the M18/M84
|
||||
// activity timeout and the M85 max 'kill' timeout
|
||||
if (planner.has_blocks_queued())
|
||||
gcode.reset_stepper_timeout(ms);
|
||||
else if (!do_reset_timeout && gcode.stepper_inactive_timeout()) {
|
||||
if (!already_shutdown_steppers) {
|
||||
already_shutdown_steppers = true; // L6470 SPI will consume 99% of free time without this
|
||||
if (!has_blocks && !do_reset_timeout && gcode.stepper_inactive_timeout()) {
|
||||
if (!already_shutdown_steppers) {
|
||||
already_shutdown_steppers = true;
|
||||
|
||||
// Individual axes will be disabled if configured
|
||||
TERN_(DISABLE_INACTIVE_X, stepper.disable_axis(X_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_Y, stepper.disable_axis(Y_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_Z, stepper.disable_axis(Z_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_I, stepper.disable_axis(I_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_J, stepper.disable_axis(J_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_K, stepper.disable_axis(K_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_E, stepper.disable_e_steppers());
|
||||
// Individual axes will be disabled if configured
|
||||
TERN_(DISABLE_INACTIVE_X, stepper.disable_axis(X_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_Y, stepper.disable_axis(Y_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_Z, stepper.disable_axis(Z_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_I, stepper.disable_axis(I_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_J, stepper.disable_axis(J_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_K, stepper.disable_axis(K_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_U, stepper.disable_axis(U_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_V, stepper.disable_axis(V_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_W, stepper.disable_axis(W_AXIS));
|
||||
TERN_(DISABLE_INACTIVE_E, stepper.disable_e_steppers());
|
||||
|
||||
TERN_(AUTO_BED_LEVELING_UBL, ubl.steppers_were_disabled());
|
||||
TERN_(AUTO_BED_LEVELING_UBL, bedlevel.steppers_were_disabled());
|
||||
}
|
||||
}
|
||||
else
|
||||
already_shutdown_steppers = false;
|
||||
}
|
||||
else
|
||||
already_shutdown_steppers = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if ENABLED(PHOTO_GCODE) && PIN_EXISTS(CHDK)
|
||||
// Check if CHDK should be set to LOW (after M240 set it HIGH)
|
||||
@@ -552,13 +575,15 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
||||
// KILL the machine
|
||||
// ----------------------------------------------------------------
|
||||
if (killCount >= KILL_DELAY) {
|
||||
SERIAL_ERROR_MSG(STR_KILL_BUTTON);
|
||||
SERIAL_ERROR_START();
|
||||
SERIAL_ECHOPGM(STR_KILL_PRE);
|
||||
SERIAL_ECHOLNPGM(STR_KILL_BUTTON);
|
||||
kill();
|
||||
}
|
||||
#endif
|
||||
|
||||
#if HAS_FREEZE_PIN
|
||||
Stepper::frozen = !READ(FREEZE_PIN);
|
||||
stepper.frozen = READ(FREEZE_PIN) == FREEZE_STATE;
|
||||
#endif
|
||||
|
||||
#if HAS_HOME
|
||||
@@ -568,7 +593,7 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
||||
if (!IS_SD_PRINTING() && !READ(HOME_PIN)) { // HOME_PIN goes LOW when pressed
|
||||
if (ELAPSED(ms, next_home_key_ms)) {
|
||||
next_home_key_ms = ms + HOME_DEBOUNCE_DELAY;
|
||||
LCD_MESSAGEPGM(MSG_AUTO_HOME);
|
||||
LCD_MESSAGE(MSG_AUTO_HOME);
|
||||
queue.inject_P(G28_STR);
|
||||
}
|
||||
}
|
||||
@@ -587,14 +612,14 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
||||
if (ELAPSED(ms, next_cub_ms_##N)) { \
|
||||
next_cub_ms_##N = ms + CUB_DEBOUNCE_DELAY_##N; \
|
||||
CODE; \
|
||||
queue.inject_P(PSTR(BUTTON##N##_GCODE)); \
|
||||
TERN_(HAS_LCD_MENU, ui.quick_feedback()); \
|
||||
queue.inject(F(BUTTON##N##_GCODE)); \
|
||||
TERN_(HAS_MARLINUI_MENU, ui.quick_feedback()); \
|
||||
} \
|
||||
} \
|
||||
}while(0)
|
||||
|
||||
#define CHECK_CUSTOM_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, NOOP)
|
||||
#define CHECK_BETTER_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, if (strlen(BUTTON##N##_DESC)) LCD_MESSAGEPGM_P(PSTR(BUTTON##N##_DESC)))
|
||||
#define CHECK_CUSTOM_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, NOOP)
|
||||
#define CHECK_BETTER_USER_BUTTON(N) _CHECK_CUSTOM_USER_BUTTON(N, if (strlen(BUTTON##N##_DESC)) LCD_MESSAGE_F(BUTTON##N##_DESC))
|
||||
|
||||
#if HAS_BETTER_USER_BUTTON(1)
|
||||
CHECK_BETTER_USER_BUTTON(1);
|
||||
@@ -723,6 +748,8 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
TERN_(EASYTHREED_UI, easythreed_ui.run());
|
||||
|
||||
TERN_(USE_CONTROLLER_FAN, controllerFan.update()); // Check if fan should be turned on to cool stepper drivers down
|
||||
|
||||
TERN_(AUTO_POWER_CONTROL, powerManager.check(!ui.on_status_screen() || printJobOngoing() || printingIsPaused()));
|
||||
@@ -800,8 +827,6 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
||||
|
||||
TERN_(MONITOR_DRIVER_STATUS, monitor_tmc_drivers());
|
||||
|
||||
TERN_(MONITOR_L6470_DRIVER_STATUS, L64xxManager.monitor_driver());
|
||||
|
||||
// Limit check_axes_activity frequency to 10Hz
|
||||
static millis_t next_check_axes_ms = 0;
|
||||
if (ELAPSED(ms, next_check_axes_ms)) {
|
||||
@@ -843,16 +868,23 @@ inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
||||
* - Handle Joystick jogging
|
||||
*/
|
||||
void idle(bool no_stepper_sleep/*=false*/) {
|
||||
#ifdef MAX7219_DEBUG_PROFILE
|
||||
CodeProfiler idle_profiler;
|
||||
#endif
|
||||
|
||||
#if ENABLED(MARLIN_DEV_MODE)
|
||||
static uint16_t idle_depth = 0;
|
||||
if (++idle_depth > 5) SERIAL_ECHOLNPGM("idle() call depth: ", idle_depth);
|
||||
#endif
|
||||
|
||||
// Bed Distance Sensor task
|
||||
TERN_(BD_SENSOR, bdl.process());
|
||||
|
||||
// Core Marlin activities
|
||||
manage_inactivity(no_stepper_sleep);
|
||||
|
||||
// Manage Heaters (and Watchdog)
|
||||
thermalManager.manage_heater();
|
||||
thermalManager.task();
|
||||
|
||||
// Max7219 heartbeat, animation, etc
|
||||
TERN_(MAX7219_DEBUG, max7219.idle_tasks());
|
||||
@@ -874,10 +906,13 @@ void idle(bool no_stepper_sleep/*=false*/) {
|
||||
(void)check_tool_sensor_stats(active_extruder, true);
|
||||
|
||||
// Handle filament runout sensors
|
||||
TERN_(HAS_FILAMENT_SENSOR, runout.run());
|
||||
#if HAS_FILAMENT_SENSOR
|
||||
if (TERN1(HAS_PRUSA_MMU2, !mmu2.enabled()))
|
||||
runout.run();
|
||||
#endif
|
||||
|
||||
// Run HAL idle tasks
|
||||
TERN_(HAL_IDLETASK, HAL_idletask());
|
||||
hal.idletask();
|
||||
|
||||
// Check network connection
|
||||
TERN_(HAS_ETHERNET, ethernet.check());
|
||||
@@ -906,10 +941,10 @@ void idle(bool no_stepper_sleep/*=false*/) {
|
||||
TERN_(PRINTCOUNTER, print_job_timer.tick());
|
||||
|
||||
// Update the Beeper queue
|
||||
TERN_(USE_BEEPER, buzzer.tick());
|
||||
TERN_(HAS_BEEPER, buzzer.tick());
|
||||
|
||||
// Handle UI input / draw events
|
||||
TERN(HAS_DWIN_E3V2_BASIC, DWIN_Update(), ui.update());
|
||||
TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update());
|
||||
|
||||
// Run i2c Position Encoders
|
||||
#if ENABLED(I2C_POSITION_ENCODERS)
|
||||
@@ -929,6 +964,7 @@ void idle(bool no_stepper_sleep/*=false*/) {
|
||||
#if HAS_AUTO_REPORTING
|
||||
if (!gcode.autoreport_paused) {
|
||||
TERN_(AUTO_REPORT_TEMPERATURES, thermalManager.auto_reporter.tick());
|
||||
TERN_(AUTO_REPORT_FANS, fan_check.auto_reporter.tick());
|
||||
TERN_(AUTO_REPORT_SD_STATUS, card.auto_reporter.tick());
|
||||
TERN_(AUTO_REPORT_POSITION, position_auto_reporter.tick());
|
||||
TERN_(BUFFER_MONITORING, queue.auto_report_buffer_statistics());
|
||||
@@ -956,16 +992,16 @@ void idle(bool no_stepper_sleep/*=false*/) {
|
||||
* Kill all activity and lock the machine.
|
||||
* After this the machine will need to be reset.
|
||||
*/
|
||||
void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) {
|
||||
void kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) {
|
||||
thermalManager.disable_all_heaters();
|
||||
|
||||
TERN_(HAS_CUTTER, cutter.kill()); // Full cutter shutdown including ISR control
|
||||
|
||||
// Echo the LCD message to serial for extra context
|
||||
if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLNPGM_P(lcd_error); }
|
||||
if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLNF(lcd_error); }
|
||||
|
||||
#if EITHER(HAS_DISPLAY, DWIN_CREALITY_LCD_ENHANCED)
|
||||
ui.kill_screen(lcd_error ?: GET_TEXT(MSG_KILLED), lcd_component ?: NUL_STR);
|
||||
#if HAS_DISPLAY
|
||||
ui.kill_screen(lcd_error ?: GET_TEXT_F(MSG_KILLED), lcd_component ?: FPSTR(NUL_STR));
|
||||
#else
|
||||
UNUSED(lcd_error); UNUSED(lcd_component);
|
||||
#endif
|
||||
@@ -982,7 +1018,7 @@ void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr
|
||||
// PATCH END: Knutwurst
|
||||
|
||||
#ifdef ACTION_ON_KILL
|
||||
host_action_kill();
|
||||
hostui.kill();
|
||||
#endif
|
||||
|
||||
minkill(steppers_off);
|
||||
@@ -1014,18 +1050,18 @@ void minkill(const bool steppers_off/*=false*/) {
|
||||
|
||||
// Wait for both KILL and ENC to be released
|
||||
while (TERN0(HAS_KILL, kill_state()) || TERN0(SOFT_RESET_ON_KILL, ui.button_pressed()))
|
||||
watchdog_refresh();
|
||||
hal.watchdog_refresh();
|
||||
|
||||
// Wait for either KILL or ENC to be pressed again
|
||||
while (TERN1(HAS_KILL, !kill_state()) && TERN1(SOFT_RESET_ON_KILL, !ui.button_pressed()))
|
||||
watchdog_refresh();
|
||||
hal.watchdog_refresh();
|
||||
|
||||
// Reboot the board
|
||||
HAL_reboot();
|
||||
hal.reboot();
|
||||
|
||||
#else
|
||||
|
||||
for (;;) watchdog_refresh(); // Wait for RESET button or power-cycle
|
||||
for (;;) hal.watchdog_refresh(); // Wait for RESET button or power-cycle
|
||||
|
||||
#endif
|
||||
}
|
||||
@@ -1045,7 +1081,7 @@ void stop() {
|
||||
|
||||
if (!IsStopped()) {
|
||||
SERIAL_ERROR_MSG(STR_ERR_STOPPED);
|
||||
LCD_MESSAGEPGM(MSG_STOPPED);
|
||||
LCD_MESSAGE(MSG_STOPPED);
|
||||
safe_delay(350); // allow enough time for messages to get out before stopping
|
||||
marlin_state = MF_STOPPED;
|
||||
}
|
||||
@@ -1085,6 +1121,15 @@ inline void tmc_standby_setup() {
|
||||
#if PIN_EXISTS(K_STDBY)
|
||||
SET_INPUT_PULLDOWN(K_STDBY_PIN);
|
||||
#endif
|
||||
#if PIN_EXISTS(U_STDBY)
|
||||
SET_INPUT_PULLDOWN(U_STDBY_PIN);
|
||||
#endif
|
||||
#if PIN_EXISTS(V_STDBY)
|
||||
SET_INPUT_PULLDOWN(V_STDBY_PIN);
|
||||
#endif
|
||||
#if PIN_EXISTS(W_STDBY)
|
||||
SET_INPUT_PULLDOWN(W_STDBY_PIN);
|
||||
#endif
|
||||
#if PIN_EXISTS(E0_STDBY)
|
||||
SET_INPUT_PULLDOWN(E0_STDBY_PIN);
|
||||
#endif
|
||||
@@ -1130,10 +1175,9 @@ inline void tmc_standby_setup() {
|
||||
* • TMC220x Stepper Drivers (Serial)
|
||||
* • PSU control
|
||||
* • Power-loss Recovery
|
||||
* • L64XX Stepper Drivers (SPI)
|
||||
* • Stepper Driver Reset: DISABLE
|
||||
* • TMC Stepper Drivers (SPI)
|
||||
* • Run BOARD_INIT if defined
|
||||
* • Run hal.init_board() for additional pins setup
|
||||
* • ESP WiFi
|
||||
* - Get the Reset Reason and report it
|
||||
* - Print startup messages and diagnostics
|
||||
@@ -1210,6 +1254,10 @@ void setup() {
|
||||
|
||||
tmc_standby_setup(); // TMC Low Power Standby pins must be set early or they're not usable
|
||||
|
||||
// Check startup - does nothing if bootloader sets MCUSR to 0
|
||||
const byte mcu = hal.get_reset_source();
|
||||
hal.clear_reset_source();
|
||||
|
||||
#if ENABLED(MARLIN_DEV_MODE)
|
||||
auto log_current_ms = [&](PGM_P const msg) {
|
||||
SERIAL_ECHO_START();
|
||||
@@ -1260,9 +1308,13 @@ void setup() {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_FREEZE_PIN
|
||||
#if ENABLED(FREEZE_FEATURE)
|
||||
SETUP_LOG("FREEZE_PIN");
|
||||
SET_INPUT_PULLUP(FREEZE_PIN);
|
||||
#if FREEZE_STATE
|
||||
SET_INPUT_PULLDOWN(FREEZE_PIN);
|
||||
#else
|
||||
SET_INPUT_PULLUP(FREEZE_PIN);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if HAS_SUICIDE
|
||||
@@ -1275,29 +1327,26 @@ void setup() {
|
||||
JTAGSWD_RESET();
|
||||
#endif
|
||||
|
||||
#if EITHER(DISABLE_DEBUG, DISABLE_JTAG)
|
||||
// Disable any hardware debug to free up pins for IO
|
||||
#if ENABLED(DISABLE_DEBUG) && defined(JTAGSWD_DISABLE)
|
||||
delay(10);
|
||||
// Disable any hardware debug to free up pins for IO
|
||||
#if ENABLED(DISABLE_DEBUG) && defined(JTAGSWD_DISABLE)
|
||||
SETUP_LOG("JTAGSWD_DISABLE");
|
||||
JTAGSWD_DISABLE();
|
||||
#elif defined(JTAG_DISABLE)
|
||||
SETUP_LOG("JTAG_DISABLE");
|
||||
JTAG_DISABLE();
|
||||
#else
|
||||
#error "DISABLE_(DEBUG|JTAG) is not supported for the selected MCU/Board."
|
||||
#endif
|
||||
SETUP_LOG("JTAGSWD_DISABLE");
|
||||
JTAGSWD_DISABLE();
|
||||
#elif ENABLED(DISABLE_JTAG) && defined(JTAG_DISABLE)
|
||||
delay(10);
|
||||
SETUP_LOG("JTAG_DISABLE");
|
||||
JTAG_DISABLE();
|
||||
#endif
|
||||
|
||||
TERN_(DYNAMIC_VECTORTABLE, hook_cpu_exceptions()); // If supported, install Marlin exception handlers at runtime
|
||||
|
||||
SETUP_RUN(HAL_init());
|
||||
SETUP_RUN(hal.init());
|
||||
|
||||
// Init and disable SPI thermocouples; this is still needed
|
||||
#if TEMP_SENSOR_0_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E0))
|
||||
#if TEMP_SENSOR_IS_MAX_TC(0) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E0))
|
||||
OUT_WRITE(TEMP_0_CS_PIN, HIGH); // Disable
|
||||
#endif
|
||||
#if TEMP_SENSOR_1_IS_MAX_TC || (TEMP_SENSOR_REDUNDANT_IS_MAX_TC && REDUNDANT_TEMP_MATCH(SOURCE, E1))
|
||||
#if TEMP_SENSOR_IS_MAX_TC(1) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E1))
|
||||
OUT_WRITE(TEMP_1_CS_PIN, HIGH);
|
||||
#endif
|
||||
|
||||
@@ -1313,6 +1362,13 @@ void setup() {
|
||||
SETUP_RUN(tmc_serial_begin());
|
||||
#endif
|
||||
|
||||
#if HAS_TMC_SPI
|
||||
#if DISABLED(TMC_USE_SW_SPI)
|
||||
SETUP_RUN(SPI.begin());
|
||||
#endif
|
||||
SETUP_RUN(tmc_init_cs_pins());
|
||||
#endif
|
||||
|
||||
#if ENABLED(PSU_CONTROL)
|
||||
SETUP_LOG("PSU_CONTROL");
|
||||
powerManager.init();
|
||||
@@ -1322,37 +1378,22 @@ void setup() {
|
||||
SETUP_RUN(recovery.setup());
|
||||
#endif
|
||||
|
||||
#if HAS_L64XX
|
||||
SETUP_RUN(L64xxManager.init()); // Set up SPI, init drivers
|
||||
#endif
|
||||
|
||||
#if HAS_STEPPER_RESET
|
||||
SETUP_RUN(disableStepperDrivers());
|
||||
#endif
|
||||
|
||||
#if HAS_TMC_SPI
|
||||
#if DISABLED(TMC_USE_SW_SPI)
|
||||
SETUP_RUN(SPI.begin());
|
||||
#endif
|
||||
SETUP_RUN(tmc_init_cs_pins());
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_INIT
|
||||
SETUP_LOG("BOARD_INIT");
|
||||
BOARD_INIT();
|
||||
#endif
|
||||
SETUP_RUN(hal.init_board());
|
||||
|
||||
SETUP_RUN(esp_wifi_init());
|
||||
|
||||
// Check startup - does nothing if bootloader sets MCUSR to 0
|
||||
const byte mcu = HAL_get_reset_source();
|
||||
if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP);
|
||||
if (mcu & RST_EXTERNAL) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET);
|
||||
// Report Reset Reason
|
||||
if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP);
|
||||
if (mcu & RST_EXTERNAL) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET);
|
||||
if (mcu & RST_BROWN_OUT) SERIAL_ECHOLNPGM(STR_BROWNOUT_RESET);
|
||||
if (mcu & RST_WATCHDOG) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET);
|
||||
if (mcu & RST_SOFTWARE) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET);
|
||||
HAL_clear_reset_source();
|
||||
if (mcu & RST_WATCHDOG) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET);
|
||||
if (mcu & RST_SOFTWARE) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET);
|
||||
|
||||
// Identify myself as Marlin x.x.x
|
||||
SERIAL_ECHOLNPGM("Marlin " SHORT_BUILD_VERSION);
|
||||
#if defined(STRING_DISTRIBUTION_DATE) && defined(STRING_CONFIG_H_AUTHOR)
|
||||
SERIAL_ECHO_MSG(
|
||||
@@ -1361,13 +1402,13 @@ void setup() {
|
||||
);
|
||||
#endif
|
||||
SERIAL_ECHO_MSG(" Compiled: " __DATE__);
|
||||
SERIAL_ECHO_MSG(STR_FREE_MEMORY, freeMemory(), STR_PLANNER_BUFFER_BYTES, sizeof(block_t) * (BLOCK_BUFFER_SIZE));
|
||||
SERIAL_ECHO_MSG(STR_FREE_MEMORY, hal.freeMemory(), STR_PLANNER_BUFFER_BYTES, sizeof(block_t) * (BLOCK_BUFFER_SIZE));
|
||||
|
||||
// Some HAL need precise delay adjustment
|
||||
calibrate_delay_loop();
|
||||
|
||||
// Init buzzer pin(s)
|
||||
#if USE_BEEPER
|
||||
#if HAS_BEEPER
|
||||
SETUP_RUN(buzzer.init());
|
||||
#endif
|
||||
|
||||
@@ -1384,19 +1425,12 @@ void setup() {
|
||||
SETUP_RUN(controllerFan.setup());
|
||||
#endif
|
||||
|
||||
TERN_(HAS_FANCHECK, fan_check.init());
|
||||
|
||||
// UI must be initialized before EEPROM
|
||||
// (because EEPROM code calls the UI).
|
||||
|
||||
#if HAS_DWIN_E3V2_BASIC
|
||||
SETUP_RUN(DWIN_Startup());
|
||||
#else
|
||||
SETUP_RUN(ui.init());
|
||||
#if BOTH(HAS_WIRED_LCD, SHOW_BOOTSCREEN)
|
||||
SETUP_RUN(ui.show_bootscreen());
|
||||
const millis_t bootscreen_ms = millis();
|
||||
#endif
|
||||
SETUP_RUN(ui.reset_status()); // Load welcome message early. (Retained if no errors exist.)
|
||||
#endif
|
||||
SETUP_RUN(ui.init());
|
||||
|
||||
#if PIN_EXISTS(SAFE_POWER)
|
||||
#if HAS_DRIVER_SAFE_POWER_PROTECT
|
||||
@@ -1407,10 +1441,6 @@ void setup() {
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if ENABLED(PROBE_TARE)
|
||||
SETUP_RUN(probe.tare_init());
|
||||
#endif
|
||||
|
||||
#if BOTH(SDSUPPORT, SDCARD_EEPROM_EMULATION)
|
||||
SETUP_RUN(card.mount()); // Mount media with settings before first_load
|
||||
#endif
|
||||
@@ -1418,6 +1448,15 @@ void setup() {
|
||||
SETUP_RUN(settings.first_load()); // Load data from EEPROM if available (or use defaults)
|
||||
// This also updates variables in the planner, elsewhere
|
||||
|
||||
#if BOTH(HAS_WIRED_LCD, SHOW_BOOTSCREEN)
|
||||
SETUP_RUN(ui.show_bootscreen());
|
||||
const millis_t bootscreen_ms = millis();
|
||||
#endif
|
||||
|
||||
#if ENABLED(PROBE_TARE)
|
||||
SETUP_RUN(probe.tare_init());
|
||||
#endif
|
||||
|
||||
#if HAS_ETHERNET
|
||||
SETUP_RUN(ethernet.init());
|
||||
#endif
|
||||
@@ -1436,6 +1475,10 @@ void setup() {
|
||||
|
||||
SETUP_RUN(endstops.init()); // Init endstops and pullups
|
||||
|
||||
#if ENABLED(DELTA) && !HAS_SOFTWARE_ENDSTOPS
|
||||
SETUP_RUN(refresh_delta_clip_start_height()); // Init safe delta height without soft endstops
|
||||
#endif
|
||||
|
||||
SETUP_RUN(stepper.init()); // Init stepper. This enables interrupts!
|
||||
|
||||
#if HAS_SERVOS
|
||||
@@ -1462,6 +1505,9 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if HAS_BED_PROBE
|
||||
#if PIN_EXISTS(PROBE_ENABLE)
|
||||
OUT_WRITE(PROBE_ENABLE_PIN, LOW); // Disable
|
||||
#endif
|
||||
SETUP_RUN(endstops.enable_z_probe(false));
|
||||
#endif
|
||||
|
||||
@@ -1592,6 +1638,10 @@ void setup() {
|
||||
SETUP_RUN(bltouch.init(/*set_voltage=*/true));
|
||||
#endif
|
||||
|
||||
#if ENABLED(MAGLEV4)
|
||||
OUT_WRITE(MAGLEV_TRIGGER_PIN, LOW);
|
||||
#endif
|
||||
|
||||
#if ENABLED(I2C_POSITION_ENCODERS)
|
||||
SETUP_RUN(I2CPEM.init());
|
||||
#endif
|
||||
@@ -1628,7 +1678,7 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if ENABLED(USE_WATCHDOG)
|
||||
SETUP_RUN(watchdog_init()); // Reinit watchdog after HAL_get_reset_source call
|
||||
SETUP_RUN(hal.watchdog_init()); // Reinit watchdog after hal.get_reset_source call
|
||||
#endif
|
||||
|
||||
#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
|
||||
@@ -1637,15 +1687,11 @@ void setup() {
|
||||
|
||||
#ifdef STARTUP_COMMANDS
|
||||
SETUP_LOG("STARTUP_COMMANDS");
|
||||
queue.inject_P(PSTR(STARTUP_COMMANDS));
|
||||
queue.inject(F(STARTUP_COMMANDS));
|
||||
#endif
|
||||
|
||||
#if ENABLED(HOST_PROMPT_SUPPORT)
|
||||
SETUP_RUN(host_action_prompt_end());
|
||||
#endif
|
||||
|
||||
#if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF)
|
||||
SETUP_RUN(test_tmc_connection());
|
||||
SETUP_RUN(hostui.prompt_end());
|
||||
#endif
|
||||
|
||||
#if HAS_DRIVER_SAFE_POWER_PROTECT
|
||||
@@ -1663,15 +1709,11 @@ void setup() {
|
||||
#endif
|
||||
|
||||
#if HAS_DWIN_E3V2_BASIC
|
||||
Encoder_Configuration();
|
||||
HMI_Init();
|
||||
HMI_SetLanguageCache();
|
||||
HMI_StartFrame(true);
|
||||
DWIN_StatusChanged_P(GET_TEXT(WELCOME_MSG));
|
||||
SETUP_RUN(DWIN_InitScreen());
|
||||
#endif
|
||||
|
||||
#if HAS_SERVICE_INTERVALS && !HAS_DWIN_E3V2_BASIC
|
||||
ui.reset_status(true); // Show service messages or keep current status
|
||||
SETUP_RUN(ui.reset_status(true)); // Show service messages or keep current status
|
||||
#endif
|
||||
|
||||
#if ENABLED(MAX7219_DEBUG)
|
||||
@@ -1701,13 +1743,27 @@ void setup() {
|
||||
SETUP_RUN(password.lock_machine()); // Will not proceed until correct password provided
|
||||
#endif
|
||||
|
||||
#if BOTH(HAS_LCD_MENU, TOUCH_SCREEN_CALIBRATION) && EITHER(TFT_CLASSIC_UI, TFT_COLOR_UI)
|
||||
ui.check_touch_calibration();
|
||||
#if BOTH(HAS_MARLINUI_MENU, TOUCH_SCREEN_CALIBRATION) && EITHER(TFT_CLASSIC_UI, TFT_COLOR_UI)
|
||||
SETUP_RUN(ui.check_touch_calibration());
|
||||
#endif
|
||||
|
||||
#if ENABLED(EASYTHREED_UI)
|
||||
SETUP_RUN(easythreed_ui.init());
|
||||
#endif
|
||||
|
||||
#if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF)
|
||||
SETUP_RUN(test_tmc_connection());
|
||||
#endif
|
||||
|
||||
#if ENABLED(BD_SENSOR)
|
||||
SETUP_RUN(bdl.init(I2C_BD_SDA_PIN, I2C_BD_SCL_PIN, I2C_BD_DELAY));
|
||||
#endif
|
||||
|
||||
marlin_state = MF_RUNNING;
|
||||
|
||||
SETUP_LOG("setup() completed.");
|
||||
|
||||
TERN_(MARLIN_TEST_BUILD, runStartupTests());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1734,6 +1790,10 @@ void loop() {
|
||||
|
||||
queue.advance();
|
||||
|
||||
#if EITHER(POWER_OFF_TIMER, POWER_OFF_WAIT_FOR_COOLDOWN)
|
||||
powerManager.checkAutoPowerOff();
|
||||
#endif
|
||||
|
||||
endstops.event_handler();
|
||||
|
||||
// PATCH START: Knutwurst
|
||||
@@ -1745,5 +1805,7 @@ void loop() {
|
||||
|
||||
TERN_(HAS_TFT_LVGL_UI, printer_state_polling());
|
||||
|
||||
TERN_(MARLIN_TEST_BUILD, runPeriodicTests());
|
||||
|
||||
} while (ENABLED(__AVR__)); // Loop forever on slower (AVR) boards
|
||||
}
|
||||
|
Reference in New Issue
Block a user