2016-03-25 07:19:46 +01:00
|
|
|
/**
|
2016-03-24 19:01:20 +01:00
|
|
|
* Marlin 3D Printer Firmware
|
2020-02-03 15:00:57 +01:00
|
|
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2015-05-17 10:44:53 +02:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2015-05-17 10:44:53 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2020-07-23 05:20:14 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2016-03-24 19:01:20 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-03-25 07:19:46 +01:00
|
|
|
/**
|
2015-05-17 10:44:53 +02:00
|
|
|
* About Marlin
|
|
|
|
*
|
|
|
|
* This firmware is a mashup between Sprinter and grbl.
|
|
|
|
* - https://github.com/kliment/Sprinter
|
2018-02-06 09:28:18 +01:00
|
|
|
* - https://github.com/grbl/grbl
|
2015-04-14 02:17:36 +02:00
|
|
|
*/
|
2012-11-06 12:06:41 +01:00
|
|
|
|
2020-01-03 02:01:38 +01:00
|
|
|
#include "MarlinCore.h"
|
2016-11-19 04:54:38 +01:00
|
|
|
|
2020-04-25 23:32:08 +02:00
|
|
|
#include "HAL/shared/Delay.h"
|
|
|
|
#include "HAL/shared/esp_wifi.h"
|
2021-02-21 03:22:20 +01:00
|
|
|
#include "HAL/shared/cpu_exception/exception_hook.h"
|
2020-04-25 23:32:08 +02:00
|
|
|
|
|
|
|
#ifdef ARDUINO
|
|
|
|
#include <pins_arduino.h>
|
|
|
|
#endif
|
|
|
|
#include <math.h>
|
|
|
|
|
2022-08-05 00:56:09 +02:00
|
|
|
#include "module/endstops.h"
|
2017-09-08 05:33:16 +02:00
|
|
|
#include "module/motion.h"
|
2017-09-06 13:28:33 +02:00
|
|
|
#include "module/planner.h"
|
2017-09-09 07:18:43 +02:00
|
|
|
#include "module/printcounter.h" // PrintCounter or Stopwatch
|
2022-08-05 00:56:09 +02:00
|
|
|
#include "module/settings.h"
|
2020-08-04 04:55:37 +02:00
|
|
|
#include "module/stepper.h"
|
2022-08-05 00:56:09 +02:00
|
|
|
#include "module/temperature.h"
|
2019-01-24 02:06:54 +01:00
|
|
|
|
2017-09-08 05:33:16 +02:00
|
|
|
#include "gcode/gcode.h"
|
2017-09-06 13:28:33 +02:00
|
|
|
#include "gcode/parser.h"
|
2017-09-08 05:33:16 +02:00
|
|
|
#include "gcode/queue.h"
|
2016-11-19 04:54:38 +01:00
|
|
|
|
2021-01-21 10:40:07 +01:00
|
|
|
#include "feature/pause.h"
|
2020-08-04 04:55:37 +02:00
|
|
|
#include "sd/cardreader.h"
|
|
|
|
|
2020-10-17 02:36:25 +02:00
|
|
|
#include "lcd/marlinui.h"
|
2020-11-15 23:39:58 +01:00
|
|
|
#if HAS_TOUCH_BUTTONS
|
2020-08-22 01:54:21 +02:00
|
|
|
#include "lcd/touch/touch_buttons.h"
|
2020-08-04 04:55:37 +02:00
|
|
|
#endif
|
|
|
|
|
2020-07-25 07:52:07 +02:00
|
|
|
#if HAS_TFT_LVGL_UI
|
2021-05-06 11:17:59 +02:00
|
|
|
#include "lcd/extui/mks_ui/tft_lvgl_configuration.h"
|
|
|
|
#include "lcd/extui/mks_ui/draw_ui.h"
|
2021-07-19 04:21:51 +02:00
|
|
|
#include "lcd/extui/mks_ui/mks_hardware.h"
|
2020-07-25 07:52:07 +02:00
|
|
|
#include <lvgl.h>
|
2020-06-16 04:05:33 +02:00
|
|
|
#endif
|
|
|
|
|
2021-09-16 02:48:29 +02:00
|
|
|
#if HAS_DWIN_E3V2
|
|
|
|
#include "lcd/e3v2/common/encoder.h"
|
|
|
|
#if ENABLED(DWIN_CREALITY_LCD)
|
|
|
|
#include "lcd/e3v2/creality/dwin.h"
|
2022-03-11 05:07:47 +01:00
|
|
|
#elif ENABLED(DWIN_LCD_PROUI)
|
2022-02-05 17:30:17 +01:00
|
|
|
#include "lcd/e3v2/proui/dwin.h"
|
2022-07-23 04:59:00 +02:00
|
|
|
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
|
|
|
|
#include "lcd/e3v2/jyersui/dwin.h"
|
2021-09-16 02:48:29 +02:00
|
|
|
#endif
|
2020-06-16 08:45:27 +02:00
|
|
|
#endif
|
|
|
|
|
2020-10-20 21:35:29 +02:00
|
|
|
#if HAS_ETHERNET
|
|
|
|
#include "feature/ethernet.h"
|
|
|
|
#endif
|
|
|
|
|
2020-06-16 08:45:27 +02:00
|
|
|
#if ENABLED(IIC_BL24CXX_EEPROM)
|
2020-07-24 10:09:14 +02:00
|
|
|
#include "libs/BL24CXX.h"
|
2020-06-16 08:45:27 +02:00
|
|
|
#endif
|
|
|
|
|
2020-05-12 02:22:41 +02:00
|
|
|
#if ENABLED(DIRECT_STEPPING)
|
|
|
|
#include "feature/direct_stepping.h"
|
|
|
|
#endif
|
|
|
|
|
2019-02-12 22:55:47 +01:00
|
|
|
#if ENABLED(HOST_ACTION_COMMANDS)
|
|
|
|
#include "feature/host_actions.h"
|
|
|
|
#endif
|
|
|
|
|
2022-05-12 04:23:16 +02:00
|
|
|
#if HAS_BEEPER
|
2017-09-14 22:33:07 +02:00
|
|
|
#include "libs/buzzer.h"
|
|
|
|
#endif
|
|
|
|
|
2020-08-04 04:55:37 +02:00
|
|
|
#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
|
|
|
|
#include "feature/closedloop.h"
|
|
|
|
#endif
|
|
|
|
|
2020-10-11 21:58:35 +02:00
|
|
|
#if HAS_MOTOR_CURRENT_I2C
|
2017-09-18 01:45:21 +02:00
|
|
|
#include "feature/digipot/digipot.h"
|
|
|
|
#endif
|
|
|
|
|
2017-09-18 07:06:16 +02:00
|
|
|
#if ENABLED(MIXING_EXTRUDER)
|
|
|
|
#include "feature/mixing.h"
|
|
|
|
#endif
|
|
|
|
|
2017-08-26 00:03:07 +02:00
|
|
|
#if ENABLED(MAX7219_DEBUG)
|
2020-03-13 22:29:29 +01:00
|
|
|
#include "feature/max7219.h"
|
2017-08-26 00:03:07 +02:00
|
|
|
#endif
|
|
|
|
|
2017-09-08 21:47:47 +02:00
|
|
|
#if HAS_COLOR_LEDS
|
|
|
|
#include "feature/leds/leds.h"
|
2017-06-10 08:02:15 +02:00
|
|
|
#endif
|
|
|
|
|
2019-03-17 11:57:25 +01:00
|
|
|
#if ENABLED(BLTOUCH)
|
|
|
|
#include "feature/bltouch.h"
|
|
|
|
#endif
|
|
|
|
|
2022-08-06 08:14:58 +02:00
|
|
|
#if ENABLED(BD_SENSOR)
|
|
|
|
#include "feature/bedlevel/bdl/bdl.h"
|
|
|
|
#endif
|
|
|
|
|
2019-09-08 07:55:34 +02:00
|
|
|
#if ENABLED(POLL_JOG)
|
|
|
|
#include "feature/joystick.h"
|
|
|
|
#endif
|
|
|
|
|
2016-11-19 04:54:38 +01:00
|
|
|
#if HAS_SERVOS
|
2017-11-19 20:39:46 +01:00
|
|
|
#include "module/servo.h"
|
2016-11-19 04:54:38 +01:00
|
|
|
#endif
|
|
|
|
|
2021-07-10 00:09:58 +02:00
|
|
|
#if HAS_MOTOR_CURRENT_DAC
|
2017-09-06 13:28:33 +02:00
|
|
|
#include "feature/dac/stepper_dac.h"
|
2016-11-19 04:54:38 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(EXPERIMENTAL_I2CBUS)
|
2017-09-06 13:28:33 +02:00
|
|
|
#include "feature/twibus.h"
|
2016-11-19 04:54:38 +01:00
|
|
|
#endif
|
|
|
|
|
2017-06-09 14:06:23 +02:00
|
|
|
#if ENABLED(I2C_POSITION_ENCODERS)
|
2020-03-13 22:29:29 +01:00
|
|
|
#include "feature/encoder_i2c.h"
|
2017-06-09 14:06:23 +02:00
|
|
|
#endif
|
|
|
|
|
2022-02-22 04:16:57 +01:00
|
|
|
#if (HAS_TRINAMIC_CONFIG || HAS_TMC_SPI) && DISABLED(PSU_DEFAULT_OFF)
|
2017-12-15 22:03:14 +01:00
|
|
|
#include "feature/tmc_util.h"
|
2017-09-18 01:34:04 +02:00
|
|
|
#endif
|
|
|
|
|
2019-06-28 06:06:49 +02:00
|
|
|
#if HAS_CUTTER
|
|
|
|
#include "feature/spindle_laser.h"
|
|
|
|
#endif
|
|
|
|
|
2015-07-31 07:24:43 +02:00
|
|
|
#if ENABLED(SDSUPPORT)
|
2015-01-30 03:52:21 +01:00
|
|
|
CardReader card;
|
2012-11-06 12:06:41 +01:00
|
|
|
#endif
|
2015-01-30 03:52:21 +01:00
|
|
|
|
2016-09-29 22:06:01 +02:00
|
|
|
#if ENABLED(G38_PROBE_TARGET)
|
2019-03-10 23:22:09 +01:00
|
|
|
uint8_t G38_move; // = 0
|
|
|
|
bool G38_did_trigger; // = false
|
2016-09-19 21:17:10 +02:00
|
|
|
#endif
|
|
|
|
|
2017-09-08 22:35:25 +02:00
|
|
|
#if ENABLED(DELTA)
|
|
|
|
#include "module/delta.h"
|
2021-09-20 22:42:33 +02:00
|
|
|
#elif ENABLED(POLARGRAPH)
|
|
|
|
#include "module/polargraph.h"
|
2017-09-08 22:35:25 +02:00
|
|
|
#elif IS_SCARA
|
|
|
|
#include "module/scara.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAS_LEVELING
|
|
|
|
#include "feature/bedlevel/bedlevel.h"
|
2017-03-18 16:15:54 +01:00
|
|
|
#endif
|
|
|
|
|
2020-11-27 04:18:40 +01:00
|
|
|
#if ENABLED(GCODE_REPEAT_MARKERS)
|
|
|
|
#include "feature/repeat.h"
|
|
|
|
#endif
|
|
|
|
|
2018-04-22 02:41:26 +02:00
|
|
|
#if ENABLED(POWER_LOSS_RECOVERY)
|
2020-03-13 22:29:29 +01:00
|
|
|
#include "feature/powerloss.h"
|
2018-04-22 02:41:26 +02:00
|
|
|
#endif
|
|
|
|
|
2019-10-25 19:26:41 +02:00
|
|
|
#if ENABLED(CANCEL_OBJECTS)
|
|
|
|
#include "feature/cancel_object.h"
|
|
|
|
#endif
|
|
|
|
|
2019-02-13 03:08:34 +01:00
|
|
|
#if HAS_FILAMENT_SENSOR
|
2017-10-10 09:35:20 +02:00
|
|
|
#include "feature/runout.h"
|
|
|
|
#endif
|
|
|
|
|
2020-12-27 23:23:18 +01:00
|
|
|
#if EITHER(PROBE_TARE, HAS_Z_SERVO_PROBE)
|
2020-08-04 04:55:37 +02:00
|
|
|
#include "module/probe.h"
|
|
|
|
#endif
|
|
|
|
|
2020-05-18 07:50:35 +02:00
|
|
|
#if ENABLED(HOTEND_IDLE_TIMEOUT)
|
|
|
|
#include "feature/hotend_idle.h"
|
|
|
|
#endif
|
|
|
|
|
2017-09-16 12:09:34 +02:00
|
|
|
#if ENABLED(TEMP_STAT_LEDS)
|
|
|
|
#include "feature/leds/tempstat.h"
|
|
|
|
#endif
|
|
|
|
|
2020-08-06 15:14:00 +02:00
|
|
|
#if ENABLED(CASE_LIGHT_ENABLE)
|
2017-09-18 01:56:29 +02:00
|
|
|
#include "feature/caselight.h"
|
|
|
|
#endif
|
|
|
|
|
2017-11-05 03:01:41 +01:00
|
|
|
#if HAS_FANMUX
|
|
|
|
#include "feature/fanmux.h"
|
|
|
|
#endif
|
|
|
|
|
2021-04-16 15:02:31 +02:00
|
|
|
#include "module/tool_change.h"
|
2017-09-18 08:05:44 +02:00
|
|
|
|
2021-11-23 21:01:53 +01:00
|
|
|
#if HAS_FANCHECK
|
|
|
|
#include "feature/fancheck.h"
|
|
|
|
#endif
|
|
|
|
|
2017-09-18 08:44:59 +02:00
|
|
|
#if ENABLED(USE_CONTROLLER_FAN)
|
|
|
|
#include "feature/controllerfan.h"
|
|
|
|
#endif
|
|
|
|
|
2021-10-18 09:54:20 +02:00
|
|
|
#if HAS_PRUSA_MMU1
|
|
|
|
#include "feature/mmu/mmu.h"
|
|
|
|
#endif
|
|
|
|
|
2020-11-18 08:27:21 +01:00
|
|
|
#if HAS_PRUSA_MMU2
|
|
|
|
#include "feature/mmu/mmu2.h"
|
2019-02-01 02:10:52 +01:00
|
|
|
#endif
|
|
|
|
|
2020-08-09 03:00:42 +02:00
|
|
|
#if ENABLED(PASSWORD_FEATURE)
|
|
|
|
#include "feature/password/password.h"
|
|
|
|
#endif
|
|
|
|
|
2021-02-28 00:35:32 +01:00
|
|
|
#if ENABLED(DGUS_LCD_UI_MKS)
|
2021-05-06 11:17:59 +02:00
|
|
|
#include "lcd/extui/dgus/DGUSScreenHandler.h"
|
2021-02-28 00:35:32 +01:00
|
|
|
#endif
|
|
|
|
|
2021-04-27 09:22:09 +02:00
|
|
|
#if HAS_DRIVER_SAFE_POWER_PROTECT
|
|
|
|
#include "feature/stepper_driver_safety.h"
|
|
|
|
#endif
|
|
|
|
|
2021-07-12 07:13:58 +02:00
|
|
|
#if ENABLED(PSU_CONTROL)
|
|
|
|
#include "feature/power.h"
|
|
|
|
#endif
|
|
|
|
|
2021-11-23 22:52:18 +01:00
|
|
|
#if ENABLED(EASYTHREED_UI)
|
|
|
|
#include "feature/easythreed_ui.h"
|
|
|
|
#endif
|
|
|
|
|
2022-08-05 00:56:09 +02:00
|
|
|
#if ENABLED(MARLIN_TEST_BUILD)
|
|
|
|
#include "tests/marlin_tests.h"
|
|
|
|
#endif
|
|
|
|
|
2020-05-06 06:34:04 +02:00
|
|
|
PGMSTR(M112_KILL_STR, "M112 Shutdown");
|
2019-11-02 05:51:25 +01:00
|
|
|
|
2020-03-15 00:47:44 +01:00
|
|
|
MarlinState marlin_state = MF_INITIALIZING;
|
2015-04-08 09:56:19 +02:00
|
|
|
|
2016-10-07 05:06:33 +02:00
|
|
|
// For M109 and M190, this flag may be cleared (by M108) to exit the wait loop
|
2019-03-10 15:13:54 +01:00
|
|
|
bool wait_for_heatup = true;
|
2015-04-08 09:56:19 +02:00
|
|
|
|
2016-10-07 05:06:33 +02:00
|
|
|
// For M0/M1, this flag may be cleared (by M108) to exit the wait-for-user loop
|
2017-04-09 18:12:08 +02:00
|
|
|
#if HAS_RESUME_CONTINUE
|
2019-03-09 21:13:50 +01:00
|
|
|
bool wait_for_user; // = false;
|
2020-03-28 09:18:53 +01:00
|
|
|
|
|
|
|
void wait_for_user_response(millis_t ms/*=0*/, const bool no_sleep/*=false*/) {
|
2020-11-08 01:28:29 +01:00
|
|
|
UNUSED(no_sleep);
|
2020-03-28 09:18:53 +01:00
|
|
|
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
|
|
|
wait_for_user = true;
|
|
|
|
if (ms) ms += millis(); // expire time
|
2020-04-02 08:22:48 +02:00
|
|
|
while (wait_for_user && !(ms && ELAPSED(millis(), ms)))
|
|
|
|
idle(TERN_(ADVANCED_PAUSE_FEATURE, no_sleep));
|
2020-03-28 09:18:53 +01:00
|
|
|
wait_for_user = false;
|
2022-04-21 14:07:04 +02:00
|
|
|
while (ui.button_pressed()) safe_delay(50);
|
2020-03-28 09:18:53 +01:00
|
|
|
}
|
|
|
|
|
2016-09-12 03:51:53 +02:00
|
|
|
#endif
|
|
|
|
|
2016-09-15 20:22:23 +02:00
|
|
|
/**
|
2017-09-08 22:35:25 +02:00
|
|
|
* ***************************************************************************
|
|
|
|
* ******************************** FUNCTIONS ********************************
|
|
|
|
* ***************************************************************************
|
2016-09-15 20:22:23 +02:00
|
|
|
*/
|
|
|
|
|
2017-09-08 22:35:25 +02:00
|
|
|
/**
|
|
|
|
* Stepper Reset (RigidBoard, et.al.)
|
|
|
|
*/
|
|
|
|
#if HAS_STEPPER_RESET
|
2019-02-20 12:28:40 +01:00
|
|
|
void disableStepperDrivers() { OUT_WRITE(STEPPER_RESET_PIN, LOW); } // Drive down to keep motor driver chips in reset
|
|
|
|
void enableStepperDrivers() { SET_INPUT(STEPPER_RESET_PIN); } // Set to input, allowing pullups to pull the pin high
|
2017-09-08 22:35:25 +02:00
|
|
|
#endif
|
2016-08-28 02:53:02 +02:00
|
|
|
|
2017-09-06 13:28:33 +02:00
|
|
|
/**
|
|
|
|
* Sensitive pin test for M42, M226
|
|
|
|
*/
|
2018-10-11 07:58:41 +02:00
|
|
|
|
|
|
|
#include "pins/sensitive_pins.h"
|
|
|
|
|
2020-04-28 15:30:52 +02:00
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wnarrowing"
|
|
|
|
|
2021-06-21 05:49:57 +02:00
|
|
|
#ifndef RUNTIME_ONLY_ANALOG_TO_DIGITAL
|
2021-06-09 02:55:27 +02:00
|
|
|
template <pin_t ...D>
|
2021-06-21 05:49:57 +02:00
|
|
|
constexpr pin_t OnlyPins<_SP_END, D...>::table[sizeof...(D)];
|
2021-06-09 02:55:27 +02:00
|
|
|
#endif
|
|
|
|
|
2017-10-26 20:37:26 +02:00
|
|
|
bool pin_is_protected(const pin_t pin) {
|
2021-06-21 05:49:57 +02:00
|
|
|
#ifdef RUNTIME_ONLY_ANALOG_TO_DIGITAL
|
|
|
|
static const pin_t sensitive_pins[] PROGMEM = { SENSITIVE_PINS };
|
|
|
|
const size_t pincount = COUNT(sensitive_pins);
|
|
|
|
#else
|
|
|
|
static constexpr size_t pincount = OnlyPins<SENSITIVE_PINS>::size;
|
|
|
|
static const pin_t (&sensitive_pins)[pincount] PROGMEM = OnlyPins<SENSITIVE_PINS>::table;
|
|
|
|
#endif
|
|
|
|
LOOP_L_N(i, pincount) {
|
|
|
|
const pin_t * const pptr = &sensitive_pins[i];
|
|
|
|
if (pin == (sizeof(pin_t) == 2 ? (pin_t)pgm_read_word(pptr) : (pin_t)pgm_read_byte(pptr))) return true;
|
2017-10-26 20:37:26 +02:00
|
|
|
}
|
2017-09-06 13:28:33 +02:00
|
|
|
return false;
|
|
|
|
}
|
2016-07-19 17:24:44 +02:00
|
|
|
|
2020-04-28 15:30:52 +02:00
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
|
2022-05-13 03:13:59 +02:00
|
|
|
bool printer_busy() {
|
|
|
|
return planner.movesplanned() || printingIsActive();
|
|
|
|
}
|
|
|
|
|
2020-07-15 08:14:03 +02:00
|
|
|
/**
|
2021-05-08 11:35:35 +02:00
|
|
|
* A Print Job exists when the timer is running or SD is printing
|
2020-07-15 08:14:03 +02:00
|
|
|
*/
|
2021-05-08 11:35:35 +02:00
|
|
|
bool printJobOngoing() { return print_job_timer.isRunning() || IS_SD_PRINTING(); }
|
2020-07-15 08:14:03 +02:00
|
|
|
|
2019-10-03 01:54:20 +02:00
|
|
|
/**
|
2021-05-08 11:35:35 +02:00
|
|
|
* Printing is active when a job is underway but not paused
|
2019-10-03 01:54:20 +02:00
|
|
|
*/
|
2021-05-08 11:35:35 +02:00
|
|
|
bool printingIsActive() { return !did_pause_print && printJobOngoing(); }
|
2019-10-03 01:54:20 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Printing is paused according to SD or host indicators
|
|
|
|
*/
|
|
|
|
bool printingIsPaused() {
|
2019-10-24 22:35:40 +02:00
|
|
|
return did_pause_print || print_job_timer.isPaused() || IS_SD_PAUSED();
|
|
|
|
}
|
|
|
|
|
|
|
|
void startOrResumeJob() {
|
2019-10-27 23:49:27 +01:00
|
|
|
if (!printingIsPaused()) {
|
2020-11-27 04:18:40 +01:00
|
|
|
TERN_(GCODE_REPEAT_MARKERS, repeat.reset());
|
2020-04-22 23:35:03 +02:00
|
|
|
TERN_(CANCEL_OBJECTS, cancelable.reset());
|
|
|
|
TERN_(LCD_SHOW_E_TOTAL, e_move_accumulator = 0);
|
2019-11-13 09:07:09 +01:00
|
|
|
#if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME)
|
2019-11-13 02:36:54 +01:00
|
|
|
ui.reset_remaining_time();
|
|
|
|
#endif
|
2019-10-27 23:49:27 +01:00
|
|
|
}
|
2019-10-24 22:35:40 +02:00
|
|
|
print_job_timer.start();
|
2019-10-03 01:54:20 +02:00
|
|
|
}
|
|
|
|
|
2019-10-29 23:04:39 +01:00
|
|
|
#if ENABLED(SDSUPPORT)
|
|
|
|
|
2020-02-26 05:18:14 +01:00
|
|
|
inline void abortSDPrinting() {
|
2020-12-07 12:53:15 +01:00
|
|
|
IF_DISABLED(NO_SD_AUTOSTART, card.autofile_cancel());
|
2021-05-08 11:35:35 +02:00
|
|
|
card.abortFilePrintNow(TERN_(SD_RESORT, true));
|
2021-01-25 11:56:54 +01:00
|
|
|
|
2019-10-29 23:04:39 +01:00
|
|
|
queue.clear();
|
|
|
|
quickstop_stepper();
|
2021-01-26 09:30:31 +01:00
|
|
|
|
|
|
|
print_job_timer.abort();
|
2021-01-25 11:56:54 +01:00
|
|
|
|
|
|
|
IF_DISABLED(SD_ABORT_NO_COOLDOWN, thermalManager.disable_all_heaters());
|
|
|
|
|
|
|
|
TERN(HAS_CUTTER, cutter.kill(), thermalManager.zero_fan_speeds()); // Full cutter shutdown including ISR control
|
|
|
|
|
2019-10-29 23:04:39 +01:00
|
|
|
wait_for_heatup = false;
|
2021-01-25 11:56:54 +01:00
|
|
|
|
2020-04-22 23:35:03 +02:00
|
|
|
TERN_(POWER_LOSS_RECOVERY, recovery.purge());
|
2021-01-25 11:56:54 +01:00
|
|
|
|
2020-08-11 03:25:35 +02:00
|
|
|
#ifdef EVENT_GCODE_SD_ABORT
|
2021-09-26 04:11:31 +02:00
|
|
|
queue.inject(F(EVENT_GCODE_SD_ABORT));
|
2019-10-29 23:04:39 +01:00
|
|
|
#endif
|
2020-08-09 03:00:42 +02:00
|
|
|
|
|
|
|
TERN_(PASSWORD_AFTER_SD_PRINT_ABORT, password.lock_machine());
|
2019-10-29 23:04:39 +01:00
|
|
|
}
|
|
|
|
|
2020-02-26 05:18:14 +01:00
|
|
|
inline void finishSDPrinting() {
|
2021-09-26 04:11:31 +02:00
|
|
|
if (queue.enqueue_one(F("M1001"))) { // Keep trying until it gets queued
|
|
|
|
marlin_state = MF_RUNNING; // Signal to stop trying
|
2020-08-09 03:00:42 +02:00
|
|
|
TERN_(PASSWORD_AFTER_SD_PRINT_END, password.lock_machine());
|
2021-02-28 00:35:32 +01:00
|
|
|
TERN_(DGUS_LCD_UI_MKS, ScreenHandler.SDPrintingFinished());
|
2020-08-09 03:00:42 +02:00
|
|
|
}
|
2020-02-26 05:18:14 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SDSUPPORT
|
2019-10-29 22:00:17 +01:00
|
|
|
|
2015-04-04 00:31:35 +02:00
|
|
|
/**
|
2020-02-26 05:18:14 +01:00
|
|
|
* Minimal management of Marlin's core activities:
|
2015-04-04 08:42:50 +02:00
|
|
|
* - Keep the command buffer full
|
|
|
|
* - Check for maximum inactive time between commands
|
|
|
|
* - Check for maximum inactive time between stepper commands
|
2018-11-05 08:08:40 +01:00
|
|
|
* - Check if CHDK_PIN needs to go LOW
|
2015-04-04 08:42:50 +02:00
|
|
|
* - Check for KILL button held down
|
|
|
|
* - Check for HOME button held down
|
2021-03-01 15:03:41 +01:00
|
|
|
* - Check for CUSTOM USER button held down
|
2015-04-04 08:42:50 +02:00
|
|
|
* - Check if cooling fan needs to be switched on
|
|
|
|
* - Check if an idle but hot extruder needs filament extruded (EXTRUDER_RUNOUT_PREVENT)
|
2019-02-27 04:03:13 +01:00
|
|
|
* - Pulse FET_SAFETY_PIN if it exists
|
2015-04-04 00:31:35 +02:00
|
|
|
*/
|
2021-06-15 01:44:27 +02:00
|
|
|
inline void manage_inactivity(const bool no_stepper_sleep=false) {
|
2015-08-05 13:40:36 +02:00
|
|
|
|
2021-02-26 23:54:46 +01:00
|
|
|
queue.get_available_commands();
|
2015-04-04 00:31:35 +02:00
|
|
|
|
2017-03-29 02:45:54 +02:00
|
|
|
const millis_t ms = millis();
|
2015-04-04 00:31:35 +02:00
|
|
|
|
2021-06-15 01:44:27 +02:00
|
|
|
// Prevent steppers timing-out
|
|
|
|
const bool do_reset_timeout = no_stepper_sleep
|
2021-01-21 10:40:07 +01:00
|
|
|
|| TERN0(PAUSE_PARK_NO_STEPPER_TIMEOUT, did_pause_print);
|
2020-07-01 23:27:28 +02:00
|
|
|
|
2020-07-02 05:28:37 +02:00
|
|
|
// Reset both the M18/M84 activity timeout and the M85 max 'kill' timeout
|
2021-06-15 01:44:27 +02:00
|
|
|
if (do_reset_timeout) gcode.reset_stepper_timeout(ms);
|
2020-07-01 23:27:28 +02:00
|
|
|
|
|
|
|
if (gcode.stepper_max_timed_out(ms)) {
|
2022-04-04 01:44:45 +02:00
|
|
|
SERIAL_ERROR_START();
|
|
|
|
SERIAL_ECHOPGM(STR_KILL_PRE);
|
|
|
|
SERIAL_ECHOLNPGM(STR_KILL_INACTIVE_TIME, parser.command_ptr);
|
2018-10-19 04:20:56 +02:00
|
|
|
kill();
|
2017-03-14 18:24:46 +01:00
|
|
|
}
|
2017-02-10 07:13:58 +01:00
|
|
|
|
2022-06-01 00:09:44 +02:00
|
|
|
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.
|
|
|
|
|
2020-11-10 10:27:34 +01:00
|
|
|
// M18 / M84 : Handle steppers inactive time timeout
|
2022-06-01 00:09:44 +02:00
|
|
|
#if HAS_DISABLE_INACTIVE_AXIS
|
|
|
|
if (gcode.stepper_inactive_time) {
|
|
|
|
|
|
|
|
static bool already_shutdown_steppers; // = false
|
|
|
|
|
|
|
|
if (!has_blocks && !do_reset_timeout && gcode.stepper_inactive_timeout()) {
|
|
|
|
if (!already_shutdown_steppers) {
|
2022-07-14 05:16:22 +02:00
|
|
|
already_shutdown_steppers = true;
|
2022-06-01 00:09:44 +02:00
|
|
|
|
|
|
|
// 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));
|
2022-04-29 22:21:15 +02:00
|
|
|
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));
|
2022-06-01 00:09:44 +02:00
|
|
|
TERN_(DISABLE_INACTIVE_E, stepper.disable_e_steppers());
|
|
|
|
|
|
|
|
TERN_(AUTO_BED_LEVELING_UBL, bedlevel.steppers_were_disabled());
|
|
|
|
}
|
2019-01-24 02:06:54 +01:00
|
|
|
}
|
2022-06-01 00:09:44 +02:00
|
|
|
else
|
|
|
|
already_shutdown_steppers = false;
|
2018-03-22 01:30:06 +01:00
|
|
|
}
|
2022-06-01 00:09:44 +02:00
|
|
|
#endif
|
2015-03-07 21:43:15 +01:00
|
|
|
|
2021-04-19 00:12:56 +02:00
|
|
|
#if ENABLED(PHOTO_GCODE) && PIN_EXISTS(CHDK)
|
|
|
|
// Check if CHDK should be set to LOW (after M240 set it HIGH)
|
2021-01-21 10:40:07 +01:00
|
|
|
extern millis_t chdk_timeout;
|
2019-02-14 22:09:35 +01:00
|
|
|
if (chdk_timeout && ELAPSED(ms, chdk_timeout)) {
|
|
|
|
chdk_timeout = 0;
|
2018-11-05 08:08:40 +01:00
|
|
|
WRITE(CHDK_PIN, LOW);
|
2014-03-10 21:57:08 +01:00
|
|
|
}
|
|
|
|
#endif
|
2015-04-04 00:31:35 +02:00
|
|
|
|
|
|
|
#if HAS_KILL
|
2015-08-05 13:40:36 +02:00
|
|
|
|
2014-12-28 19:54:06 +01:00
|
|
|
// Check if the kill button was pressed and wait just in case it was an accidental
|
|
|
|
// key kill key press
|
|
|
|
// -------------------------------------------------------------------------------
|
2015-04-04 00:45:41 +02:00
|
|
|
static int killCount = 0; // make the inactivity button a bit less responsive
|
|
|
|
const int KILL_DELAY = 750;
|
2020-05-05 10:31:03 +02:00
|
|
|
if (kill_state())
|
2015-10-03 08:08:58 +02:00
|
|
|
killCount++;
|
2014-12-28 19:54:06 +01:00
|
|
|
else if (killCount > 0)
|
2015-10-03 08:08:58 +02:00
|
|
|
killCount--;
|
2015-04-04 00:31:35 +02:00
|
|
|
|
2014-12-28 19:54:06 +01:00
|
|
|
// Exceeded threshold and we can confirm that it was not accidental
|
|
|
|
// KILL the machine
|
|
|
|
// ----------------------------------------------------------------
|
2017-03-14 18:24:46 +01:00
|
|
|
if (killCount >= KILL_DELAY) {
|
2022-04-04 01:44:45 +02:00
|
|
|
SERIAL_ERROR_START();
|
|
|
|
SERIAL_ECHOPGM(STR_KILL_PRE);
|
|
|
|
SERIAL_ECHOLNPGM(STR_KILL_BUTTON);
|
2018-10-19 04:20:56 +02:00
|
|
|
kill();
|
2017-03-14 18:24:46 +01:00
|
|
|
}
|
2012-11-06 12:06:41 +01:00
|
|
|
#endif
|
2014-12-28 19:54:06 +01:00
|
|
|
|
2022-08-25 19:08:03 +02:00
|
|
|
#if ENABLED(FREEZE_FEATURE)
|
2022-03-26 04:44:22 +01:00
|
|
|
stepper.frozen = READ(FREEZE_PIN) == FREEZE_STATE;
|
2021-05-14 07:14:13 +02:00
|
|
|
#endif
|
|
|
|
|
2015-04-04 00:31:35 +02:00
|
|
|
#if HAS_HOME
|
2019-06-27 22:07:45 +02:00
|
|
|
// Handle a standalone HOME button
|
|
|
|
constexpr millis_t HOME_DEBOUNCE_DELAY = 1000UL;
|
|
|
|
static millis_t next_home_key_ms; // = 0
|
|
|
|
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;
|
2021-09-26 00:05:11 +02:00
|
|
|
LCD_MESSAGE(MSG_AUTO_HOME);
|
2020-12-07 12:53:15 +01:00
|
|
|
queue.inject_P(G28_STR);
|
2015-04-04 00:31:35 +02:00
|
|
|
}
|
2014-12-28 19:54:06 +01:00
|
|
|
}
|
2015-04-04 00:31:35 +02:00
|
|
|
#endif
|
2015-08-05 13:40:36 +02:00
|
|
|
|
2021-03-01 15:03:41 +01:00
|
|
|
#if ENABLED(CUSTOM_USER_BUTTONS)
|
|
|
|
// Handle a custom user button if defined
|
|
|
|
const bool printer_not_busy = !printingIsActive();
|
2021-07-12 07:15:48 +02:00
|
|
|
#define HAS_CUSTOM_USER_BUTTON(N) (PIN_EXISTS(BUTTON##N) && defined(BUTTON##N##_HIT_STATE) && defined(BUTTON##N##_GCODE))
|
|
|
|
#define HAS_BETTER_USER_BUTTON(N) HAS_CUSTOM_USER_BUTTON(N) && defined(BUTTON##N##_DESC)
|
|
|
|
#define _CHECK_CUSTOM_USER_BUTTON(N, CODE) do{ \
|
2021-03-01 15:03:41 +01:00
|
|
|
constexpr millis_t CUB_DEBOUNCE_DELAY_##N = 250UL; \
|
|
|
|
static millis_t next_cub_ms_##N; \
|
|
|
|
if (BUTTON##N##_HIT_STATE == READ(BUTTON##N##_PIN) \
|
|
|
|
&& (ENABLED(BUTTON##N##_WHEN_PRINTING) || printer_not_busy)) { \
|
|
|
|
if (ELAPSED(ms, next_cub_ms_##N)) { \
|
|
|
|
next_cub_ms_##N = ms + CUB_DEBOUNCE_DELAY_##N; \
|
2021-07-12 07:15:48 +02:00
|
|
|
CODE; \
|
2021-09-26 04:11:31 +02:00
|
|
|
queue.inject(F(BUTTON##N##_GCODE)); \
|
2022-01-25 22:33:03 +01:00
|
|
|
TERN_(HAS_MARLINUI_MENU, ui.quick_feedback()); \
|
2021-03-01 15:03:41 +01:00
|
|
|
} \
|
|
|
|
} \
|
|
|
|
}while(0)
|
|
|
|
|
2021-09-26 00:05:11 +02:00
|
|
|
#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))
|
2021-07-12 07:15:48 +02:00
|
|
|
|
|
|
|
#if HAS_BETTER_USER_BUTTON(1)
|
|
|
|
CHECK_BETTER_USER_BUTTON(1);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(1)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(1);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(2)
|
|
|
|
CHECK_BETTER_USER_BUTTON(2);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(2)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(2);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(3)
|
|
|
|
CHECK_BETTER_USER_BUTTON(3);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(3)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(3);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(4)
|
|
|
|
CHECK_BETTER_USER_BUTTON(4);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(4)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(4);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(5)
|
|
|
|
CHECK_BETTER_USER_BUTTON(5);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(5)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(5);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(6)
|
|
|
|
CHECK_BETTER_USER_BUTTON(6);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(6)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(6);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(7)
|
|
|
|
CHECK_BETTER_USER_BUTTON(7);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(7)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(7);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(8)
|
|
|
|
CHECK_BETTER_USER_BUTTON(8);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(8)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(8);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(9)
|
|
|
|
CHECK_BETTER_USER_BUTTON(9);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(9)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(9);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(10)
|
|
|
|
CHECK_BETTER_USER_BUTTON(10);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(10)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(10);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(11)
|
|
|
|
CHECK_BETTER_USER_BUTTON(11);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(11)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(11);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(12)
|
|
|
|
CHECK_BETTER_USER_BUTTON(12);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(12)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(12);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(13)
|
|
|
|
CHECK_BETTER_USER_BUTTON(13);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(13)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(13);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(14)
|
|
|
|
CHECK_BETTER_USER_BUTTON(14);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(14)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(14);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(15)
|
|
|
|
CHECK_BETTER_USER_BUTTON(15);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(15)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(15);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(16)
|
|
|
|
CHECK_BETTER_USER_BUTTON(16);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(16)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(16);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(17)
|
|
|
|
CHECK_BETTER_USER_BUTTON(17);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(17)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(17);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(18)
|
|
|
|
CHECK_BETTER_USER_BUTTON(18);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(18)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(18);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(19)
|
|
|
|
CHECK_BETTER_USER_BUTTON(19);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(19)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(19);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(20)
|
|
|
|
CHECK_BETTER_USER_BUTTON(20);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(20)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(20);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(21)
|
|
|
|
CHECK_BETTER_USER_BUTTON(21);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(21)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(21);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(22)
|
|
|
|
CHECK_BETTER_USER_BUTTON(22);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(22)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(22);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(23)
|
|
|
|
CHECK_BETTER_USER_BUTTON(23);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(23)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(23);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(24)
|
|
|
|
CHECK_BETTER_USER_BUTTON(24);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(24)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(24);
|
|
|
|
#endif
|
2021-07-12 07:15:48 +02:00
|
|
|
#if HAS_BETTER_USER_BUTTON(25)
|
|
|
|
CHECK_BETTER_USER_BUTTON(25);
|
|
|
|
#elif HAS_CUSTOM_USER_BUTTON(25)
|
2021-03-01 15:03:41 +01:00
|
|
|
CHECK_CUSTOM_USER_BUTTON(25);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2021-11-23 22:52:18 +01:00
|
|
|
TERN_(EASYTHREED_UI, easythreed_ui.run());
|
|
|
|
|
2020-04-22 23:35:03 +02:00
|
|
|
TERN_(USE_CONTROLLER_FAN, controllerFan.update()); // Check if fan should be turned on to cool stepper drivers down
|
2015-04-04 00:31:35 +02:00
|
|
|
|
2021-06-29 19:58:11 +02:00
|
|
|
TERN_(AUTO_POWER_CONTROL, powerManager.check(!ui.on_status_screen() || printJobOngoing() || printingIsPaused()));
|
2018-02-19 23:12:04 +01:00
|
|
|
|
2020-05-18 07:50:35 +02:00
|
|
|
TERN_(HOTEND_IDLE_TIMEOUT, hotend_idle.check());
|
|
|
|
|
2015-07-31 07:24:43 +02:00
|
|
|
#if ENABLED(EXTRUDER_RUNOUT_PREVENT)
|
2021-04-24 02:06:55 +02:00
|
|
|
if (thermalManager.degHotend(active_extruder) > (EXTRUDER_RUNOUT_MINTEMP)
|
2020-04-04 02:49:45 +02:00
|
|
|
&& ELAPSED(ms, gcode.previous_move_ms + SEC_TO_MS(EXTRUDER_RUNOUT_SECONDS))
|
2018-03-22 01:30:06 +01:00
|
|
|
&& !planner.has_blocks_queued()
|
2018-02-09 10:32:40 +01:00
|
|
|
) {
|
2016-06-29 00:06:56 +02:00
|
|
|
#if ENABLED(SWITCHING_EXTRUDER)
|
2018-05-28 00:56:21 +02:00
|
|
|
bool oldstatus;
|
|
|
|
switch (active_extruder) {
|
2021-09-28 08:07:51 +02:00
|
|
|
default: oldstatus = stepper.AXIS_IS_ENABLED(E_AXIS, 0); stepper.ENABLE_EXTRUDER(0); break;
|
2018-05-28 00:56:21 +02:00
|
|
|
#if E_STEPPERS > 1
|
2021-09-28 08:07:51 +02:00
|
|
|
case 2: case 3: oldstatus = stepper.AXIS_IS_ENABLED(E_AXIS, 1); stepper.ENABLE_EXTRUDER(1); break;
|
2018-05-28 00:56:21 +02:00
|
|
|
#if E_STEPPERS > 2
|
2021-09-28 08:07:51 +02:00
|
|
|
case 4: case 5: oldstatus = stepper.AXIS_IS_ENABLED(E_AXIS, 2); stepper.ENABLE_EXTRUDER(2); break;
|
2020-02-01 22:18:01 +01:00
|
|
|
#if E_STEPPERS > 3
|
2021-09-28 08:07:51 +02:00
|
|
|
case 6: case 7: oldstatus = stepper.AXIS_IS_ENABLED(E_AXIS, 3); stepper.ENABLE_EXTRUDER(3); break;
|
2020-02-01 22:18:01 +01:00
|
|
|
#endif // E_STEPPERS > 3
|
2018-05-28 00:56:21 +02:00
|
|
|
#endif // E_STEPPERS > 2
|
|
|
|
#endif // E_STEPPERS > 1
|
|
|
|
}
|
2016-06-29 00:06:56 +02:00
|
|
|
#else // !SWITCHING_EXTRUDER
|
2017-07-06 19:10:06 +02:00
|
|
|
bool oldstatus;
|
2015-10-03 08:08:58 +02:00
|
|
|
switch (active_extruder) {
|
2019-11-10 00:59:04 +01:00
|
|
|
default:
|
2021-09-28 08:07:51 +02:00
|
|
|
#define _CASE_EN(N) case N: oldstatus = stepper.AXIS_IS_ENABLED(E_AXIS, N); stepper.ENABLE_EXTRUDER(N); break;
|
2019-11-10 00:59:04 +01:00
|
|
|
REPEAT(E_STEPPERS, _CASE_EN);
|
2015-10-03 08:08:58 +02:00
|
|
|
}
|
2019-11-10 00:59:04 +01:00
|
|
|
#endif
|
2016-06-29 00:06:56 +02:00
|
|
|
|
2019-09-29 11:25:39 +02:00
|
|
|
const float olde = current_position.e;
|
|
|
|
current_position.e += EXTRUDER_RUNOUT_EXTRUDE;
|
|
|
|
line_to_current_position(MMM_TO_MMS(EXTRUDER_RUNOUT_SPEED));
|
|
|
|
current_position.e = olde;
|
2017-03-20 22:41:59 +01:00
|
|
|
planner.set_e_position_mm(olde);
|
2018-05-12 08:38:02 +02:00
|
|
|
planner.synchronize();
|
2018-05-28 00:56:21 +02:00
|
|
|
|
2016-06-29 00:06:56 +02:00
|
|
|
#if ENABLED(SWITCHING_EXTRUDER)
|
2018-05-28 00:56:21 +02:00
|
|
|
switch (active_extruder) {
|
2021-09-28 08:07:51 +02:00
|
|
|
default: if (oldstatus) stepper.ENABLE_EXTRUDER(0); else stepper.DISABLE_EXTRUDER(0); break;
|
2018-05-28 00:56:21 +02:00
|
|
|
#if E_STEPPERS > 1
|
2021-09-28 08:07:51 +02:00
|
|
|
case 2: case 3: if (oldstatus) stepper.ENABLE_EXTRUDER(1); else stepper.DISABLE_EXTRUDER(1); break;
|
2018-05-28 00:56:21 +02:00
|
|
|
#if E_STEPPERS > 2
|
2021-09-28 08:07:51 +02:00
|
|
|
case 4: case 5: if (oldstatus) stepper.ENABLE_EXTRUDER(2); else stepper.DISABLE_EXTRUDER(2); break;
|
2018-05-28 00:56:21 +02:00
|
|
|
#endif // E_STEPPERS > 2
|
|
|
|
#endif // E_STEPPERS > 1
|
|
|
|
}
|
|
|
|
#else // !SWITCHING_EXTRUDER
|
2016-06-29 00:06:56 +02:00
|
|
|
switch (active_extruder) {
|
2021-09-28 08:07:51 +02:00
|
|
|
#define _CASE_RESTORE(N) case N: if (oldstatus) stepper.ENABLE_EXTRUDER(N); else stepper.DISABLE_EXTRUDER(N); break;
|
2019-11-10 00:59:04 +01:00
|
|
|
REPEAT(E_STEPPERS, _CASE_RESTORE);
|
2016-06-29 00:06:56 +02:00
|
|
|
}
|
|
|
|
#endif // !SWITCHING_EXTRUDER
|
2018-03-22 01:30:06 +01:00
|
|
|
|
2020-07-01 23:27:28 +02:00
|
|
|
gcode.reset_stepper_timeout(ms);
|
2012-11-06 12:06:41 +01:00
|
|
|
}
|
2016-06-29 00:06:56 +02:00
|
|
|
#endif // EXTRUDER_RUNOUT_PREVENT
|
2015-04-04 00:31:35 +02:00
|
|
|
|
2015-07-31 07:24:43 +02:00
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
2013-08-07 16:10:26 +02:00
|
|
|
// handle delayed move timeout
|
2021-01-04 05:22:21 +01:00
|
|
|
if (delayed_move_time && ELAPSED(ms, delayed_move_time) && IsRunning()) {
|
2013-08-07 16:10:26 +02:00
|
|
|
// travel moves have been received so enact them
|
|
|
|
delayed_move_time = 0xFFFFFFFFUL; // force moves to be done
|
2019-09-29 11:25:39 +02:00
|
|
|
destination = current_position;
|
2020-03-01 23:59:04 +01:00
|
|
|
prepare_line_to_destination();
|
2021-01-04 05:07:29 +01:00
|
|
|
planner.synchronize();
|
2013-08-07 16:10:26 +02:00
|
|
|
}
|
2013-10-20 12:12:35 +02:00
|
|
|
#endif
|
2015-04-04 00:31:35 +02:00
|
|
|
|
2020-04-22 23:35:03 +02:00
|
|
|
TERN_(TEMP_STAT_LEDS, handle_status_leds());
|
2015-04-04 00:31:35 +02:00
|
|
|
|
2020-04-22 23:35:03 +02:00
|
|
|
TERN_(MONITOR_DRIVER_STATUS, monitor_tmc_drivers());
|
2017-03-07 06:00:43 +01:00
|
|
|
|
2017-11-16 02:01:52 +01:00
|
|
|
// Limit check_axes_activity frequency to 10Hz
|
|
|
|
static millis_t next_check_axes_ms = 0;
|
|
|
|
if (ELAPSED(ms, next_check_axes_ms)) {
|
|
|
|
planner.check_axes_activity();
|
|
|
|
next_check_axes_ms = ms + 100UL;
|
|
|
|
}
|
2019-02-27 04:03:13 +01:00
|
|
|
|
|
|
|
#if PIN_EXISTS(FET_SAFETY)
|
|
|
|
static millis_t FET_next;
|
|
|
|
if (ELAPSED(ms, FET_next)) {
|
2020-01-09 03:00:06 +01:00
|
|
|
FET_next = ms + FET_SAFETY_DELAY; // 2µs pulse every FET_SAFETY_DELAY mS
|
2019-02-27 04:03:13 +01:00
|
|
|
OUT_WRITE(FET_SAFETY_PIN, !FET_SAFETY_INVERTED);
|
|
|
|
DELAY_US(2);
|
|
|
|
WRITE(FET_SAFETY_PIN, FET_SAFETY_INVERTED);
|
|
|
|
}
|
|
|
|
#endif
|
2012-11-06 12:06:41 +01:00
|
|
|
}
|
|
|
|
|
2016-09-13 09:11:45 +02:00
|
|
|
/**
|
2020-04-04 07:08:25 +02:00
|
|
|
* Standard idle routine keeps the machine alive:
|
|
|
|
* - Core Marlin activities
|
|
|
|
* - Manage heaters (and Watchdog)
|
|
|
|
* - Max7219 heartbeat, animation, etc.
|
|
|
|
*
|
|
|
|
* Only after setup() is complete:
|
|
|
|
* - Handle filament runout sensors
|
|
|
|
* - Run HAL idle tasks
|
|
|
|
* - Handle Power-Loss Recovery
|
|
|
|
* - Run StallGuard endstop checks
|
|
|
|
* - Handle SD Card insert / remove
|
|
|
|
* - Handle USB Flash Drive insert / remove
|
|
|
|
* - Announce Host Keepalive state (if any)
|
|
|
|
* - Update the Print Job Timer state
|
|
|
|
* - Update the Beeper queue
|
|
|
|
* - Read Buttons and Update the LCD
|
|
|
|
* - Run i2c Position Encoders
|
|
|
|
* - Auto-report Temperatures / SD Status
|
2020-08-26 09:15:43 +02:00
|
|
|
* - Update the Průša MMU2
|
2020-04-04 07:08:25 +02:00
|
|
|
* - Handle Joystick jogging
|
2016-09-13 09:11:45 +02:00
|
|
|
*/
|
2021-06-15 01:44:27 +02:00
|
|
|
void idle(bool no_stepper_sleep/*=false*/) {
|
2022-06-26 07:38:23 +02:00
|
|
|
#ifdef MAX7219_DEBUG_PROFILE
|
|
|
|
CodeProfiler idle_profiler;
|
|
|
|
#endif
|
|
|
|
|
2020-12-07 11:04:38 +01:00
|
|
|
#if ENABLED(MARLIN_DEV_MODE)
|
2021-02-01 00:21:27 +01:00
|
|
|
static uint16_t idle_depth = 0;
|
2021-09-09 11:57:05 +02:00
|
|
|
if (++idle_depth > 5) SERIAL_ECHOLNPGM("idle() call depth: ", idle_depth);
|
2020-12-07 11:04:38 +01:00
|
|
|
#endif
|
2020-04-04 07:08:25 +02:00
|
|
|
|
2022-08-06 08:14:58 +02:00
|
|
|
// Bed Distance Sensor task
|
|
|
|
TERN_(BD_SENSOR, bdl.process());
|
|
|
|
|
2020-04-04 07:08:25 +02:00
|
|
|
// Core Marlin activities
|
2021-06-15 01:44:27 +02:00
|
|
|
manage_inactivity(no_stepper_sleep);
|
2020-04-04 07:08:25 +02:00
|
|
|
|
|
|
|
// Manage Heaters (and Watchdog)
|
2022-07-03 17:32:47 +02:00
|
|
|
thermalManager.task();
|
2020-04-04 07:08:25 +02:00
|
|
|
|
|
|
|
// Max7219 heartbeat, animation, etc
|
2020-04-22 23:35:03 +02:00
|
|
|
TERN_(MAX7219_DEBUG, max7219.idle_tasks());
|
2020-04-04 07:08:25 +02:00
|
|
|
|
|
|
|
// Return if setup() isn't completed
|
2020-12-07 11:04:38 +01:00
|
|
|
if (marlin_state == MF_INITIALIZING) goto IDLE_DONE;
|
2020-04-04 07:08:25 +02:00
|
|
|
|
2021-04-16 15:02:31 +02:00
|
|
|
// TODO: Still causing errors
|
|
|
|
(void)check_tool_sensor_stats(active_extruder, true);
|
|
|
|
|
2020-04-04 07:08:25 +02:00
|
|
|
// Handle filament runout sensors
|
2021-12-14 01:47:57 +01:00
|
|
|
#if HAS_FILAMENT_SENSOR
|
|
|
|
if (TERN1(HAS_PRUSA_MMU2, !mmu2.enabled()))
|
|
|
|
runout.run();
|
|
|
|
#endif
|
2020-04-04 07:08:25 +02:00
|
|
|
|
|
|
|
// Run HAL idle tasks
|
2022-02-18 01:50:31 +01:00
|
|
|
hal.idletask();
|
2020-04-04 07:08:25 +02:00
|
|
|
|
2020-10-20 21:35:29 +02:00
|
|
|
// Check network connection
|
|
|
|
TERN_(HAS_ETHERNET, ethernet.check());
|
|
|
|
|
2020-04-02 08:22:48 +02:00
|
|
|
// Handle Power-Loss Recovery
|
2019-09-11 01:52:41 +02:00
|
|
|
#if ENABLED(POWER_LOSS_RECOVERY) && PIN_EXISTS(POWER_LOSS)
|
2021-05-08 11:35:35 +02:00
|
|
|
if (IS_SD_PRINTING()) recovery.outage();
|
2019-09-11 01:52:41 +02:00
|
|
|
#endif
|
2019-08-05 05:22:58 +02:00
|
|
|
|
2020-04-02 08:22:48 +02:00
|
|
|
// Run StallGuard endstop checks
|
2019-08-05 05:22:58 +02:00
|
|
|
#if ENABLED(SPI_ENDSTOPS)
|
2021-07-13 02:19:29 +02:00
|
|
|
if (endstops.tmc_spi_homing.any && TERN1(IMPROVE_HOMING_RELIABILITY, ELAPSED(millis(), sg_guard_period)))
|
|
|
|
LOOP_L_N(i, 4) if (endstops.tmc_spi_homing_check()) break; // Read SGT 4 times per idle loop
|
2019-08-05 05:22:58 +02:00
|
|
|
#endif
|
|
|
|
|
2020-04-04 07:08:25 +02:00
|
|
|
// Handle SD Card insert / remove
|
2020-04-22 23:35:03 +02:00
|
|
|
TERN_(SDSUPPORT, card.manage_media());
|
2017-08-26 00:03:07 +02:00
|
|
|
|
2020-04-04 07:08:25 +02:00
|
|
|
// Handle USB Flash Drive insert / remove
|
2021-04-14 00:34:19 +02:00
|
|
|
TERN_(USB_FLASH_DRIVE_SUPPORT, card.diskIODriver()->idle());
|
2016-11-09 01:03:40 +01:00
|
|
|
|
2020-04-02 08:22:48 +02:00
|
|
|
// Announce Host Keepalive state (if any)
|
2020-04-22 23:35:03 +02:00
|
|
|
TERN_(HOST_KEEPALIVE_FEATURE, gcode.host_keepalive());
|
2016-11-09 01:03:40 +01:00
|
|
|
|
2020-04-02 08:22:48 +02:00
|
|
|
// Update the Print Job Timer state
|
2020-04-22 23:35:03 +02:00
|
|
|
TERN_(PRINTCOUNTER, print_job_timer.tick());
|
2016-09-13 09:11:45 +02:00
|
|
|
|
2020-04-02 08:22:48 +02:00
|
|
|
// Update the Beeper queue
|
2022-05-12 04:23:16 +02:00
|
|
|
TERN_(HAS_BEEPER, buzzer.tick());
|
2017-06-09 14:06:23 +02:00
|
|
|
|
2020-06-21 09:40:16 +02:00
|
|
|
// Handle UI input / draw events
|
2022-03-11 21:06:49 +01:00
|
|
|
TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update());
|
2020-04-04 07:08:25 +02:00
|
|
|
|
2020-04-02 08:22:48 +02:00
|
|
|
// Run i2c Position Encoders
|
2017-06-09 14:06:23 +02:00
|
|
|
#if ENABLED(I2C_POSITION_ENCODERS)
|
2020-12-07 11:04:38 +01:00
|
|
|
{
|
2018-02-08 10:57:11 +01:00
|
|
|
static millis_t i2cpem_next_update_ms;
|
2019-07-24 08:52:36 +02:00
|
|
|
if (planner.has_blocks_queued()) {
|
|
|
|
const millis_t ms = millis();
|
|
|
|
if (ELAPSED(ms, i2cpem_next_update_ms)) {
|
|
|
|
I2CPEM.update();
|
|
|
|
i2cpem_next_update_ms = ms + I2CPE_MIN_UPD_TIME_MS;
|
|
|
|
}
|
2017-06-09 14:06:23 +02:00
|
|
|
}
|
2020-12-07 11:04:38 +01:00
|
|
|
}
|
2017-06-09 14:06:23 +02:00
|
|
|
#endif
|
2017-12-21 06:22:08 +01:00
|
|
|
|
2020-04-02 08:22:48 +02:00
|
|
|
// Auto-report Temperatures / SD Status
|
2018-03-07 08:57:09 +01:00
|
|
|
#if HAS_AUTO_REPORTING
|
2020-02-21 03:09:37 +01:00
|
|
|
if (!gcode.autoreport_paused) {
|
2021-01-29 03:40:20 +01:00
|
|
|
TERN_(AUTO_REPORT_TEMPERATURES, thermalManager.auto_reporter.tick());
|
2021-11-23 21:01:53 +01:00
|
|
|
TERN_(AUTO_REPORT_FANS, fan_check.auto_reporter.tick());
|
2021-01-29 03:40:20 +01:00
|
|
|
TERN_(AUTO_REPORT_SD_STATUS, card.auto_reporter.tick());
|
2021-05-15 22:02:20 +02:00
|
|
|
TERN_(AUTO_REPORT_POSITION, position_auto_reporter.tick());
|
2021-07-23 05:53:00 +02:00
|
|
|
TERN_(BUFFER_MONITORING, queue.auto_report_buffer_statistics());
|
2018-03-07 08:57:09 +01:00
|
|
|
}
|
|
|
|
#endif
|
2018-07-02 17:06:17 +02:00
|
|
|
|
2020-08-26 09:15:43 +02:00
|
|
|
// Update the Průša MMU2
|
2020-11-18 08:27:21 +01:00
|
|
|
TERN_(HAS_PRUSA_MMU2, mmu2.mmu_loop());
|
2019-09-08 07:55:34 +02:00
|
|
|
|
2020-04-02 08:22:48 +02:00
|
|
|
// Handle Joystick jogging
|
2020-04-22 23:35:03 +02:00
|
|
|
TERN_(POLL_JOG, joystick.inject_jog_moves());
|
2020-05-12 02:22:41 +02:00
|
|
|
|
|
|
|
// Direct Stepping
|
|
|
|
TERN_(DIRECT_STEPPING, page_manager.write_responses());
|
2020-06-16 04:05:33 +02:00
|
|
|
|
2020-11-18 08:27:21 +01:00
|
|
|
// Update the LVGL interface
|
|
|
|
TERN_(HAS_TFT_LVGL_UI, LV_TASK_HANDLER());
|
2020-12-07 11:04:38 +01:00
|
|
|
|
|
|
|
IDLE_DONE:
|
|
|
|
TERN_(MARLIN_DEV_MODE, idle_depth--);
|
|
|
|
return;
|
2016-09-13 09:11:45 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Kill all activity and lock the machine.
|
|
|
|
* After this the machine will need to be reset.
|
|
|
|
*/
|
2021-09-29 03:15:52 +02:00
|
|
|
void kill(FSTR_P const lcd_error/*=nullptr*/, FSTR_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) {
|
2017-03-21 15:06:01 +01:00
|
|
|
thermalManager.disable_all_heaters();
|
2017-03-29 02:45:54 +02:00
|
|
|
|
2020-04-22 23:35:03 +02:00
|
|
|
TERN_(HAS_CUTTER, cutter.kill()); // Full cutter shutdown including ISR control
|
2020-04-03 02:31:08 +02:00
|
|
|
|
2021-05-06 00:22:46 +02:00
|
|
|
// Echo the LCD message to serial for extra context
|
2021-09-29 03:15:52 +02:00
|
|
|
if (lcd_error) { SERIAL_ECHO_START(); SERIAL_ECHOLNF(lcd_error); }
|
2018-10-19 20:30:37 +02:00
|
|
|
|
2022-05-17 22:05:25 +02:00
|
|
|
#if HAS_DISPLAY
|
2021-09-29 03:15:52 +02:00
|
|
|
ui.kill_screen(lcd_error ?: GET_TEXT_F(MSG_KILLED), lcd_component ?: FPSTR(NUL_STR));
|
2015-10-04 17:33:55 +02:00
|
|
|
#else
|
2021-05-06 00:22:46 +02:00
|
|
|
UNUSED(lcd_error); UNUSED(lcd_component);
|
2015-05-20 22:03:16 +02:00
|
|
|
#endif
|
2015-05-20 20:53:48 +02:00
|
|
|
|
2021-05-06 00:22:46 +02:00
|
|
|
TERN_(HAS_TFT_LVGL_UI, lv_draw_error_message(lcd_error));
|
|
|
|
|
|
|
|
// "Error:Printer halted. kill() called!"
|
|
|
|
SERIAL_ERROR_MSG(STR_ERR_KILLED);
|
2020-09-21 03:55:02 +02:00
|
|
|
|
2017-07-28 06:42:01 +02:00
|
|
|
#ifdef ACTION_ON_KILL
|
2021-10-15 07:24:08 +02:00
|
|
|
hostui.kill();
|
2017-07-02 10:44:24 +02:00
|
|
|
#endif
|
2017-07-07 04:24:30 +02:00
|
|
|
|
2019-08-28 07:51:01 +02:00
|
|
|
minkill(steppers_off);
|
2018-10-19 04:20:56 +02:00
|
|
|
}
|
|
|
|
|
2019-08-28 07:51:01 +02:00
|
|
|
void minkill(const bool steppers_off/*=false*/) {
|
2018-10-19 04:20:56 +02:00
|
|
|
|
2018-10-20 08:44:46 +02:00
|
|
|
// Wait a short time (allows messages to get out before shutting down.
|
2018-10-21 20:43:21 +02:00
|
|
|
for (int i = 1000; i--;) DELAY_US(600);
|
2018-10-20 08:44:46 +02:00
|
|
|
|
|
|
|
cli(); // Stop interrupts
|
|
|
|
|
|
|
|
// Wait to ensure all interrupts stopped
|
2018-10-21 20:43:21 +02:00
|
|
|
for (int i = 1000; i--;) DELAY_US(250);
|
2018-10-19 04:20:56 +02:00
|
|
|
|
2019-08-28 07:51:01 +02:00
|
|
|
// Reiterate heaters off
|
|
|
|
thermalManager.disable_all_heaters();
|
|
|
|
|
2020-04-22 23:35:03 +02:00
|
|
|
TERN_(HAS_CUTTER, cutter.kill()); // Reiterate cutter shutdown
|
2020-04-03 02:31:08 +02:00
|
|
|
|
2019-08-28 07:51:01 +02:00
|
|
|
// Power off all steppers (for M112) or just the E steppers
|
2021-09-28 08:07:51 +02:00
|
|
|
steppers_off ? stepper.disable_all_steppers() : stepper.disable_e_steppers();
|
2018-10-19 04:20:56 +02:00
|
|
|
|
2021-07-12 07:13:58 +02:00
|
|
|
TERN_(PSU_CONTROL, powerManager.power_off());
|
2015-03-31 01:50:05 +02:00
|
|
|
|
2020-04-22 23:35:03 +02:00
|
|
|
TERN_(HAS_SUICIDE, suicide());
|
2017-09-27 11:40:48 +02:00
|
|
|
|
2021-04-24 09:53:52 +02:00
|
|
|
#if EITHER(HAS_KILL, SOFT_RESET_ON_KILL)
|
2019-03-10 15:57:38 +01:00
|
|
|
|
2021-04-24 09:53:52 +02:00
|
|
|
// Wait for both KILL and ENC to be released
|
2021-07-10 01:25:47 +02:00
|
|
|
while (TERN0(HAS_KILL, kill_state()) || TERN0(SOFT_RESET_ON_KILL, ui.button_pressed()))
|
2022-05-23 03:45:37 +02:00
|
|
|
hal.watchdog_refresh();
|
2019-03-10 15:57:38 +01:00
|
|
|
|
2021-07-10 01:25:47 +02:00
|
|
|
// Wait for either KILL or ENC to be pressed again
|
|
|
|
while (TERN1(HAS_KILL, !kill_state()) && TERN1(SOFT_RESET_ON_KILL, !ui.button_pressed()))
|
2022-05-23 03:45:37 +02:00
|
|
|
hal.watchdog_refresh();
|
2019-03-10 15:57:38 +01:00
|
|
|
|
2021-04-24 09:53:52 +02:00
|
|
|
// Reboot the board
|
2022-02-18 01:50:31 +01:00
|
|
|
hal.reboot();
|
2019-03-10 15:57:38 +01:00
|
|
|
|
2020-04-03 02:31:08 +02:00
|
|
|
#else
|
2019-03-10 15:57:38 +01:00
|
|
|
|
2022-05-23 03:45:37 +02:00
|
|
|
for (;;) hal.watchdog_refresh(); // Wait for RESET button or power-cycle
|
2019-03-10 15:57:38 +01:00
|
|
|
|
2020-04-03 02:31:08 +02:00
|
|
|
#endif
|
2012-11-06 12:06:41 +01:00
|
|
|
}
|
|
|
|
|
2016-09-13 09:11:45 +02:00
|
|
|
/**
|
|
|
|
* Turn off heaters and stop the print in progress
|
|
|
|
* After a stop the machine may be resumed with M999
|
|
|
|
*/
|
2016-04-18 09:05:22 +02:00
|
|
|
void stop() {
|
2017-05-07 13:06:06 +02:00
|
|
|
thermalManager.disable_all_heaters(); // 'unpause' taken care of in here
|
2021-01-25 15:32:58 +01:00
|
|
|
|
2018-10-19 04:20:56 +02:00
|
|
|
print_job_timer.stop();
|
2017-05-07 13:06:06 +02:00
|
|
|
|
2021-03-18 01:23:36 +01:00
|
|
|
#if EITHER(PROBING_FANS_OFF, ADVANCED_PAUSE_FANS_PAUSE)
|
|
|
|
thermalManager.set_fans_paused(false); // Un-pause fans for safety
|
2017-05-07 13:06:06 +02:00
|
|
|
#endif
|
|
|
|
|
2021-05-08 11:35:35 +02:00
|
|
|
if (!IsStopped()) {
|
2020-02-26 10:02:03 +01:00
|
|
|
SERIAL_ERROR_MSG(STR_ERR_STOPPED);
|
2021-09-26 00:05:11 +02:00
|
|
|
LCD_MESSAGE(MSG_STOPPED);
|
2017-04-01 07:23:14 +02:00
|
|
|
safe_delay(350); // allow enough time for messages to get out before stopping
|
2020-03-15 00:47:44 +01:00
|
|
|
marlin_state = MF_STOPPED;
|
2012-11-06 12:06:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-25 04:19:04 +02:00
|
|
|
inline void tmc_standby_setup() {
|
|
|
|
#if PIN_EXISTS(X_STDBY)
|
|
|
|
SET_INPUT_PULLDOWN(X_STDBY_PIN);
|
|
|
|
#endif
|
|
|
|
#if PIN_EXISTS(X2_STDBY)
|
|
|
|
SET_INPUT_PULLDOWN(X2_STDBY_PIN);
|
|
|
|
#endif
|
|
|
|
#if PIN_EXISTS(Y_STDBY)
|
|
|
|
SET_INPUT_PULLDOWN(Y_STDBY_PIN);
|
|
|
|
#endif
|
|
|
|
#if PIN_EXISTS(Y2_STDBY)
|
|
|
|
SET_INPUT_PULLDOWN(Y2_STDBY_PIN);
|
|
|
|
#endif
|
|
|
|
#if PIN_EXISTS(Z_STDBY)
|
|
|
|
SET_INPUT_PULLDOWN(Z_STDBY_PIN);
|
|
|
|
#endif
|
|
|
|
#if PIN_EXISTS(Z2_STDBY)
|
|
|
|
SET_INPUT_PULLDOWN(Z2_STDBY_PIN);
|
|
|
|
#endif
|
|
|
|
#if PIN_EXISTS(Z3_STDBY)
|
|
|
|
SET_INPUT_PULLDOWN(Z3_STDBY_PIN);
|
|
|
|
#endif
|
|
|
|
#if PIN_EXISTS(Z4_STDBY)
|
|
|
|
SET_INPUT_PULLDOWN(Z4_STDBY_PIN);
|
|
|
|
#endif
|
2021-06-05 09:18:47 +02:00
|
|
|
#if PIN_EXISTS(I_STDBY)
|
|
|
|
SET_INPUT_PULLDOWN(I_STDBY_PIN);
|
|
|
|
#endif
|
|
|
|
#if PIN_EXISTS(J_STDBY)
|
|
|
|
SET_INPUT_PULLDOWN(J_STDBY_PIN);
|
|
|
|
#endif
|
|
|
|
#if PIN_EXISTS(K_STDBY)
|
|
|
|
SET_INPUT_PULLDOWN(K_STDBY_PIN);
|
|
|
|
#endif
|
2022-04-29 22:21:15 +02:00
|
|
|
#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
|
2020-09-25 04:19:04 +02:00
|
|
|
#if PIN_EXISTS(E0_STDBY)
|
|
|
|
SET_INPUT_PULLDOWN(E0_STDBY_PIN);
|
|
|
|
#endif
|
|
|
|
#if PIN_EXISTS(E1_STDBY)
|
|
|
|
SET_INPUT_PULLDOWN(E1_STDBY_PIN);
|
|
|
|
#endif
|
|
|
|
#if PIN_EXISTS(E2_STDBY)
|
|
|
|
SET_INPUT_PULLDOWN(E2_STDBY_PIN);
|
|
|
|
#endif
|
|
|
|
#if PIN_EXISTS(E3_STDBY)
|
|
|
|
SET_INPUT_PULLDOWN(E3_STDBY_PIN);
|
|
|
|
#endif
|
|
|
|
#if PIN_EXISTS(E4_STDBY)
|
|
|
|
SET_INPUT_PULLDOWN(E4_STDBY_PIN);
|
|
|
|
#endif
|
|
|
|
#if PIN_EXISTS(E5_STDBY)
|
|
|
|
SET_INPUT_PULLDOWN(E5_STDBY_PIN);
|
|
|
|
#endif
|
|
|
|
#if PIN_EXISTS(E6_STDBY)
|
|
|
|
SET_INPUT_PULLDOWN(E6_STDBY_PIN);
|
|
|
|
#endif
|
|
|
|
#if PIN_EXISTS(E7_STDBY)
|
|
|
|
SET_INPUT_PULLDOWN(E7_STDBY_PIN);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2016-09-12 03:21:54 +02:00
|
|
|
/**
|
2021-03-18 01:24:07 +01:00
|
|
|
* Marlin Firmware entry-point. Abandon Hope All Ye Who Enter Here.
|
|
|
|
* Setup before the program loop:
|
|
|
|
*
|
|
|
|
* - Call any special pre-init set for the board
|
|
|
|
* - Put TMC drivers into Low Power Standby mode
|
|
|
|
* - Init the serial ports (so setup can be debugged)
|
|
|
|
* - Set up the kill and suicide pins
|
|
|
|
* - Prepare (disable) board JTAG and Debug ports
|
|
|
|
* - Init serial for a connected MKS TFT with WiFi
|
|
|
|
* - Install Marlin custom Exception Handlers, if set.
|
|
|
|
* - Init Marlin's HAL interfaces (for SPI, i2c, etc.)
|
|
|
|
* - Init some optional hardware and features:
|
|
|
|
* • MAX Thermocouple pins
|
|
|
|
* • Duet Smart Effector
|
|
|
|
* • Filament Runout Sensor
|
|
|
|
* • TMC220x Stepper Drivers (Serial)
|
|
|
|
* • PSU control
|
|
|
|
* • Power-loss Recovery
|
|
|
|
* • Stepper Driver Reset: DISABLE
|
|
|
|
* • TMC Stepper Drivers (SPI)
|
2022-02-18 01:50:31 +01:00
|
|
|
* • Run hal.init_board() for additional pins setup
|
2021-03-18 01:24:07 +01:00
|
|
|
* • ESP WiFi
|
|
|
|
* - Get the Reset Reason and report it
|
2016-09-12 03:21:54 +02:00
|
|
|
* - Print startup messages and diagnostics
|
2021-03-18 01:24:07 +01:00
|
|
|
* - Calibrate the HAL DELAY for precise timing
|
|
|
|
* - Init the buzzer, possibly a custom timer
|
|
|
|
* - Init more optional hardware:
|
|
|
|
* • Color LED illumination
|
|
|
|
* • Neopixel illumination
|
|
|
|
* • Controller Fan
|
|
|
|
* • Creality DWIN LCD (show boot image)
|
|
|
|
* • Tare the Probe if possible
|
|
|
|
* - Mount the (most likely external) SD Card
|
|
|
|
* - Load settings from EEPROM (or use defaults)
|
|
|
|
* - Init the Ethernet Port
|
|
|
|
* - Init Touch Buttons (for emulated DOGLCD)
|
|
|
|
* - Adjust the (certainly wrong) current position by the home offset
|
|
|
|
* - Init the Planner::position (steps) based on current (native) position
|
|
|
|
* - Initialize more managers and peripherals:
|
|
|
|
* • Temperatures
|
|
|
|
* • Print Job Timer
|
|
|
|
* • Endstops and Endstop Interrupts
|
|
|
|
* • Stepper ISR - Kind of Important!
|
|
|
|
* • Servos
|
|
|
|
* • Servo-based Probe
|
|
|
|
* • Photograph Pin
|
|
|
|
* • Laser/Spindle tool Power / PWM
|
|
|
|
* • Coolant Control
|
|
|
|
* • Bed Probe
|
|
|
|
* • Stepper Driver Reset: ENABLE
|
|
|
|
* • Digipot I2C - Stepper driver current control
|
|
|
|
* • Stepper DAC - Stepper driver current control
|
|
|
|
* • Solenoid (probe, or for other use)
|
|
|
|
* • Home Pin
|
|
|
|
* • Custom User Buttons
|
|
|
|
* • Red/Blue Status LEDs
|
|
|
|
* • Case Light
|
|
|
|
* • Prusa MMU filament changer
|
|
|
|
* • Fan Multiplexer
|
|
|
|
* • Mixing Extruder
|
|
|
|
* • BLTouch Probe
|
|
|
|
* • I2C Position Encoders
|
|
|
|
* • Custom I2C Bus handlers
|
|
|
|
* • Enhanced tools or extruders:
|
|
|
|
* • Switching Extruder
|
|
|
|
* • Switching Nozzle
|
|
|
|
* • Parking Extruder
|
|
|
|
* • Magnetic Parking Extruder
|
|
|
|
* • Switching Toolhead
|
|
|
|
* • Electromagnetic Switching Toolhead
|
|
|
|
* • Watchdog Timer - Also Kind of Important!
|
|
|
|
* • Closed Loop Controller
|
|
|
|
* - Run Startup Commands, if defined
|
|
|
|
* - Tell host to close Host Prompts
|
|
|
|
* - Test Trinamic driver connections
|
|
|
|
* - Init Prusa MMU2 filament changer
|
|
|
|
* - Init and test BL24Cxx EEPROM
|
|
|
|
* - Init Creality DWIN encoder, show faux progress bar
|
|
|
|
* - Reset Status Message / Show Service Messages
|
|
|
|
* - Init MAX7219 LED Matrix
|
|
|
|
* - Init Direct Stepping (Klipper-style motion control)
|
|
|
|
* - Init TFT LVGL UI (with 3D Graphics)
|
|
|
|
* - Apply Password Lock - Hold for Authentication
|
|
|
|
* - Open Touch Screen Calibration screen, if not calibrated
|
|
|
|
* - Set Marlin to RUNNING State
|
2016-09-12 03:21:54 +02:00
|
|
|
*/
|
|
|
|
void setup() {
|
2021-08-09 04:37:27 +02:00
|
|
|
#ifdef FASTIO_INIT
|
|
|
|
FASTIO_INIT();
|
|
|
|
#endif
|
|
|
|
|
2021-02-25 11:35:18 +01:00
|
|
|
#ifdef BOARD_PREINIT
|
|
|
|
BOARD_PREINIT(); // Low-level init (before serial init)
|
|
|
|
#endif
|
2016-09-12 03:21:54 +02:00
|
|
|
|
2020-09-25 04:19:04 +02:00
|
|
|
tmc_standby_setup(); // TMC Low Power Standby pins must be set early or they're not usable
|
|
|
|
|
2021-11-04 18:18:23 +01:00
|
|
|
// Check startup - does nothing if bootloader sets MCUSR to 0
|
2022-02-18 01:50:31 +01:00
|
|
|
const byte mcu = hal.get_reset_source();
|
|
|
|
hal.clear_reset_source();
|
2021-11-04 18:18:23 +01:00
|
|
|
|
2020-04-16 10:36:53 +02:00
|
|
|
#if ENABLED(MARLIN_DEV_MODE)
|
|
|
|
auto log_current_ms = [&](PGM_P const msg) {
|
|
|
|
SERIAL_ECHO_START();
|
2020-06-23 04:12:45 +02:00
|
|
|
SERIAL_CHAR('['); SERIAL_ECHO(millis()); SERIAL_ECHOPGM("] ");
|
2021-03-01 02:43:46 +01:00
|
|
|
SERIAL_ECHOLNPGM_P(msg);
|
2020-04-16 10:36:53 +02:00
|
|
|
};
|
|
|
|
#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)
|
|
|
|
|
2021-03-10 18:35:19 +01:00
|
|
|
MYSERIAL1.begin(BAUDRATE);
|
2021-01-31 23:50:12 +01:00
|
|
|
millis_t serial_connect_timeout = millis() + 1000UL;
|
2021-03-10 18:35:19 +01:00
|
|
|
while (!MYSERIAL1.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
2021-01-31 23:50:12 +01:00
|
|
|
|
|
|
|
#if HAS_MULTI_SERIAL && !HAS_ETHERNET
|
2021-05-20 13:06:26 +02:00
|
|
|
#ifndef BAUDRATE_2
|
|
|
|
#define BAUDRATE_2 BAUDRATE
|
|
|
|
#endif
|
|
|
|
MYSERIAL2.begin(BAUDRATE_2);
|
2021-01-31 23:50:12 +01:00
|
|
|
serial_connect_timeout = millis() + 1000UL;
|
2021-03-10 18:35:19 +01:00
|
|
|
while (!MYSERIAL2.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
2021-05-07 07:31:45 +02:00
|
|
|
#ifdef SERIAL_PORT_3
|
2021-05-20 13:06:26 +02:00
|
|
|
#ifndef BAUDRATE_3
|
|
|
|
#define BAUDRATE_3 BAUDRATE
|
|
|
|
#endif
|
|
|
|
MYSERIAL3.begin(BAUDRATE_3);
|
2021-05-07 07:31:45 +02:00
|
|
|
serial_connect_timeout = millis() + 1000UL;
|
|
|
|
while (!MYSERIAL3.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
|
|
|
#endif
|
2021-01-31 23:50:12 +01:00
|
|
|
#endif
|
|
|
|
SERIAL_ECHOLNPGM("start");
|
|
|
|
|
2021-01-25 15:50:39 +01:00
|
|
|
// Set up these pins early to prevent suicide
|
|
|
|
#if HAS_KILL
|
|
|
|
SETUP_LOG("KILL_PIN");
|
|
|
|
#if KILL_PIN_STATE
|
|
|
|
SET_INPUT_PULLDOWN(KILL_PIN);
|
|
|
|
#else
|
|
|
|
SET_INPUT_PULLUP(KILL_PIN);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2022-03-26 04:44:22 +01:00
|
|
|
#if ENABLED(FREEZE_FEATURE)
|
2021-06-11 23:13:22 +02:00
|
|
|
SETUP_LOG("FREEZE_PIN");
|
2022-03-26 04:44:22 +01:00
|
|
|
#if FREEZE_STATE
|
|
|
|
SET_INPUT_PULLDOWN(FREEZE_PIN);
|
|
|
|
#else
|
|
|
|
SET_INPUT_PULLUP(FREEZE_PIN);
|
|
|
|
#endif
|
2021-05-14 07:14:13 +02:00
|
|
|
#endif
|
|
|
|
|
2021-01-25 15:50:39 +01:00
|
|
|
#if HAS_SUICIDE
|
|
|
|
SETUP_LOG("SUICIDE_PIN");
|
2021-08-13 23:32:25 +02:00
|
|
|
OUT_WRITE(SUICIDE_PIN, !SUICIDE_PIN_STATE);
|
2021-01-25 15:50:39 +01:00
|
|
|
#endif
|
|
|
|
|
2021-06-11 23:13:22 +02:00
|
|
|
#ifdef JTAGSWD_RESET
|
|
|
|
SETUP_LOG("JTAGSWD_RESET");
|
|
|
|
JTAGSWD_RESET();
|
|
|
|
#endif
|
|
|
|
|
2022-02-18 01:50:31 +01:00
|
|
|
// Disable any hardware debug to free up pins for IO
|
|
|
|
#if ENABLED(DISABLE_DEBUG) && defined(JTAGSWD_DISABLE)
|
2021-06-11 23:13:22 +02:00
|
|
|
delay(10);
|
2022-02-18 01:50:31 +01:00
|
|
|
SETUP_LOG("JTAGSWD_DISABLE");
|
|
|
|
JTAGSWD_DISABLE();
|
|
|
|
#elif ENABLED(DISABLE_JTAG) && defined(JTAG_DISABLE)
|
|
|
|
delay(10);
|
|
|
|
SETUP_LOG("JTAG_DISABLE");
|
|
|
|
JTAG_DISABLE();
|
2020-04-12 04:29:52 +02:00
|
|
|
#endif
|
|
|
|
|
2021-02-21 03:22:20 +01:00
|
|
|
TERN_(DYNAMIC_VECTORTABLE, hook_cpu_exceptions()); // If supported, install Marlin exception handlers at runtime
|
|
|
|
|
2022-02-18 01:50:31 +01:00
|
|
|
SETUP_RUN(hal.init());
|
2020-04-12 04:29:52 +02:00
|
|
|
|
2021-02-09 02:51:57 +01:00
|
|
|
// Init and disable SPI thermocouples; this is still needed
|
2022-08-04 09:38:15 +02:00
|
|
|
#if TEMP_SENSOR_IS_MAX_TC(0) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E0))
|
2021-07-07 02:36:41 +02:00
|
|
|
OUT_WRITE(TEMP_0_CS_PIN, HIGH); // Disable
|
2020-11-11 23:27:45 +01:00
|
|
|
#endif
|
2022-08-04 09:38:15 +02:00
|
|
|
#if TEMP_SENSOR_IS_MAX_TC(1) || (TEMP_SENSOR_IS_MAX_TC(REDUNDANT) && REDUNDANT_TEMP_MATCH(SOURCE, E1))
|
2021-07-07 02:36:41 +02:00
|
|
|
OUT_WRITE(TEMP_1_CS_PIN, HIGH);
|
2020-11-11 23:27:45 +01:00
|
|
|
#endif
|
|
|
|
|
2020-08-23 09:07:42 +02:00
|
|
|
#if ENABLED(DUET_SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD)
|
2020-04-12 04:29:52 +02:00
|
|
|
OUT_WRITE(SMART_EFFECTOR_MOD_PIN, LOW); // Put Smart Effector into NORMAL mode
|
2016-09-12 03:21:54 +02:00
|
|
|
#endif
|
|
|
|
|
2019-02-13 03:08:34 +01:00
|
|
|
#if HAS_FILAMENT_SENSOR
|
2020-04-12 04:29:52 +02:00
|
|
|
SETUP_RUN(runout.setup());
|
2016-09-12 03:21:54 +02:00
|
|
|
#endif
|
2021-03-10 18:35:19 +01:00
|
|
|
|
2021-03-10 00:06:00 +01:00
|
|
|
#if HAS_TMC220x
|
|
|
|
SETUP_RUN(tmc_serial_begin());
|
|
|
|
#endif
|
2016-09-12 03:21:54 +02:00
|
|
|
|
2022-06-02 11:22:09 +02:00
|
|
|
#if HAS_TMC_SPI
|
|
|
|
#if DISABLED(TMC_USE_SW_SPI)
|
|
|
|
SETUP_RUN(SPI.begin());
|
|
|
|
#endif
|
|
|
|
SETUP_RUN(tmc_init_cs_pins());
|
|
|
|
#endif
|
|
|
|
|
2021-02-27 20:50:44 +01:00
|
|
|
#if ENABLED(PSU_CONTROL)
|
|
|
|
SETUP_LOG("PSU_CONTROL");
|
2021-07-12 07:13:58 +02:00
|
|
|
powerManager.init();
|
2021-02-27 20:50:44 +01:00
|
|
|
#endif
|
|
|
|
|
2019-08-20 09:40:44 +02:00
|
|
|
#if ENABLED(POWER_LOSS_RECOVERY)
|
2020-04-12 04:29:52 +02:00
|
|
|
SETUP_RUN(recovery.setup());
|
2019-08-20 09:40:44 +02:00
|
|
|
#endif
|
|
|
|
|
2016-09-12 03:21:54 +02:00
|
|
|
#if HAS_STEPPER_RESET
|
2020-04-12 04:29:52 +02:00
|
|
|
SETUP_RUN(disableStepperDrivers());
|
2016-09-12 03:21:54 +02:00
|
|
|
#endif
|
|
|
|
|
2022-02-18 01:50:31 +01:00
|
|
|
SETUP_RUN(hal.init_board());
|
2018-07-02 06:11:42 +02:00
|
|
|
|
2020-04-16 10:55:33 +02:00
|
|
|
SETUP_RUN(esp_wifi_init());
|
|
|
|
|
2021-11-04 18:18:23 +01:00
|
|
|
// Report Reset Reason
|
2022-02-18 01:50:31 +01:00
|
|
|
if (mcu & RST_POWER_ON) SERIAL_ECHOLNPGM(STR_POWERUP);
|
|
|
|
if (mcu & RST_EXTERNAL) SERIAL_ECHOLNPGM(STR_EXTERNAL_RESET);
|
2020-06-29 08:02:36 +02:00
|
|
|
if (mcu & RST_BROWN_OUT) SERIAL_ECHOLNPGM(STR_BROWNOUT_RESET);
|
2022-02-18 01:50:31 +01:00
|
|
|
if (mcu & RST_WATCHDOG) SERIAL_ECHOLNPGM(STR_WATCHDOG_RESET);
|
|
|
|
if (mcu & RST_SOFTWARE) SERIAL_ECHOLNPGM(STR_SOFTWARE_RESET);
|
2017-06-18 01:36:10 +02:00
|
|
|
|
2021-11-04 18:18:23 +01:00
|
|
|
// Identify myself as Marlin x.x.x
|
2021-07-18 07:45:17 +02:00
|
|
|
SERIAL_ECHOLNPGM("Marlin " SHORT_BUILD_VERSION);
|
2016-09-13 00:49:35 +02:00
|
|
|
#if defined(STRING_DISTRIBUTION_DATE) && defined(STRING_CONFIG_H_AUTHOR)
|
2019-09-26 10:47:26 +02:00
|
|
|
SERIAL_ECHO_MSG(
|
2020-09-11 03:44:13 +02:00
|
|
|
" Last Updated: " STRING_DISTRIBUTION_DATE
|
|
|
|
" | Author: " STRING_CONFIG_H_AUTHOR
|
2019-09-26 10:47:26 +02:00
|
|
|
);
|
2016-09-13 00:49:35 +02:00
|
|
|
#endif
|
2021-08-26 01:08:27 +02:00
|
|
|
SERIAL_ECHO_MSG(" Compiled: " __DATE__);
|
2022-02-18 01:50:31 +01:00
|
|
|
SERIAL_ECHO_MSG(STR_FREE_MEMORY, hal.freeMemory(), STR_PLANNER_BUFFER_BYTES, sizeof(block_t) * (BLOCK_BUFFER_SIZE));
|
2016-09-12 03:21:54 +02:00
|
|
|
|
2021-02-06 05:43:51 +01:00
|
|
|
// Some HAL need precise delay adjustment
|
|
|
|
calibrate_delay_loop();
|
|
|
|
|
2020-10-01 03:14:19 +02:00
|
|
|
// Init buzzer pin(s)
|
2022-05-12 04:23:16 +02:00
|
|
|
#if HAS_BEEPER
|
2020-10-01 03:14:19 +02:00
|
|
|
SETUP_RUN(buzzer.init());
|
|
|
|
#endif
|
|
|
|
|
2019-09-26 01:41:04 +02:00
|
|
|
// Set up LEDs early
|
|
|
|
#if HAS_COLOR_LEDS
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_RUN(leds.setup());
|
2019-09-26 01:41:04 +02:00
|
|
|
#endif
|
|
|
|
|
2020-08-27 21:18:16 +02:00
|
|
|
#if ENABLED(NEOPIXEL2_SEPARATE)
|
|
|
|
SETUP_RUN(leds2.setup());
|
|
|
|
#endif
|
|
|
|
|
2020-03-18 19:41:12 +01:00
|
|
|
#if ENABLED(USE_CONTROLLER_FAN) // Set up fan controller to initialize also the default configurations.
|
|
|
|
SETUP_RUN(controllerFan.setup());
|
|
|
|
#endif
|
|
|
|
|
2021-11-23 21:01:53 +01:00
|
|
|
TERN_(HAS_FANCHECK, fan_check.init());
|
|
|
|
|
2020-04-12 04:29:52 +02:00
|
|
|
// UI must be initialized before EEPROM
|
|
|
|
// (because EEPROM code calls the UI).
|
|
|
|
|
2022-01-22 17:14:47 +01:00
|
|
|
SETUP_RUN(ui.init());
|
2020-03-08 05:33:38 +01:00
|
|
|
|
2021-04-27 09:22:09 +02:00
|
|
|
#if PIN_EXISTS(SAFE_POWER)
|
|
|
|
#if HAS_DRIVER_SAFE_POWER_PROTECT
|
|
|
|
SETUP_RUN(stepper_driver_backward_check());
|
|
|
|
#else
|
|
|
|
SETUP_LOG("SAFE_POWER");
|
|
|
|
OUT_WRITE(SAFE_POWER_PIN, HIGH);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2020-04-04 07:08:25 +02:00
|
|
|
#if BOTH(SDSUPPORT, SDCARD_EEPROM_EMULATION)
|
|
|
|
SETUP_RUN(card.mount()); // Mount media with settings before first_load
|
2020-03-08 05:33:38 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
SETUP_RUN(settings.first_load()); // Load data from EEPROM if available (or use defaults)
|
|
|
|
// This also updates variables in the planner, elsewhere
|
|
|
|
|
2022-01-22 17:14:47 +01:00
|
|
|
#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
|
|
|
|
|
2020-10-20 21:35:29 +02:00
|
|
|
#if HAS_ETHERNET
|
|
|
|
SETUP_RUN(ethernet.init());
|
|
|
|
#endif
|
|
|
|
|
2020-11-15 23:39:58 +01:00
|
|
|
#if HAS_TOUCH_BUTTONS
|
2021-09-14 04:07:08 +02:00
|
|
|
SETUP_RUN(touchBt.init());
|
2019-07-15 01:16:26 +02:00
|
|
|
#endif
|
|
|
|
|
2020-04-22 23:35:03 +02:00
|
|
|
TERN_(HAS_M206_COMMAND, current_position += home_offset); // Init current position based on home_offset
|
2016-09-12 03:21:54 +02:00
|
|
|
|
2020-03-08 05:33:38 +01:00
|
|
|
sync_plan_position(); // Vital to init stepper/planner equivalent for current_position
|
2016-09-12 03:21:54 +02:00
|
|
|
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_RUN(thermalManager.init()); // Initialize temperature loop
|
2016-09-12 03:21:54 +02:00
|
|
|
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_RUN(print_job_timer.init()); // Initial setup of print job timer
|
2018-03-05 04:23:43 +01:00
|
|
|
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_RUN(endstops.init()); // Init endstops and pullups
|
2018-05-16 09:08:43 +02:00
|
|
|
|
2022-02-06 15:35:18 +01:00
|
|
|
#if ENABLED(DELTA) && !HAS_SOFTWARE_ENDSTOPS
|
|
|
|
SETUP_RUN(refresh_delta_clip_start_height()); // Init safe delta height without soft endstops
|
|
|
|
#endif
|
|
|
|
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_RUN(stepper.init()); // Init stepper. This enables interrupts!
|
2017-09-08 22:35:25 +02:00
|
|
|
|
|
|
|
#if HAS_SERVOS
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_RUN(servo_init());
|
2017-09-08 22:35:25 +02:00
|
|
|
#endif
|
2016-09-12 03:21:54 +02:00
|
|
|
|
2018-04-02 06:54:12 +02:00
|
|
|
#if HAS_Z_SERVO_PROBE
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_RUN(probe.servo_probe_init());
|
2017-11-19 20:39:46 +01:00
|
|
|
#endif
|
|
|
|
|
2016-11-01 12:24:21 +01:00
|
|
|
#if HAS_PHOTOGRAPH
|
|
|
|
OUT_WRITE(PHOTOGRAPH_PIN, LOW);
|
|
|
|
#endif
|
|
|
|
|
2019-06-28 06:06:49 +02:00
|
|
|
#if HAS_CUTTER
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_RUN(cutter.init());
|
2017-04-07 20:52:45 +02:00
|
|
|
#endif
|
|
|
|
|
2019-06-14 01:43:11 +02:00
|
|
|
#if ENABLED(COOLANT_MIST)
|
|
|
|
OUT_WRITE(COOLANT_MIST_PIN, COOLANT_MIST_INVERT); // Init Mist Coolant OFF
|
|
|
|
#endif
|
|
|
|
#if ENABLED(COOLANT_FLOOD)
|
|
|
|
OUT_WRITE(COOLANT_FLOOD_PIN, COOLANT_FLOOD_INVERT); // Init Flood Coolant OFF
|
|
|
|
#endif
|
|
|
|
|
2016-09-12 03:21:54 +02:00
|
|
|
#if HAS_BED_PROBE
|
2021-11-17 18:35:28 +01:00
|
|
|
#if PIN_EXISTS(PROBE_ENABLE)
|
|
|
|
OUT_WRITE(PROBE_ENABLE_PIN, LOW); // Disable
|
|
|
|
#endif
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_RUN(endstops.enable_z_probe(false));
|
2016-09-12 03:21:54 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAS_STEPPER_RESET
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_RUN(enableStepperDrivers());
|
2016-09-12 03:21:54 +02:00
|
|
|
#endif
|
|
|
|
|
2020-10-11 21:58:35 +02:00
|
|
|
#if HAS_MOTOR_CURRENT_I2C
|
|
|
|
SETUP_RUN(digipot_i2c.init());
|
2016-09-12 03:21:54 +02:00
|
|
|
#endif
|
|
|
|
|
2021-07-10 00:09:58 +02:00
|
|
|
#if HAS_MOTOR_CURRENT_DAC
|
2020-10-11 21:58:35 +02:00
|
|
|
SETUP_RUN(stepper_dac.init());
|
2016-09-12 03:21:54 +02:00
|
|
|
#endif
|
|
|
|
|
2019-03-17 05:43:06 +01:00
|
|
|
#if EITHER(Z_PROBE_SLED, SOLENOID_PROBE) && HAS_SOLENOID_1
|
2018-10-02 01:33:52 +02:00
|
|
|
OUT_WRITE(SOL1_PIN, LOW); // OFF
|
2017-04-14 23:36:02 +02:00
|
|
|
#endif
|
2016-09-12 03:21:54 +02:00
|
|
|
|
2017-07-02 09:26:49 +02:00
|
|
|
#if HAS_HOME
|
|
|
|
SET_INPUT_PULLUP(HOME_PIN);
|
|
|
|
#endif
|
2016-09-12 03:21:54 +02:00
|
|
|
|
2021-03-01 15:03:41 +01:00
|
|
|
#if ENABLED(CUSTOM_USER_BUTTONS)
|
|
|
|
#define INIT_CUSTOM_USER_BUTTON_PIN(N) do{ SET_INPUT(BUTTON##N##_PIN); WRITE(BUTTON##N##_PIN, !BUTTON##N##_HIT_STATE); }while(0)
|
|
|
|
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(1)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(1);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(2)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(2);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(3)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(3);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(4)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(4);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(5)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(5);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(6)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(6);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(7)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(7);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(8)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(8);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(9)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(9);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(10)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(10);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(11)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(11);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(12)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(12);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(13)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(13);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(14)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(14);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(15)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(15);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(16)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(16);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(17)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(17);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(18)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(18);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(19)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(19);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(20)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(20);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(21)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(21);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(22)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(22);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(23)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(23);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(24)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(24);
|
|
|
|
#endif
|
|
|
|
#if HAS_CUSTOM_USER_BUTTON(25)
|
|
|
|
INIT_CUSTOM_USER_BUTTON_PIN(25);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2016-09-24 22:33:29 +02:00
|
|
|
#if PIN_EXISTS(STAT_LED_RED)
|
2018-10-02 01:33:52 +02:00
|
|
|
OUT_WRITE(STAT_LED_RED_PIN, LOW); // OFF
|
2016-09-12 03:21:54 +02:00
|
|
|
#endif
|
2016-09-24 22:33:29 +02:00
|
|
|
#if PIN_EXISTS(STAT_LED_BLUE)
|
2018-10-02 01:33:52 +02:00
|
|
|
OUT_WRITE(STAT_LED_BLUE_PIN, LOW); // OFF
|
2016-09-12 03:21:54 +02:00
|
|
|
#endif
|
|
|
|
|
2020-08-06 15:14:00 +02:00
|
|
|
#if ENABLED(CASE_LIGHT_ENABLE)
|
2021-02-27 23:06:48 +01:00
|
|
|
SETUP_RUN(caselight.init());
|
2019-01-16 01:50:56 +01:00
|
|
|
#endif
|
|
|
|
|
2020-11-18 08:27:21 +01:00
|
|
|
#if HAS_PRUSA_MMU1
|
2021-06-05 03:02:37 +02:00
|
|
|
SETUP_RUN(mmu_init());
|
2017-06-02 20:57:31 +02:00
|
|
|
#endif
|
2017-08-26 00:03:07 +02:00
|
|
|
|
2017-08-15 14:48:10 +02:00
|
|
|
#if HAS_FANMUX
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_RUN(fanmux_init());
|
2017-08-15 14:48:10 +02:00
|
|
|
#endif
|
2017-08-26 00:03:07 +02:00
|
|
|
|
2018-10-16 10:38:57 +02:00
|
|
|
#if ENABLED(MIXING_EXTRUDER)
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_RUN(mixer.init());
|
2016-09-12 03:21:54 +02:00
|
|
|
#endif
|
|
|
|
|
2017-01-22 01:10:02 +01:00
|
|
|
#if ENABLED(BLTOUCH)
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_RUN(bltouch.init(/*set_voltage=*/true));
|
2017-01-22 01:10:02 +01:00
|
|
|
#endif
|
|
|
|
|
2021-12-27 22:28:27 +01:00
|
|
|
#if ENABLED(MAGLEV4)
|
|
|
|
OUT_WRITE(MAGLEV_TRIGGER_PIN, LOW);
|
|
|
|
#endif
|
|
|
|
|
2017-06-09 14:06:23 +02:00
|
|
|
#if ENABLED(I2C_POSITION_ENCODERS)
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_RUN(I2CPEM.init());
|
2017-06-09 14:06:23 +02:00
|
|
|
#endif
|
|
|
|
|
2016-09-12 03:21:54 +02:00
|
|
|
#if ENABLED(EXPERIMENTAL_I2CBUS) && I2C_SLAVE_ADDRESS > 0
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_LOG("i2c...");
|
2016-09-12 03:21:54 +02:00
|
|
|
i2c.onReceive(i2c_on_receive);
|
|
|
|
i2c.onRequest(i2c_on_request);
|
|
|
|
#endif
|
2016-11-05 22:38:48 +01:00
|
|
|
|
2018-05-18 20:16:59 +02:00
|
|
|
#if DO_SWITCH_EXTRUDER
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_RUN(move_extruder_servo(0)); // Initialize extruder servo
|
2017-06-04 15:40:57 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(SWITCHING_NOZZLE)
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_LOG("SWITCHING_NOZZLE");
|
2019-02-04 07:19:56 +01:00
|
|
|
// Initialize nozzle servo(s)
|
|
|
|
#if SWITCHING_NOZZLE_TWO_SERVOS
|
|
|
|
lower_nozzle(0);
|
|
|
|
raise_nozzle(1);
|
|
|
|
#else
|
|
|
|
move_nozzle_servo(0);
|
|
|
|
#endif
|
2017-06-04 15:40:57 +02:00
|
|
|
#endif
|
2017-08-21 23:30:08 +02:00
|
|
|
|
2017-08-13 23:35:59 +02:00
|
|
|
#if ENABLED(PARKING_EXTRUDER)
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_RUN(pe_solenoid_init());
|
2021-03-18 01:24:07 +01:00
|
|
|
#elif ENABLED(MAGNETIC_PARKING_EXTRUDER)
|
|
|
|
SETUP_RUN(mpe_settings_init());
|
|
|
|
#elif ENABLED(SWITCHING_TOOLHEAD)
|
2020-04-20 07:01:14 +02:00
|
|
|
SETUP_RUN(swt_init());
|
2021-03-18 01:24:07 +01:00
|
|
|
#elif ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_RUN(est_init());
|
2019-07-01 12:55:23 +02:00
|
|
|
#endif
|
|
|
|
|
2018-11-17 03:47:07 +01:00
|
|
|
#if ENABLED(USE_WATCHDOG)
|
2022-05-23 03:45:37 +02:00
|
|
|
SETUP_RUN(hal.watchdog_init()); // Reinit watchdog after hal.get_reset_source call
|
2018-03-09 00:34:50 +01:00
|
|
|
#endif
|
2018-09-08 19:08:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
|
2020-06-28 20:48:48 +02:00
|
|
|
SETUP_RUN(closedloop.init());
|
2018-09-08 19:08:31 +02:00
|
|
|
#endif
|
2018-09-12 10:49:46 +02:00
|
|
|
|
2019-08-15 04:05:15 +02:00
|
|
|
#ifdef STARTUP_COMMANDS
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_LOG("STARTUP_COMMANDS");
|
2021-09-26 04:11:31 +02:00
|
|
|
queue.inject(F(STARTUP_COMMANDS));
|
2019-08-15 04:05:15 +02:00
|
|
|
#endif
|
|
|
|
|
2019-09-28 00:06:26 +02:00
|
|
|
#if ENABLED(HOST_PROMPT_SUPPORT)
|
2021-10-15 07:24:08 +02:00
|
|
|
SETUP_RUN(hostui.prompt_end());
|
2019-09-28 00:06:26 +02:00
|
|
|
#endif
|
|
|
|
|
2021-04-27 09:22:09 +02:00
|
|
|
#if HAS_DRIVER_SAFE_POWER_PROTECT
|
|
|
|
SETUP_RUN(stepper_driver_backward_report());
|
|
|
|
#endif
|
|
|
|
|
2020-11-18 08:27:21 +01:00
|
|
|
#if HAS_PRUSA_MMU2
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_RUN(mmu2.init());
|
2020-02-26 10:04:02 +01:00
|
|
|
#endif
|
2020-03-07 07:16:33 +01:00
|
|
|
|
2020-06-16 08:45:27 +02:00
|
|
|
#if ENABLED(IIC_BL24CXX_EEPROM)
|
|
|
|
BL24CXX::init();
|
|
|
|
const uint8_t err = BL24CXX::check();
|
2020-07-24 10:09:14 +02:00
|
|
|
SERIAL_ECHO_TERNARY(err, "BL24CXX Check ", "failed", "succeeded", "!\n");
|
2020-06-16 08:45:27 +02:00
|
|
|
#endif
|
|
|
|
|
2021-09-07 09:15:24 +02:00
|
|
|
#if HAS_DWIN_E3V2_BASIC
|
2022-03-11 21:06:49 +01:00
|
|
|
SETUP_RUN(DWIN_InitScreen());
|
2020-06-16 08:45:27 +02:00
|
|
|
#endif
|
|
|
|
|
2021-09-07 09:15:24 +02:00
|
|
|
#if HAS_SERVICE_INTERVALS && !HAS_DWIN_E3V2_BASIC
|
2021-11-07 08:11:51 +01:00
|
|
|
SETUP_RUN(ui.reset_status(true)); // Show service messages or keep current status
|
2020-06-16 08:45:27 +02:00
|
|
|
#endif
|
|
|
|
|
2020-03-07 07:16:33 +01:00
|
|
|
#if ENABLED(MAX7219_DEBUG)
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_RUN(max7219.init());
|
2020-03-07 07:16:33 +01:00
|
|
|
#endif
|
2020-03-08 05:33:38 +01:00
|
|
|
|
2020-05-12 02:22:41 +02:00
|
|
|
#if ENABLED(DIRECT_STEPPING)
|
|
|
|
SETUP_RUN(page_manager.init());
|
|
|
|
#endif
|
|
|
|
|
2020-07-25 07:52:07 +02:00
|
|
|
#if HAS_TFT_LVGL_UI
|
2020-08-04 04:55:37 +02:00
|
|
|
#if ENABLED(SDSUPPORT)
|
|
|
|
if (!card.isMounted()) SETUP_RUN(card.mount()); // Mount SD to load graphics and fonts
|
|
|
|
#endif
|
2020-06-16 04:05:33 +02:00
|
|
|
SETUP_RUN(tft_lvgl_init());
|
|
|
|
#endif
|
|
|
|
|
2021-04-24 08:29:30 +02:00
|
|
|
#if BOTH(HAS_WIRED_LCD, SHOW_BOOTSCREEN)
|
|
|
|
const millis_t elapsed = millis() - bootscreen_ms;
|
|
|
|
#if ENABLED(MARLIN_DEV_MODE)
|
2021-09-09 11:57:05 +02:00
|
|
|
SERIAL_ECHOLNPGM("elapsed=", elapsed);
|
2021-04-24 08:29:30 +02:00
|
|
|
#endif
|
|
|
|
SETUP_RUN(ui.bootscreen_completion(elapsed));
|
|
|
|
#endif
|
|
|
|
|
2020-08-09 03:00:42 +02:00
|
|
|
#if ENABLED(PASSWORD_ON_STARTUP)
|
|
|
|
SETUP_RUN(password.lock_machine()); // Will not proceed until correct password provided
|
|
|
|
#endif
|
|
|
|
|
2022-01-25 22:33:03 +01:00
|
|
|
#if BOTH(HAS_MARLINUI_MENU, TOUCH_SCREEN_CALIBRATION) && EITHER(TFT_CLASSIC_UI, TFT_COLOR_UI)
|
2021-11-07 08:11:51 +01:00
|
|
|
SETUP_RUN(ui.check_touch_calibration());
|
2020-11-15 23:39:58 +01:00
|
|
|
#endif
|
|
|
|
|
2021-11-23 22:52:18 +01:00
|
|
|
#if ENABLED(EASYTHREED_UI)
|
|
|
|
SETUP_RUN(easythreed_ui.init());
|
|
|
|
#endif
|
|
|
|
|
2022-05-14 02:50:42 +02:00
|
|
|
#if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF)
|
|
|
|
SETUP_RUN(test_tmc_connection());
|
|
|
|
#endif
|
|
|
|
|
2022-08-06 08:14:58 +02:00
|
|
|
#if ENABLED(BD_SENSOR)
|
|
|
|
SETUP_RUN(bdl.init(I2C_BD_SDA_PIN, I2C_BD_SCL_PIN, I2C_BD_DELAY));
|
|
|
|
#endif
|
|
|
|
|
2020-03-15 00:47:44 +01:00
|
|
|
marlin_state = MF_RUNNING;
|
|
|
|
|
2020-03-08 05:33:38 +01:00
|
|
|
SETUP_LOG("setup() completed.");
|
2022-08-05 00:56:09 +02:00
|
|
|
|
|
|
|
TERN_(MARLIN_TEST_BUILD, runStartupTests());
|
2016-09-12 03:21:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The main Marlin program loop
|
|
|
|
*
|
2020-02-26 05:18:14 +01:00
|
|
|
* - Call idle() to handle all tasks between G-code commands
|
|
|
|
* Note that no G-codes from the queue can be executed during idle()
|
|
|
|
* but many G-codes can be called directly anytime like macros.
|
|
|
|
* - Check whether SD card auto-start is needed now.
|
|
|
|
* - Check whether SD print finishing is needed now.
|
|
|
|
* - Run one G-code command from the immediate or main command queue
|
|
|
|
* and open up one space. Commands in the main queue may come from sd
|
|
|
|
* card, host, or by direct injection. The queue will continue to fill
|
|
|
|
* as long as idle() or manage_inactivity() are being called.
|
2016-09-12 03:21:54 +02:00
|
|
|
*/
|
|
|
|
void loop() {
|
2020-01-02 04:13:43 +01:00
|
|
|
do {
|
|
|
|
idle();
|
2019-08-06 03:33:15 +02:00
|
|
|
|
2018-05-01 08:01:02 +02:00
|
|
|
#if ENABLED(SDSUPPORT)
|
2019-10-29 22:00:17 +01:00
|
|
|
if (card.flag.abort_sd_printing) abortSDPrinting();
|
2020-03-28 09:18:53 +01:00
|
|
|
if (marlin_state == MF_SD_COMPLETE) finishSDPrinting();
|
2019-10-29 22:00:17 +01:00
|
|
|
#endif
|
2018-04-16 01:27:54 +02:00
|
|
|
|
2019-06-19 07:00:19 +02:00
|
|
|
queue.advance();
|
2019-10-29 22:00:17 +01:00
|
|
|
|
2022-01-03 17:11:39 +01:00
|
|
|
#if EITHER(POWER_OFF_TIMER, POWER_OFF_WAIT_FOR_COOLDOWN)
|
|
|
|
powerManager.checkAutoPowerOff();
|
|
|
|
#endif
|
|
|
|
|
2018-07-12 00:33:26 +02:00
|
|
|
endstops.event_handler();
|
2020-01-02 04:13:43 +01:00
|
|
|
|
2020-07-25 07:52:07 +02:00
|
|
|
TERN_(HAS_TFT_LVGL_UI, printer_state_polling());
|
2020-06-16 04:05:33 +02:00
|
|
|
|
2022-08-05 00:56:09 +02:00
|
|
|
TERN_(MARLIN_TEST_BUILD, runPeriodicTests());
|
|
|
|
|
2020-03-08 05:20:41 +01:00
|
|
|
} while (ENABLED(__AVR__)); // Loop forever on slower (AVR) boards
|
2016-09-12 03:21:54 +02:00
|
|
|
}
|