2016-03-25 01:19:46 -05:00
|
|
|
/**
|
2016-03-24 13:01:20 -05:00
|
|
|
* Marlin 3D Printer Firmware
|
2020-02-03 08:00:57 -06:00
|
|
|
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2015-05-17 03:44:53 -05:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-27 23:57:50 -05:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2015-05-17 03:44:53 -05: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-22 22:20:14 -05:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2016-03-24 13:01:20 -05:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-03-25 01:19:46 -05:00
|
|
|
/**
|
2015-05-17 03:44:53 -05:00
|
|
|
* About Marlin
|
|
|
|
*
|
|
|
|
* This firmware is a mashup between Sprinter and grbl.
|
|
|
|
* - https://github.com/kliment/Sprinter
|
2018-02-06 02:28:18 -06:00
|
|
|
* - https://github.com/grbl/grbl
|
2015-04-13 19:17:36 -05:00
|
|
|
*/
|
2012-11-06 05:06:41 -06:00
|
|
|
|
2020-01-02 19:01:38 -06:00
|
|
|
#include "MarlinCore.h"
|
2016-11-18 21:54:38 -06:00
|
|
|
|
2020-08-27 11:29:07 -05:00
|
|
|
#if ENABLED(MARLIN_DEV_MODE)
|
|
|
|
#warning "WARNING! Disable MARLIN_DEV_MODE for the final build!"
|
|
|
|
#endif
|
|
|
|
|
2020-04-25 16:32:08 -05:00
|
|
|
#include "HAL/shared/Delay.h"
|
|
|
|
#include "HAL/shared/esp_wifi.h"
|
2021-02-20 20:22:20 -06:00
|
|
|
#include "HAL/shared/cpu_exception/exception_hook.h"
|
2020-04-25 16:32:08 -05:00
|
|
|
|
|
|
|
#ifdef ARDUINO
|
|
|
|
#include <pins_arduino.h>
|
|
|
|
#endif
|
|
|
|
#include <math.h>
|
|
|
|
|
2019-03-29 14:07:43 -05:00
|
|
|
#include "core/utility.h"
|
2021-01-21 03:40:07 -06:00
|
|
|
|
2017-09-07 22:33:16 -05:00
|
|
|
#include "module/motion.h"
|
2017-09-06 06:28:33 -05:00
|
|
|
#include "module/planner.h"
|
|
|
|
#include "module/endstops.h"
|
|
|
|
#include "module/temperature.h"
|
2020-08-07 20:51:40 -05:00
|
|
|
#include "module/settings.h"
|
2017-09-09 00:18:43 -05:00
|
|
|
#include "module/printcounter.h" // PrintCounter or Stopwatch
|
2018-09-08 12:08:31 -05:00
|
|
|
|
2020-08-03 21:55:37 -05:00
|
|
|
#include "module/stepper.h"
|
2019-08-31 19:44:45 -05:00
|
|
|
#include "module/stepper/indirection.h"
|
2019-01-23 19:06:54 -06:00
|
|
|
|
2017-09-07 22:33:16 -05:00
|
|
|
#include "gcode/gcode.h"
|
2017-09-06 06:28:33 -05:00
|
|
|
#include "gcode/parser.h"
|
2017-09-07 22:33:16 -05:00
|
|
|
#include "gcode/queue.h"
|
2016-11-18 21:54:38 -06:00
|
|
|
|
2021-01-21 03:40:07 -06:00
|
|
|
#include "feature/pause.h"
|
2020-08-03 21:55:37 -05:00
|
|
|
#include "sd/cardreader.h"
|
|
|
|
|
2020-10-16 19:36:25 -05:00
|
|
|
#include "lcd/marlinui.h"
|
2020-11-15 16:39:58 -06:00
|
|
|
#if HAS_TOUCH_BUTTONS
|
2020-08-21 18:54:21 -05:00
|
|
|
#include "lcd/touch/touch_buttons.h"
|
2020-08-03 21:55:37 -05:00
|
|
|
#endif
|
|
|
|
|
2020-07-25 00:52:07 -05:00
|
|
|
#if HAS_TFT_LVGL_UI
|
2020-06-24 14:54:39 -05:00
|
|
|
#include "lcd/extui/lib/mks_ui/tft_lvgl_configuration.h"
|
|
|
|
#include "lcd/extui/lib/mks_ui/draw_ui.h"
|
2020-07-25 00:52:07 -05:00
|
|
|
#include "lcd/extui/lib/mks_ui/mks_hardware_test.h"
|
|
|
|
#include <lvgl.h>
|
2020-06-15 21:05:33 -05:00
|
|
|
#endif
|
|
|
|
|
2020-06-16 01:45:27 -05:00
|
|
|
#if ENABLED(DWIN_CREALITY_LCD)
|
2020-09-06 21:40:58 -05:00
|
|
|
#include "lcd/dwin/e3v2/dwin.h"
|
2020-06-16 01:45:27 -05:00
|
|
|
#include "lcd/dwin/dwin_lcd.h"
|
2020-09-06 21:40:58 -05:00
|
|
|
#include "lcd/dwin/e3v2/rotary_encoder.h"
|
2020-06-16 01:45:27 -05:00
|
|
|
#endif
|
|
|
|
|
2020-11-05 16:45:22 -06:00
|
|
|
#if ENABLED(EXTENSIBLE_UI)
|
|
|
|
#include "lcd/extui/ui_api.h"
|
|
|
|
#endif
|
|
|
|
|
2020-10-20 14:35:29 -05:00
|
|
|
#if HAS_ETHERNET
|
|
|
|
#include "feature/ethernet.h"
|
|
|
|
#endif
|
|
|
|
|
2020-06-16 01:45:27 -05:00
|
|
|
#if ENABLED(IIC_BL24CXX_EEPROM)
|
2020-07-24 03:09:14 -05:00
|
|
|
#include "libs/BL24CXX.h"
|
2020-06-16 01:45:27 -05:00
|
|
|
#endif
|
|
|
|
|
2020-05-11 19:22:41 -05:00
|
|
|
#if ENABLED(DIRECT_STEPPING)
|
|
|
|
#include "feature/direct_stepping.h"
|
|
|
|
#endif
|
|
|
|
|
2019-02-12 15:55:47 -06:00
|
|
|
#if ENABLED(HOST_ACTION_COMMANDS)
|
|
|
|
#include "feature/host_actions.h"
|
|
|
|
#endif
|
|
|
|
|
2019-08-20 02:01:37 -05:00
|
|
|
#if USE_BEEPER
|
2017-09-14 15:33:07 -05:00
|
|
|
#include "libs/buzzer.h"
|
|
|
|
#endif
|
|
|
|
|
2020-08-03 21:55:37 -05:00
|
|
|
#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
|
|
|
|
#include "feature/closedloop.h"
|
|
|
|
#endif
|
|
|
|
|
2020-10-11 14:58:35 -05:00
|
|
|
#if HAS_MOTOR_CURRENT_I2C
|
2017-09-17 18:45:21 -05:00
|
|
|
#include "feature/digipot/digipot.h"
|
|
|
|
#endif
|
|
|
|
|
2017-09-18 00:06:16 -05:00
|
|
|
#if ENABLED(MIXING_EXTRUDER)
|
|
|
|
#include "feature/mixing.h"
|
|
|
|
#endif
|
|
|
|
|
2017-08-25 17:03:07 -05:00
|
|
|
#if ENABLED(MAX7219_DEBUG)
|
2020-03-13 16:29:29 -05:00
|
|
|
#include "feature/max7219.h"
|
2017-08-25 17:03:07 -05:00
|
|
|
#endif
|
|
|
|
|
2017-09-08 14:47:47 -05:00
|
|
|
#if HAS_COLOR_LEDS
|
|
|
|
#include "feature/leds/leds.h"
|
2017-06-10 01:02:15 -05:00
|
|
|
#endif
|
|
|
|
|
2019-03-17 05:57:25 -05:00
|
|
|
#if ENABLED(BLTOUCH)
|
|
|
|
#include "feature/bltouch.h"
|
|
|
|
#endif
|
|
|
|
|
2019-09-08 00:55:34 -05:00
|
|
|
#if ENABLED(POLL_JOG)
|
|
|
|
#include "feature/joystick.h"
|
|
|
|
#endif
|
|
|
|
|
2016-11-18 21:54:38 -06:00
|
|
|
#if HAS_SERVOS
|
2017-11-19 13:39:46 -06:00
|
|
|
#include "module/servo.h"
|
2016-11-18 21:54:38 -06:00
|
|
|
#endif
|
|
|
|
|
2020-10-11 14:58:35 -05:00
|
|
|
#if ENABLED(HAS_MOTOR_CURRENT_DAC)
|
2017-09-06 06:28:33 -05:00
|
|
|
#include "feature/dac/stepper_dac.h"
|
2016-11-18 21:54:38 -06:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(EXPERIMENTAL_I2CBUS)
|
2017-09-06 06:28:33 -05:00
|
|
|
#include "feature/twibus.h"
|
2016-11-18 21:54:38 -06:00
|
|
|
#endif
|
|
|
|
|
2017-06-09 07:06:23 -05:00
|
|
|
#if ENABLED(I2C_POSITION_ENCODERS)
|
2020-03-13 16:29:29 -05:00
|
|
|
#include "feature/encoder_i2c.h"
|
2017-06-09 07:06:23 -05:00
|
|
|
#endif
|
|
|
|
|
2020-03-02 12:03:43 -06:00
|
|
|
#if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF)
|
2017-12-15 15:03:14 -06:00
|
|
|
#include "feature/tmc_util.h"
|
2017-09-17 18:34:04 -05:00
|
|
|
#endif
|
|
|
|
|
2019-06-27 23:06:49 -05:00
|
|
|
#if HAS_CUTTER
|
|
|
|
#include "feature/spindle_laser.h"
|
|
|
|
#endif
|
|
|
|
|
2015-07-31 00:24:43 -05:00
|
|
|
#if ENABLED(SDSUPPORT)
|
2015-01-29 20:52:21 -06:00
|
|
|
CardReader card;
|
2012-11-06 05:06:41 -06:00
|
|
|
#endif
|
2015-01-29 20:52:21 -06:00
|
|
|
|
2016-09-29 15:06:01 -05:00
|
|
|
#if ENABLED(G38_PROBE_TARGET)
|
2019-03-10 17:22:09 -05:00
|
|
|
uint8_t G38_move; // = 0
|
|
|
|
bool G38_did_trigger; // = false
|
2016-09-19 14:17:10 -05:00
|
|
|
#endif
|
|
|
|
|
2017-09-08 15:35:25 -05:00
|
|
|
#if ENABLED(DELTA)
|
|
|
|
#include "module/delta.h"
|
|
|
|
#elif IS_SCARA
|
|
|
|
#include "module/scara.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAS_LEVELING
|
|
|
|
#include "feature/bedlevel/bedlevel.h"
|
2017-03-18 10:15:54 -05:00
|
|
|
#endif
|
|
|
|
|
2020-11-26 21:18:40 -06:00
|
|
|
#if ENABLED(GCODE_REPEAT_MARKERS)
|
|
|
|
#include "feature/repeat.h"
|
|
|
|
#endif
|
|
|
|
|
2018-04-21 19:41:26 -05:00
|
|
|
#if ENABLED(POWER_LOSS_RECOVERY)
|
2020-03-13 16:29:29 -05:00
|
|
|
#include "feature/powerloss.h"
|
2018-04-21 19:41:26 -05:00
|
|
|
#endif
|
|
|
|
|
2019-10-25 12:26:41 -05:00
|
|
|
#if ENABLED(CANCEL_OBJECTS)
|
|
|
|
#include "feature/cancel_object.h"
|
|
|
|
#endif
|
|
|
|
|
2019-02-12 20:08:34 -06:00
|
|
|
#if HAS_FILAMENT_SENSOR
|
2017-10-10 02:35:20 -05:00
|
|
|
#include "feature/runout.h"
|
|
|
|
#endif
|
|
|
|
|
2020-12-27 16:23:18 -06:00
|
|
|
#if EITHER(PROBE_TARE, HAS_Z_SERVO_PROBE)
|
2020-08-03 21:55:37 -05:00
|
|
|
#include "module/probe.h"
|
|
|
|
#endif
|
|
|
|
|
2020-05-18 00:50:35 -05:00
|
|
|
#if ENABLED(HOTEND_IDLE_TIMEOUT)
|
|
|
|
#include "feature/hotend_idle.h"
|
|
|
|
#endif
|
|
|
|
|
2017-09-16 05:09:34 -05:00
|
|
|
#if ENABLED(TEMP_STAT_LEDS)
|
|
|
|
#include "feature/leds/tempstat.h"
|
|
|
|
#endif
|
|
|
|
|
2020-08-06 08:14:00 -05:00
|
|
|
#if ENABLED(CASE_LIGHT_ENABLE)
|
2017-09-17 18:56:29 -05:00
|
|
|
#include "feature/caselight.h"
|
|
|
|
#endif
|
|
|
|
|
2017-11-04 21:01:41 -05:00
|
|
|
#if HAS_FANMUX
|
|
|
|
#include "feature/fanmux.h"
|
|
|
|
#endif
|
|
|
|
|
2020-03-08 16:13:41 -05:00
|
|
|
#if DO_SWITCH_EXTRUDER || ANY(SWITCHING_NOZZLE, PARKING_EXTRUDER, MAGNETIC_PARKING_EXTRUDER, ELECTROMAGNETIC_SWITCHING_TOOLHEAD, SWITCHING_TOOLHEAD)
|
2017-09-18 01:05:44 -05:00
|
|
|
#include "module/tool_change.h"
|
|
|
|
#endif
|
|
|
|
|
2017-09-18 01:44:59 -05:00
|
|
|
#if ENABLED(USE_CONTROLLER_FAN)
|
|
|
|
#include "feature/controllerfan.h"
|
|
|
|
#endif
|
|
|
|
|
2020-11-18 01:27:21 -06:00
|
|
|
#if HAS_PRUSA_MMU2
|
|
|
|
#include "feature/mmu/mmu2.h"
|
2019-01-31 19:10:52 -06:00
|
|
|
#endif
|
|
|
|
|
2020-01-13 18:47:30 -06:00
|
|
|
#if HAS_L64XX
|
|
|
|
#include "libs/L64XX/L64XX_Marlin.h"
|
2019-01-23 19:06:54 -06:00
|
|
|
#endif
|
|
|
|
|
2020-08-08 20:00:42 -05:00
|
|
|
#if ENABLED(PASSWORD_FEATURE)
|
|
|
|
#include "feature/password/password.h"
|
|
|
|
#endif
|
|
|
|
|
2021-02-27 17:35:32 -06:00
|
|
|
#if ENABLED(DGUS_LCD_UI_MKS)
|
|
|
|
#include "lcd/extui/lib/dgus/DGUSScreenHandler.h"
|
|
|
|
#endif
|
|
|
|
|
2020-05-05 23:34:04 -05:00
|
|
|
PGMSTR(M112_KILL_STR, "M112 Shutdown");
|
2019-11-01 23:51:25 -05:00
|
|
|
|
2020-03-14 18:47:44 -05:00
|
|
|
MarlinState marlin_state = MF_INITIALIZING;
|
2015-04-08 02:56:19 -05:00
|
|
|
|
2016-10-06 22:06:33 -05:00
|
|
|
// For M109 and M190, this flag may be cleared (by M108) to exit the wait loop
|
2019-03-10 09:13:54 -05:00
|
|
|
bool wait_for_heatup = true;
|
2015-04-08 02:56:19 -05:00
|
|
|
|
2016-10-06 22:06:33 -05:00
|
|
|
// For M0/M1, this flag may be cleared (by M108) to exit the wait-for-user loop
|
2017-04-09 11:12:08 -05:00
|
|
|
#if HAS_RESUME_CONTINUE
|
2019-03-09 14:13:50 -06:00
|
|
|
bool wait_for_user; // = false;
|
2020-03-28 03:18:53 -05:00
|
|
|
|
|
|
|
void wait_for_user_response(millis_t ms/*=0*/, const bool no_sleep/*=false*/) {
|
2020-11-07 18:28:29 -06:00
|
|
|
UNUSED(no_sleep);
|
2020-03-28 03:18:53 -05:00
|
|
|
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
|
|
|
wait_for_user = true;
|
|
|
|
if (ms) ms += millis(); // expire time
|
2020-04-02 01:22:48 -05:00
|
|
|
while (wait_for_user && !(ms && ELAPSED(millis(), ms)))
|
|
|
|
idle(TERN_(ADVANCED_PAUSE_FEATURE, no_sleep));
|
2020-03-28 03:18:53 -05:00
|
|
|
wait_for_user = false;
|
|
|
|
}
|
|
|
|
|
2016-09-11 20:51:53 -05:00
|
|
|
#endif
|
|
|
|
|
2016-09-15 13:22:23 -05:00
|
|
|
/**
|
2017-09-08 15:35:25 -05:00
|
|
|
* ***************************************************************************
|
|
|
|
* ******************************** FUNCTIONS ********************************
|
|
|
|
* ***************************************************************************
|
2016-09-15 13:22:23 -05:00
|
|
|
*/
|
|
|
|
|
2017-09-08 15:35:25 -05:00
|
|
|
/**
|
|
|
|
* Stepper Reset (RigidBoard, et.al.)
|
|
|
|
*/
|
|
|
|
#if HAS_STEPPER_RESET
|
2019-02-20 05:28:40 -06: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 15:35:25 -05:00
|
|
|
#endif
|
2016-08-27 19:53:02 -05:00
|
|
|
|
2017-09-06 06:28:33 -05:00
|
|
|
/**
|
|
|
|
* Sensitive pin test for M42, M226
|
|
|
|
*/
|
2018-10-11 00:58:41 -05:00
|
|
|
|
|
|
|
#include "pins/sensitive_pins.h"
|
|
|
|
|
2020-04-28 08:30:52 -05:00
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wnarrowing"
|
|
|
|
|
2017-10-26 13:37:26 -05:00
|
|
|
bool pin_is_protected(const pin_t pin) {
|
|
|
|
static const pin_t sensitive_pins[] PROGMEM = SENSITIVE_PINS;
|
2020-03-13 23:18:16 -05:00
|
|
|
LOOP_L_N(i, COUNT(sensitive_pins)) {
|
2017-10-26 13:37:26 -05:00
|
|
|
pin_t sensitive_pin;
|
|
|
|
memcpy_P(&sensitive_pin, &sensitive_pins[i], sizeof(pin_t));
|
|
|
|
if (pin == sensitive_pin) return true;
|
|
|
|
}
|
2017-09-06 06:28:33 -05:00
|
|
|
return false;
|
|
|
|
}
|
2016-07-19 10:24:44 -05:00
|
|
|
|
2020-04-28 08:30:52 -05:00
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
|
2019-10-07 19:44:33 -05:00
|
|
|
void enable_e_steppers() {
|
2020-01-30 03:24:23 -06:00
|
|
|
#define _ENA_E(N) ENABLE_AXIS_E##N();
|
2019-11-09 17:59:04 -06:00
|
|
|
REPEAT(E_STEPPERS, _ENA_E)
|
2019-10-07 19:44:33 -05:00
|
|
|
}
|
|
|
|
|
2015-04-03 21:25:22 -05:00
|
|
|
void enable_all_steppers() {
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(AUTO_POWER_CONTROL, powerManager.power_on());
|
2020-01-30 03:24:23 -06:00
|
|
|
ENABLE_AXIS_X();
|
|
|
|
ENABLE_AXIS_Y();
|
|
|
|
ENABLE_AXIS_Z();
|
2019-10-07 19:44:33 -05:00
|
|
|
enable_e_steppers();
|
2020-11-05 16:45:22 -06:00
|
|
|
|
|
|
|
TERN_(EXTENSIBLE_UI, ExtUI::onSteppersEnabled());
|
2019-08-14 21:05:15 -05:00
|
|
|
}
|
|
|
|
|
2017-03-17 21:12:19 -05:00
|
|
|
void disable_e_steppers() {
|
2020-01-30 03:24:23 -06:00
|
|
|
#define _DIS_E(N) DISABLE_AXIS_E##N();
|
2019-11-09 17:59:04 -06:00
|
|
|
REPEAT(E_STEPPERS, _DIS_E)
|
2015-04-03 17:31:35 -05:00
|
|
|
}
|
|
|
|
|
2018-01-04 05:06:34 -06:00
|
|
|
void disable_e_stepper(const uint8_t e) {
|
2020-01-30 03:24:23 -06:00
|
|
|
#define _CASE_DIS_E(N) case N: DISABLE_AXIS_E##N(); break;
|
2018-01-04 05:06:34 -06:00
|
|
|
switch (e) {
|
2019-11-09 17:59:04 -06:00
|
|
|
REPEAT(EXTRUDERS, _CASE_DIS_E)
|
2018-01-04 05:06:34 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-03-17 21:12:19 -05:00
|
|
|
void disable_all_steppers() {
|
2020-01-30 03:24:23 -06:00
|
|
|
DISABLE_AXIS_X();
|
|
|
|
DISABLE_AXIS_Y();
|
|
|
|
DISABLE_AXIS_Z();
|
2017-03-17 21:12:19 -05:00
|
|
|
disable_e_steppers();
|
2020-11-05 16:45:22 -06:00
|
|
|
|
|
|
|
TERN_(EXTENSIBLE_UI, ExtUI::onSteppersDisabled());
|
2017-03-17 21:12:19 -05:00
|
|
|
}
|
|
|
|
|
2020-07-15 01:14:03 -05:00
|
|
|
/**
|
|
|
|
* A Print Job exists when the timer is running or SD printing
|
|
|
|
*/
|
|
|
|
bool printJobOngoing() {
|
|
|
|
return print_job_timer.isRunning() || IS_SD_PRINTING();
|
|
|
|
}
|
|
|
|
|
2019-10-02 18:54:20 -05:00
|
|
|
/**
|
|
|
|
* Printing is active when the print job timer is running
|
|
|
|
*/
|
|
|
|
bool printingIsActive() {
|
2019-10-24 15:35:40 -05:00
|
|
|
return !did_pause_print && (print_job_timer.isRunning() || IS_SD_PRINTING());
|
2019-10-02 18:54:20 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Printing is paused according to SD or host indicators
|
|
|
|
*/
|
|
|
|
bool printingIsPaused() {
|
2019-10-24 15:35:40 -05:00
|
|
|
return did_pause_print || print_job_timer.isPaused() || IS_SD_PAUSED();
|
|
|
|
}
|
|
|
|
|
|
|
|
void startOrResumeJob() {
|
2019-10-27 17:49:27 -05:00
|
|
|
if (!printingIsPaused()) {
|
2020-11-26 21:18:40 -06:00
|
|
|
TERN_(GCODE_REPEAT_MARKERS, repeat.reset());
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(CANCEL_OBJECTS, cancelable.reset());
|
|
|
|
TERN_(LCD_SHOW_E_TOTAL, e_move_accumulator = 0);
|
2019-11-13 02:07:09 -06:00
|
|
|
#if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME)
|
2019-11-12 19:36:54 -06:00
|
|
|
ui.reset_remaining_time();
|
|
|
|
#endif
|
2019-10-27 17:49:27 -05:00
|
|
|
}
|
2019-10-24 15:35:40 -05:00
|
|
|
print_job_timer.start();
|
2019-10-02 18:54:20 -05:00
|
|
|
}
|
|
|
|
|
2019-10-29 17:04:39 -05:00
|
|
|
#if ENABLED(SDSUPPORT)
|
|
|
|
|
2020-02-25 22:18:14 -06:00
|
|
|
inline void abortSDPrinting() {
|
2020-12-07 05:53:15 -06:00
|
|
|
IF_DISABLED(NO_SD_AUTOSTART, card.autofile_cancel());
|
2020-04-22 16:35:03 -05:00
|
|
|
card.endFilePrint(TERN_(SD_RESORT, true));
|
2021-01-25 04:56:54 -06:00
|
|
|
|
2019-10-29 17:04:39 -05:00
|
|
|
queue.clear();
|
|
|
|
quickstop_stepper();
|
2021-01-26 02:30:31 -06:00
|
|
|
|
|
|
|
print_job_timer.abort();
|
2021-01-25 04:56:54 -06: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 17:04:39 -05:00
|
|
|
wait_for_heatup = false;
|
2021-01-25 04:56:54 -06:00
|
|
|
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(POWER_LOSS_RECOVERY, recovery.purge());
|
2021-01-25 04:56:54 -06:00
|
|
|
|
2020-08-10 20:25:35 -05:00
|
|
|
#ifdef EVENT_GCODE_SD_ABORT
|
|
|
|
queue.inject_P(PSTR(EVENT_GCODE_SD_ABORT));
|
2019-10-29 17:04:39 -05:00
|
|
|
#endif
|
2020-08-08 20:00:42 -05:00
|
|
|
|
|
|
|
TERN_(PASSWORD_AFTER_SD_PRINT_ABORT, password.lock_machine());
|
2019-10-29 17:04:39 -05:00
|
|
|
}
|
|
|
|
|
2020-02-25 22:18:14 -06:00
|
|
|
inline void finishSDPrinting() {
|
2020-08-08 20:00:42 -05:00
|
|
|
if (queue.enqueue_one_P(PSTR("M1001"))) {
|
2020-03-28 03:18:53 -05:00
|
|
|
marlin_state = MF_RUNNING;
|
2020-08-08 20:00:42 -05:00
|
|
|
TERN_(PASSWORD_AFTER_SD_PRINT_END, password.lock_machine());
|
2021-02-27 17:35:32 -06:00
|
|
|
TERN_(DGUS_LCD_UI_MKS, ScreenHandler.SDPrintingFinished());
|
2020-08-08 20:00:42 -05:00
|
|
|
}
|
2020-02-25 22:18:14 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // SDSUPPORT
|
2019-10-29 16:00:17 -05:00
|
|
|
|
2015-04-03 17:31:35 -05:00
|
|
|
/**
|
2020-02-25 22:18:14 -06:00
|
|
|
* Minimal management of Marlin's core activities:
|
2015-04-04 01:42:50 -05:00
|
|
|
* - Keep the command buffer full
|
|
|
|
* - Check for maximum inactive time between commands
|
|
|
|
* - Check for maximum inactive time between stepper commands
|
2018-11-05 01:08:40 -06:00
|
|
|
* - Check if CHDK_PIN needs to go LOW
|
2015-04-04 01:42:50 -05:00
|
|
|
* - Check for KILL button held down
|
|
|
|
* - Check for HOME button held down
|
|
|
|
* - Check if cooling fan needs to be switched on
|
|
|
|
* - Check if an idle but hot extruder needs filament extruded (EXTRUDER_RUNOUT_PREVENT)
|
2019-02-26 21:03:13 -06:00
|
|
|
* - Pulse FET_SAFETY_PIN if it exists
|
2015-04-03 17:31:35 -05:00
|
|
|
*/
|
2020-02-20 20:09:37 -06:00
|
|
|
inline void manage_inactivity(const bool ignore_stepper_queue=false) {
|
2015-08-05 06:40:36 -05:00
|
|
|
|
2021-02-26 16:54:46 -06:00
|
|
|
queue.get_available_commands();
|
2015-04-03 17:31:35 -05:00
|
|
|
|
2017-03-28 19:45:54 -05:00
|
|
|
const millis_t ms = millis();
|
2015-04-03 17:31:35 -05:00
|
|
|
|
2020-07-01 16:27:28 -05:00
|
|
|
// Prevent steppers timing-out in the middle of M600
|
2020-07-01 22:28:37 -05:00
|
|
|
// unless PAUSE_PARK_NO_STEPPER_TIMEOUT is disabled
|
2021-01-21 03:40:07 -06:00
|
|
|
const bool parked_or_ignoring = ignore_stepper_queue
|
|
|
|
|| TERN0(PAUSE_PARK_NO_STEPPER_TIMEOUT, did_pause_print);
|
2020-07-01 16:27:28 -05:00
|
|
|
|
2020-07-01 22:28:37 -05:00
|
|
|
// Reset both the M18/M84 activity timeout and the M85 max 'kill' timeout
|
|
|
|
if (parked_or_ignoring) gcode.reset_stepper_timeout(ms);
|
2020-07-01 16:27:28 -05:00
|
|
|
|
|
|
|
if (gcode.stepper_max_timed_out(ms)) {
|
2021-02-04 23:22:42 -06:00
|
|
|
SERIAL_ERROR_MSG(STR_KILL_INACTIVE_TIME, parser.command_ptr);
|
2018-10-18 21:20:56 -05:00
|
|
|
kill();
|
2017-03-14 12:24:46 -05:00
|
|
|
}
|
2017-02-10 00:13:58 -06:00
|
|
|
|
2020-11-10 03:27:34 -06:00
|
|
|
// M18 / M84 : Handle steppers inactive time timeout
|
2020-07-01 16:27:28 -05:00
|
|
|
if (gcode.stepper_inactive_time) {
|
2020-07-01 22:28:37 -05:00
|
|
|
|
2019-01-23 19:06:54 -06:00
|
|
|
static bool already_shutdown_steppers; // = false
|
2020-07-01 22:28:37 -05:00
|
|
|
|
|
|
|
// Any moves in the planner? Resets both the M18/M84
|
|
|
|
// activity timeout and the M85 max 'kill' timeout
|
2018-03-21 19:30:06 -05:00
|
|
|
if (planner.has_blocks_queued())
|
2020-07-01 16:27:28 -05:00
|
|
|
gcode.reset_stepper_timeout(ms);
|
2020-07-01 22:28:37 -05:00
|
|
|
else if (!parked_or_ignoring && gcode.stepper_inactive_timeout()) {
|
2019-01-23 19:06:54 -06:00
|
|
|
if (!already_shutdown_steppers) {
|
|
|
|
already_shutdown_steppers = true; // L6470 SPI will consume 99% of free time without this
|
2020-07-01 22:28:37 -05:00
|
|
|
|
|
|
|
// Individual axes will be disabled if configured
|
2020-03-07 22:20:41 -06:00
|
|
|
if (ENABLED(DISABLE_INACTIVE_X)) DISABLE_AXIS_X();
|
|
|
|
if (ENABLED(DISABLE_INACTIVE_Y)) DISABLE_AXIS_Y();
|
|
|
|
if (ENABLED(DISABLE_INACTIVE_Z)) DISABLE_AXIS_Z();
|
|
|
|
if (ENABLED(DISABLE_INACTIVE_E)) disable_e_steppers();
|
2020-07-01 22:28:37 -05:00
|
|
|
|
2020-07-03 09:53:22 -05:00
|
|
|
TERN_(AUTO_BED_LEVELING_UBL, ubl.steppers_were_disabled());
|
2019-01-23 19:06:54 -06:00
|
|
|
}
|
2018-03-21 19:30:06 -05:00
|
|
|
}
|
2019-01-23 19:06:54 -06:00
|
|
|
else
|
|
|
|
already_shutdown_steppers = false;
|
2015-06-01 03:42:28 -05:00
|
|
|
}
|
2015-03-07 14:43:15 -06:00
|
|
|
|
2018-11-05 01:08:40 -06:00
|
|
|
#if PIN_EXISTS(CHDK) // Check if pin should be set to LOW (after M240 set it HIGH)
|
2021-01-21 03:40:07 -06:00
|
|
|
extern millis_t chdk_timeout;
|
2019-02-14 15:09:35 -06:00
|
|
|
if (chdk_timeout && ELAPSED(ms, chdk_timeout)) {
|
|
|
|
chdk_timeout = 0;
|
2018-11-05 01:08:40 -06:00
|
|
|
WRITE(CHDK_PIN, LOW);
|
2014-03-10 15:57:08 -05:00
|
|
|
}
|
|
|
|
#endif
|
2015-04-03 17:31:35 -05:00
|
|
|
|
|
|
|
#if HAS_KILL
|
2015-08-05 06:40:36 -05:00
|
|
|
|
2014-12-28 12:54:06 -06:00
|
|
|
// Check if the kill button was pressed and wait just in case it was an accidental
|
|
|
|
// key kill key press
|
|
|
|
// -------------------------------------------------------------------------------
|
2015-04-03 17:45:41 -05:00
|
|
|
static int killCount = 0; // make the inactivity button a bit less responsive
|
|
|
|
const int KILL_DELAY = 750;
|
2020-05-05 03:31:03 -05:00
|
|
|
if (kill_state())
|
2015-10-03 01:08:58 -05:00
|
|
|
killCount++;
|
2014-12-28 12:54:06 -06:00
|
|
|
else if (killCount > 0)
|
2015-10-03 01:08:58 -05:00
|
|
|
killCount--;
|
2015-04-03 17:31:35 -05:00
|
|
|
|
2014-12-28 12:54:06 -06:00
|
|
|
// Exceeded threshold and we can confirm that it was not accidental
|
|
|
|
// KILL the machine
|
|
|
|
// ----------------------------------------------------------------
|
2017-03-14 12:24:46 -05:00
|
|
|
if (killCount >= KILL_DELAY) {
|
2020-02-26 03:02:03 -06:00
|
|
|
SERIAL_ERROR_MSG(STR_KILL_BUTTON);
|
2018-10-18 21:20:56 -05:00
|
|
|
kill();
|
2017-03-14 12:24:46 -05:00
|
|
|
}
|
2012-11-06 05:06:41 -06:00
|
|
|
#endif
|
2014-12-28 12:54:06 -06:00
|
|
|
|
2015-04-03 17:31:35 -05:00
|
|
|
#if HAS_HOME
|
2019-06-27 15:07:45 -05: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
|
|
|
|
const millis_t ms = millis();
|
|
|
|
if (ELAPSED(ms, next_home_key_ms)) {
|
|
|
|
next_home_key_ms = ms + HOME_DEBOUNCE_DELAY;
|
2015-05-04 12:48:49 -05:00
|
|
|
LCD_MESSAGEPGM(MSG_AUTO_HOME);
|
2020-12-07 05:53:15 -06:00
|
|
|
queue.inject_P(G28_STR);
|
2015-04-03 17:31:35 -05:00
|
|
|
}
|
2014-12-28 12:54:06 -06:00
|
|
|
}
|
2015-04-03 17:31:35 -05:00
|
|
|
#endif
|
2015-08-05 06:40:36 -05:00
|
|
|
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(USE_CONTROLLER_FAN, controllerFan.update()); // Check if fan should be turned on to cool stepper drivers down
|
2015-04-03 17:31:35 -05:00
|
|
|
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(AUTO_POWER_CONTROL, powerManager.check());
|
2018-02-19 16:12:04 -06:00
|
|
|
|
2020-05-18 00:50:35 -05:00
|
|
|
TERN_(HOTEND_IDLE_TIMEOUT, hotend_idle.check());
|
|
|
|
|
2015-07-31 00:24:43 -05:00
|
|
|
#if ENABLED(EXTRUDER_RUNOUT_PREVENT)
|
2018-02-09 03:32:40 -06:00
|
|
|
if (thermalManager.degHotend(active_extruder) > EXTRUDER_RUNOUT_MINTEMP
|
2020-04-03 19:49:45 -05:00
|
|
|
&& ELAPSED(ms, gcode.previous_move_ms + SEC_TO_MS(EXTRUDER_RUNOUT_SECONDS))
|
2018-03-21 19:30:06 -05:00
|
|
|
&& !planner.has_blocks_queued()
|
2018-02-09 03:32:40 -06:00
|
|
|
) {
|
2016-06-28 17:06:56 -05:00
|
|
|
#if ENABLED(SWITCHING_EXTRUDER)
|
2018-05-27 17:56:21 -05:00
|
|
|
bool oldstatus;
|
|
|
|
switch (active_extruder) {
|
2020-01-30 03:24:23 -06:00
|
|
|
default: oldstatus = E0_ENABLE_READ(); ENABLE_AXIS_E0(); break;
|
2018-05-27 17:56:21 -05:00
|
|
|
#if E_STEPPERS > 1
|
2020-01-30 03:24:23 -06:00
|
|
|
case 2: case 3: oldstatus = E1_ENABLE_READ(); ENABLE_AXIS_E1(); break;
|
2018-05-27 17:56:21 -05:00
|
|
|
#if E_STEPPERS > 2
|
2020-01-30 03:24:23 -06:00
|
|
|
case 4: case 5: oldstatus = E2_ENABLE_READ(); ENABLE_AXIS_E2(); break;
|
2020-02-01 15:18:01 -06:00
|
|
|
#if E_STEPPERS > 3
|
|
|
|
case 6: case 7: oldstatus = E3_ENABLE_READ(); ENABLE_AXIS_E3(); break;
|
|
|
|
#endif // E_STEPPERS > 3
|
2018-05-27 17:56:21 -05:00
|
|
|
#endif // E_STEPPERS > 2
|
|
|
|
#endif // E_STEPPERS > 1
|
|
|
|
}
|
2016-06-28 17:06:56 -05:00
|
|
|
#else // !SWITCHING_EXTRUDER
|
2017-07-06 12:10:06 -05:00
|
|
|
bool oldstatus;
|
2015-10-03 01:08:58 -05:00
|
|
|
switch (active_extruder) {
|
2019-11-09 17:59:04 -06:00
|
|
|
default:
|
2020-01-30 03:24:23 -06:00
|
|
|
#define _CASE_EN(N) case N: oldstatus = E##N##_ENABLE_READ(); ENABLE_AXIS_E##N(); break;
|
2019-11-09 17:59:04 -06:00
|
|
|
REPEAT(E_STEPPERS, _CASE_EN);
|
2015-10-03 01:08:58 -05:00
|
|
|
}
|
2019-11-09 17:59:04 -06:00
|
|
|
#endif
|
2016-06-28 17:06:56 -05:00
|
|
|
|
2019-09-29 04:25:39 -05: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 16:41:59 -05:00
|
|
|
planner.set_e_position_mm(olde);
|
2018-05-12 01:38:02 -05:00
|
|
|
planner.synchronize();
|
2018-05-27 17:56:21 -05:00
|
|
|
|
2016-06-28 17:06:56 -05:00
|
|
|
#if ENABLED(SWITCHING_EXTRUDER)
|
2018-05-27 17:56:21 -05:00
|
|
|
switch (active_extruder) {
|
|
|
|
default: oldstatus = E0_ENABLE_WRITE(oldstatus); break;
|
|
|
|
#if E_STEPPERS > 1
|
|
|
|
case 2: case 3: oldstatus = E1_ENABLE_WRITE(oldstatus); break;
|
|
|
|
#if E_STEPPERS > 2
|
2018-09-13 01:35:55 -05:00
|
|
|
case 4: case 5: oldstatus = E2_ENABLE_WRITE(oldstatus); break;
|
2018-05-27 17:56:21 -05:00
|
|
|
#endif // E_STEPPERS > 2
|
|
|
|
#endif // E_STEPPERS > 1
|
|
|
|
}
|
|
|
|
#else // !SWITCHING_EXTRUDER
|
2016-06-28 17:06:56 -05:00
|
|
|
switch (active_extruder) {
|
2019-11-09 17:59:04 -06:00
|
|
|
#define _CASE_RESTORE(N) case N: E##N##_ENABLE_WRITE(oldstatus); break;
|
|
|
|
REPEAT(E_STEPPERS, _CASE_RESTORE);
|
2016-06-28 17:06:56 -05:00
|
|
|
}
|
|
|
|
#endif // !SWITCHING_EXTRUDER
|
2018-03-21 19:30:06 -05:00
|
|
|
|
2020-07-01 16:27:28 -05:00
|
|
|
gcode.reset_stepper_timeout(ms);
|
2012-11-06 05:06:41 -06:00
|
|
|
}
|
2016-06-28 17:06:56 -05:00
|
|
|
#endif // EXTRUDER_RUNOUT_PREVENT
|
2015-04-03 17:31:35 -05:00
|
|
|
|
2015-07-31 00:24:43 -05:00
|
|
|
#if ENABLED(DUAL_X_CARRIAGE)
|
2013-08-07 09:10:26 -05:00
|
|
|
// handle delayed move timeout
|
2021-01-03 22:22:21 -06:00
|
|
|
if (delayed_move_time && ELAPSED(ms, delayed_move_time) && IsRunning()) {
|
2013-08-07 09:10:26 -05:00
|
|
|
// travel moves have been received so enact them
|
|
|
|
delayed_move_time = 0xFFFFFFFFUL; // force moves to be done
|
2019-09-29 04:25:39 -05:00
|
|
|
destination = current_position;
|
2020-03-01 16:59:04 -06:00
|
|
|
prepare_line_to_destination();
|
2021-01-03 22:07:29 -06:00
|
|
|
planner.synchronize();
|
2013-08-07 09:10:26 -05:00
|
|
|
}
|
2013-10-20 05:12:35 -05:00
|
|
|
#endif
|
2015-04-03 17:31:35 -05:00
|
|
|
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(TEMP_STAT_LEDS, handle_status_leds());
|
2015-04-03 17:31:35 -05:00
|
|
|
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(MONITOR_DRIVER_STATUS, monitor_tmc_drivers());
|
2017-03-06 23:00:43 -06:00
|
|
|
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(MONITOR_L6470_DRIVER_STATUS, L64xxManager.monitor_driver());
|
2019-01-23 19:06:54 -06:00
|
|
|
|
2017-11-15 19:01:52 -06: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-26 21:03:13 -06:00
|
|
|
|
|
|
|
#if PIN_EXISTS(FET_SAFETY)
|
|
|
|
static millis_t FET_next;
|
|
|
|
if (ELAPSED(ms, FET_next)) {
|
2020-01-08 20:00:06 -06:00
|
|
|
FET_next = ms + FET_SAFETY_DELAY; // 2µs pulse every FET_SAFETY_DELAY mS
|
2019-02-26 21:03:13 -06:00
|
|
|
OUT_WRITE(FET_SAFETY_PIN, !FET_SAFETY_INVERTED);
|
|
|
|
DELAY_US(2);
|
|
|
|
WRITE(FET_SAFETY_PIN, FET_SAFETY_INVERTED);
|
|
|
|
}
|
|
|
|
#endif
|
2012-11-06 05:06:41 -06:00
|
|
|
}
|
|
|
|
|
2016-09-13 02:11:45 -05:00
|
|
|
/**
|
2020-04-04 00:08:25 -05: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 02:15:43 -05:00
|
|
|
* - Update the Průša MMU2
|
2020-04-04 00:08:25 -05:00
|
|
|
* - Handle Joystick jogging
|
2016-09-13 02:11:45 -05:00
|
|
|
*/
|
2020-04-02 01:22:48 -05:00
|
|
|
void idle(TERN_(ADVANCED_PAUSE_FEATURE, bool no_stepper_sleep/*=false*/)) {
|
2020-12-07 04:04:38 -06:00
|
|
|
#if ENABLED(MARLIN_DEV_MODE)
|
2021-01-31 17:21:27 -06:00
|
|
|
static uint16_t idle_depth = 0;
|
|
|
|
if (++idle_depth > 5) SERIAL_ECHOLNPAIR("idle() call depth: ", idle_depth);
|
2020-12-07 04:04:38 -06:00
|
|
|
#endif
|
2020-04-04 00:08:25 -05:00
|
|
|
|
|
|
|
// Core Marlin activities
|
|
|
|
manage_inactivity(TERN_(ADVANCED_PAUSE_FEATURE, no_stepper_sleep));
|
|
|
|
|
|
|
|
// Manage Heaters (and Watchdog)
|
|
|
|
thermalManager.manage_heater();
|
|
|
|
|
|
|
|
// Max7219 heartbeat, animation, etc
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(MAX7219_DEBUG, max7219.idle_tasks());
|
2020-04-04 00:08:25 -05:00
|
|
|
|
|
|
|
// Return if setup() isn't completed
|
2020-12-07 04:04:38 -06:00
|
|
|
if (marlin_state == MF_INITIALIZING) goto IDLE_DONE;
|
2020-04-04 00:08:25 -05:00
|
|
|
|
|
|
|
// Handle filament runout sensors
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(HAS_FILAMENT_SENSOR, runout.run());
|
2020-04-04 00:08:25 -05:00
|
|
|
|
|
|
|
// Run HAL idle tasks
|
2020-11-18 01:27:21 -06:00
|
|
|
TERN_(HAL_IDLETASK, HAL_idletask());
|
2020-04-04 00:08:25 -05:00
|
|
|
|
2020-10-20 14:35:29 -05:00
|
|
|
// Check network connection
|
|
|
|
TERN_(HAS_ETHERNET, ethernet.check());
|
|
|
|
|
2020-04-02 01:22:48 -05:00
|
|
|
// Handle Power-Loss Recovery
|
2019-09-10 18:52:41 -05:00
|
|
|
#if ENABLED(POWER_LOSS_RECOVERY) && PIN_EXISTS(POWER_LOSS)
|
2020-07-15 01:14:03 -05:00
|
|
|
if (printJobOngoing()) recovery.outage();
|
2019-09-10 18:52:41 -05:00
|
|
|
#endif
|
2019-08-04 22:22:58 -05:00
|
|
|
|
2020-04-02 01:22:48 -05:00
|
|
|
// Run StallGuard endstop checks
|
2019-08-04 22:22:58 -05:00
|
|
|
#if ENABLED(SPI_ENDSTOPS)
|
2019-08-09 17:00:20 -05:00
|
|
|
if (endstops.tmc_spi_homing.any
|
2020-04-02 01:22:48 -05:00
|
|
|
&& TERN1(IMPROVE_HOMING_RELIABILITY, ELAPSED(millis(), sg_guard_period))
|
|
|
|
) LOOP_L_N(i, 4) // Read SGT 4 times per idle loop
|
2019-08-04 22:22:58 -05:00
|
|
|
if (endstops.tmc_spi_homing_check()) break;
|
|
|
|
#endif
|
|
|
|
|
2020-04-04 00:08:25 -05:00
|
|
|
// Handle SD Card insert / remove
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(SDSUPPORT, card.manage_media());
|
2017-08-25 17:03:07 -05:00
|
|
|
|
2020-04-04 00:08:25 -05:00
|
|
|
// Handle USB Flash Drive insert / remove
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(USB_FLASH_DRIVE_SUPPORT, Sd2Card::idle());
|
2016-11-08 18:03:40 -06:00
|
|
|
|
2020-04-02 01:22:48 -05:00
|
|
|
// Announce Host Keepalive state (if any)
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(HOST_KEEPALIVE_FEATURE, gcode.host_keepalive());
|
2016-11-08 18:03:40 -06:00
|
|
|
|
2020-04-02 01:22:48 -05:00
|
|
|
// Update the Print Job Timer state
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(PRINTCOUNTER, print_job_timer.tick());
|
2016-09-13 02:11:45 -05:00
|
|
|
|
2020-04-02 01:22:48 -05:00
|
|
|
// Update the Beeper queue
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(USE_BEEPER, buzzer.tick());
|
2017-06-09 07:06:23 -05:00
|
|
|
|
2020-06-21 02:40:16 -05:00
|
|
|
// Handle UI input / draw events
|
|
|
|
TERN(DWIN_CREALITY_LCD, DWIN_Update(), ui.update());
|
2020-04-04 00:08:25 -05:00
|
|
|
|
2020-04-02 01:22:48 -05:00
|
|
|
// Run i2c Position Encoders
|
2017-06-09 07:06:23 -05:00
|
|
|
#if ENABLED(I2C_POSITION_ENCODERS)
|
2020-12-07 04:04:38 -06:00
|
|
|
{
|
2018-02-08 03:57:11 -06:00
|
|
|
static millis_t i2cpem_next_update_ms;
|
2019-07-24 01:52:36 -05: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 07:06:23 -05:00
|
|
|
}
|
2020-12-07 04:04:38 -06:00
|
|
|
}
|
2017-06-09 07:06:23 -05:00
|
|
|
#endif
|
2017-12-20 23:22:08 -06:00
|
|
|
|
2020-04-02 01:22:48 -05:00
|
|
|
// Auto-report Temperatures / SD Status
|
2018-03-07 01:57:09 -06:00
|
|
|
#if HAS_AUTO_REPORTING
|
2020-02-20 20:09:37 -06:00
|
|
|
if (!gcode.autoreport_paused) {
|
2021-01-28 20:40:20 -06:00
|
|
|
TERN_(AUTO_REPORT_TEMPERATURES, thermalManager.auto_reporter.tick());
|
|
|
|
TERN_(AUTO_REPORT_SD_STATUS, card.auto_reporter.tick());
|
2018-03-07 01:57:09 -06:00
|
|
|
}
|
|
|
|
#endif
|
2018-07-02 10:06:17 -05:00
|
|
|
|
2020-08-26 02:15:43 -05:00
|
|
|
// Update the Průša MMU2
|
2020-11-18 01:27:21 -06:00
|
|
|
TERN_(HAS_PRUSA_MMU2, mmu2.mmu_loop());
|
2019-09-08 00:55:34 -05:00
|
|
|
|
2020-04-02 01:22:48 -05:00
|
|
|
// Handle Joystick jogging
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(POLL_JOG, joystick.inject_jog_moves());
|
2020-05-11 19:22:41 -05:00
|
|
|
|
|
|
|
// Direct Stepping
|
|
|
|
TERN_(DIRECT_STEPPING, page_manager.write_responses());
|
2020-06-15 21:05:33 -05:00
|
|
|
|
2020-11-18 01:27:21 -06:00
|
|
|
// Update the LVGL interface
|
|
|
|
TERN_(HAS_TFT_LVGL_UI, LV_TASK_HANDLER());
|
2020-12-07 04:04:38 -06:00
|
|
|
|
|
|
|
IDLE_DONE:
|
|
|
|
TERN_(MARLIN_DEV_MODE, idle_depth--);
|
|
|
|
return;
|
2016-09-13 02:11:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Kill all activity and lock the machine.
|
|
|
|
* After this the machine will need to be reset.
|
|
|
|
*/
|
2019-10-09 19:46:10 -05:00
|
|
|
void kill(PGM_P const lcd_error/*=nullptr*/, PGM_P const lcd_component/*=nullptr*/, const bool steppers_off/*=false*/) {
|
2017-03-21 09:06:01 -05:00
|
|
|
thermalManager.disable_all_heaters();
|
2017-03-28 19:45:54 -05:00
|
|
|
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(HAS_CUTTER, cutter.kill()); // Full cutter shutdown including ISR control
|
2020-04-02 19:31:08 -05:00
|
|
|
|
2020-02-26 03:02:03 -06:00
|
|
|
SERIAL_ERROR_MSG(STR_ERR_KILLED);
|
2018-10-19 13:30:37 -05:00
|
|
|
|
2019-05-07 20:32:50 -05:00
|
|
|
#if HAS_DISPLAY
|
2019-11-09 21:17:18 -06:00
|
|
|
ui.kill_screen(lcd_error ?: GET_TEXT(MSG_KILLED), lcd_component ?: NUL_STR);
|
2015-10-04 10:33:55 -05:00
|
|
|
#else
|
2019-10-09 19:46:10 -05:00
|
|
|
UNUSED(lcd_error);
|
|
|
|
UNUSED(lcd_component);
|
2015-05-20 15:03:16 -05:00
|
|
|
#endif
|
2015-05-20 13:53:48 -05:00
|
|
|
|
2020-09-20 20:55:02 -05:00
|
|
|
#if HAS_TFT_LVGL_UI
|
|
|
|
lv_draw_error_message(lcd_error);
|
|
|
|
#endif
|
|
|
|
|
2017-07-27 23:42:01 -05:00
|
|
|
#ifdef ACTION_ON_KILL
|
2019-01-27 22:43:13 -06:00
|
|
|
host_action_kill();
|
2017-07-02 03:44:24 -05:00
|
|
|
#endif
|
2017-07-06 21:24:30 -05:00
|
|
|
|
2019-08-28 00:51:01 -05:00
|
|
|
minkill(steppers_off);
|
2018-10-18 21:20:56 -05:00
|
|
|
}
|
|
|
|
|
2019-08-28 00:51:01 -05:00
|
|
|
void minkill(const bool steppers_off/*=false*/) {
|
2018-10-18 21:20:56 -05:00
|
|
|
|
2018-10-20 01:44:46 -05:00
|
|
|
// Wait a short time (allows messages to get out before shutting down.
|
2018-10-21 13:43:21 -05:00
|
|
|
for (int i = 1000; i--;) DELAY_US(600);
|
2018-10-20 01:44:46 -05:00
|
|
|
|
|
|
|
cli(); // Stop interrupts
|
|
|
|
|
|
|
|
// Wait to ensure all interrupts stopped
|
2018-10-21 13:43:21 -05:00
|
|
|
for (int i = 1000; i--;) DELAY_US(250);
|
2018-10-18 21:20:56 -05:00
|
|
|
|
2019-08-28 00:51:01 -05:00
|
|
|
// Reiterate heaters off
|
|
|
|
thermalManager.disable_all_heaters();
|
|
|
|
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(HAS_CUTTER, cutter.kill()); // Reiterate cutter shutdown
|
2020-04-02 19:31:08 -05:00
|
|
|
|
2019-08-28 00:51:01 -05:00
|
|
|
// Power off all steppers (for M112) or just the E steppers
|
|
|
|
steppers_off ? disable_all_steppers() : disable_e_steppers();
|
2018-10-18 21:20:56 -05:00
|
|
|
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(PSU_CONTROL, PSU_OFF());
|
2015-03-30 18:50:05 -05:00
|
|
|
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(HAS_SUICIDE, suicide());
|
2017-09-27 04:40:48 -05:00
|
|
|
|
2019-03-10 09:57:38 -05:00
|
|
|
#if HAS_KILL
|
|
|
|
|
|
|
|
// Wait for kill to be released
|
2020-05-05 03:31:03 -05:00
|
|
|
while (kill_state()) watchdog_refresh();
|
2019-03-10 09:57:38 -05:00
|
|
|
|
|
|
|
// Wait for kill to be pressed
|
2020-05-05 03:31:03 -05:00
|
|
|
while (!kill_state()) watchdog_refresh();
|
2019-03-10 09:57:38 -05:00
|
|
|
|
2020-04-02 19:31:08 -05:00
|
|
|
void (*resetFunc)() = 0; // Declare resetFunc() at address 0
|
2019-09-16 20:27:04 -05:00
|
|
|
resetFunc(); // Jump to address 0
|
2019-03-10 09:57:38 -05:00
|
|
|
|
2020-04-02 19:31:08 -05:00
|
|
|
#else
|
2019-03-10 09:57:38 -05:00
|
|
|
|
2020-04-02 19:31:08 -05:00
|
|
|
for (;;) watchdog_refresh(); // Wait for reset
|
2019-03-10 09:57:38 -05:00
|
|
|
|
2020-04-02 19:31:08 -05:00
|
|
|
#endif
|
2012-11-06 05:06:41 -06:00
|
|
|
}
|
|
|
|
|
2016-09-13 02:11:45 -05:00
|
|
|
/**
|
|
|
|
* Turn off heaters and stop the print in progress
|
|
|
|
* After a stop the machine may be resumed with M999
|
|
|
|
*/
|
2016-04-18 02:05:22 -05:00
|
|
|
void stop() {
|
2017-05-07 06:06:06 -05:00
|
|
|
thermalManager.disable_all_heaters(); // 'unpause' taken care of in here
|
2021-01-25 08:32:58 -06:00
|
|
|
|
2018-10-18 21:20:56 -05:00
|
|
|
print_job_timer.stop();
|
2017-05-07 06:06:06 -05:00
|
|
|
|
|
|
|
#if ENABLED(PROBING_FANS_OFF)
|
2019-01-12 00:41:48 -06:00
|
|
|
if (thermalManager.fans_paused) thermalManager.set_fans_paused(false); // put things back the way they were
|
2017-05-07 06:06:06 -05:00
|
|
|
#endif
|
|
|
|
|
2015-05-17 03:47:02 -05:00
|
|
|
if (IsRunning()) {
|
2020-02-26 03:02:03 -06:00
|
|
|
SERIAL_ERROR_MSG(STR_ERR_STOPPED);
|
2015-05-17 03:47:02 -05:00
|
|
|
LCD_MESSAGEPGM(MSG_STOPPED);
|
2017-04-01 00:23:14 -05:00
|
|
|
safe_delay(350); // allow enough time for messages to get out before stopping
|
2020-03-14 18:47:44 -05:00
|
|
|
marlin_state = MF_STOPPED;
|
2012-11-06 05:06:41 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-24 21:19:04 -05: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
|
|
|
|
#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-11 20:21:54 -05:00
|
|
|
/**
|
|
|
|
* Marlin entry-point: Set up before the program loop
|
|
|
|
* - Set up the kill pin, filament runout, power hold
|
|
|
|
* - Start the serial port
|
|
|
|
* - Print startup messages and diagnostics
|
|
|
|
* - Get EEPROM or default settings
|
|
|
|
* - Initialize managers for:
|
|
|
|
* • temperature
|
|
|
|
* • planner
|
|
|
|
* • watchdog
|
|
|
|
* • stepper
|
|
|
|
* • photo pin
|
|
|
|
* • servos
|
|
|
|
* • LCD controller
|
|
|
|
* • Digipot I2C
|
|
|
|
* • Z probe sled
|
|
|
|
* • status LEDs
|
2020-03-07 00:16:33 -06:00
|
|
|
* • Max7219
|
2016-09-11 20:21:54 -05:00
|
|
|
*/
|
|
|
|
void setup() {
|
2021-02-25 04:35:18 -06:00
|
|
|
#ifdef BOARD_PREINIT
|
|
|
|
BOARD_PREINIT(); // Low-level init (before serial init)
|
|
|
|
#endif
|
2016-09-11 20:21:54 -05:00
|
|
|
|
2020-09-24 21:19:04 -05:00
|
|
|
tmc_standby_setup(); // TMC Low Power Standby pins must be set early or they're not usable
|
|
|
|
|
2020-04-16 03:36:53 -05:00
|
|
|
#if ENABLED(MARLIN_DEV_MODE)
|
|
|
|
auto log_current_ms = [&](PGM_P const msg) {
|
|
|
|
SERIAL_ECHO_START();
|
2020-06-22 21:12:45 -05:00
|
|
|
SERIAL_CHAR('['); SERIAL_ECHO(millis()); SERIAL_ECHOPGM("] ");
|
2020-04-16 03:36:53 -05:00
|
|
|
serialprintPGM(msg);
|
|
|
|
SERIAL_EOL();
|
|
|
|
};
|
|
|
|
#define SETUP_LOG(M) log_current_ms(PSTR(M))
|
|
|
|
#else
|
|
|
|
#define SETUP_LOG(...) NOOP
|
|
|
|
#endif
|
|
|
|
#define SETUP_RUN(C) do{ SETUP_LOG(STRINGIFY(C)); C; }while(0)
|
|
|
|
|
2021-01-31 16:50:12 -06:00
|
|
|
MYSERIAL0.begin(BAUDRATE);
|
|
|
|
millis_t serial_connect_timeout = millis() + 1000UL;
|
|
|
|
while (!MYSERIAL0.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
|
|
|
|
|
|
|
#if HAS_MULTI_SERIAL && !HAS_ETHERNET
|
|
|
|
MYSERIAL1.begin(BAUDRATE);
|
|
|
|
serial_connect_timeout = millis() + 1000UL;
|
|
|
|
while (!MYSERIAL1.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
|
|
|
#endif
|
|
|
|
SERIAL_ECHOLNPGM("start");
|
|
|
|
|
2021-01-25 08:50:39 -06: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
|
|
|
|
|
|
|
|
#if HAS_SUICIDE
|
|
|
|
SETUP_LOG("SUICIDE_PIN");
|
|
|
|
OUT_WRITE(SUICIDE_PIN, !SUICIDE_PIN_INVERTING);
|
|
|
|
#endif
|
|
|
|
|
2020-04-11 21:29:52 -05:00
|
|
|
#if EITHER(DISABLE_DEBUG, DISABLE_JTAG)
|
2018-09-29 19:00:49 -05:00
|
|
|
// Disable any hardware debug to free up pins for IO
|
2020-04-11 21:29:52 -05:00
|
|
|
#if ENABLED(DISABLE_DEBUG) && defined(JTAGSWD_DISABLE)
|
2018-09-29 19:00:49 -05:00
|
|
|
JTAGSWD_DISABLE();
|
|
|
|
#elif defined(JTAG_DISABLE)
|
|
|
|
JTAG_DISABLE();
|
|
|
|
#else
|
2020-04-11 21:29:52 -05:00
|
|
|
#error "DISABLE_(DEBUG|JTAG) is not supported for the selected MCU/Board."
|
2018-09-29 19:00:49 -05:00
|
|
|
#endif
|
2020-04-11 21:29:52 -05:00
|
|
|
#endif
|
|
|
|
|
2020-11-19 15:51:53 -06:00
|
|
|
#if BOTH(HAS_TFT_LVGL_UI, MKS_WIFI_MODULE)
|
2020-09-20 20:55:02 -05:00
|
|
|
mks_esp_wifi_init();
|
|
|
|
WIFISERIAL.begin(WIFI_BAUDRATE);
|
|
|
|
serial_connect_timeout = millis() + 1000UL;
|
|
|
|
while (/*!WIFISERIAL && */PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
|
|
|
#endif
|
|
|
|
|
2021-02-20 20:22:20 -06:00
|
|
|
TERN_(DYNAMIC_VECTORTABLE, hook_cpu_exceptions()); // If supported, install Marlin exception handlers at runtime
|
|
|
|
|
2020-04-11 21:29:52 -05:00
|
|
|
SETUP_RUN(HAL_init());
|
|
|
|
|
2021-02-08 19:51:57 -06:00
|
|
|
// Init and disable SPI thermocouples; this is still needed
|
|
|
|
#if TEMP_SENSOR_0_IS_MAX_TC
|
2020-11-11 16:27:45 -06:00
|
|
|
OUT_WRITE(MAX6675_SS_PIN, HIGH); // Disable
|
|
|
|
#endif
|
2021-02-08 19:51:57 -06:00
|
|
|
#if TEMP_SENSOR_1_IS_MAX_TC
|
2020-11-11 16:27:45 -06:00
|
|
|
OUT_WRITE(MAX6675_SS2_PIN, HIGH); // Disable
|
|
|
|
#endif
|
|
|
|
|
2020-08-23 02:07:42 -05:00
|
|
|
#if ENABLED(DUET_SMART_EFFECTOR) && PIN_EXISTS(SMART_EFFECTOR_MOD)
|
2020-04-11 21:29:52 -05:00
|
|
|
OUT_WRITE(SMART_EFFECTOR_MOD_PIN, LOW); // Put Smart Effector into NORMAL mode
|
2016-09-11 20:21:54 -05:00
|
|
|
#endif
|
|
|
|
|
2019-02-12 20:08:34 -06:00
|
|
|
#if HAS_FILAMENT_SENSOR
|
2020-04-11 21:29:52 -05:00
|
|
|
SETUP_RUN(runout.setup());
|
2016-09-11 20:21:54 -05:00
|
|
|
#endif
|
|
|
|
|
2021-02-27 13:50:44 -06:00
|
|
|
#if ENABLED(PSU_CONTROL)
|
|
|
|
SETUP_LOG("PSU_CONTROL");
|
|
|
|
powersupply_on = ENABLED(PSU_DEFAULT_OFF);
|
|
|
|
if (ENABLED(PSU_DEFAULT_OFF)) PSU_OFF(); else PSU_ON();
|
|
|
|
#endif
|
|
|
|
|
2019-08-20 02:40:44 -05:00
|
|
|
#if ENABLED(POWER_LOSS_RECOVERY)
|
2020-04-11 21:29:52 -05:00
|
|
|
SETUP_RUN(recovery.setup());
|
2019-08-20 02:40:44 -05:00
|
|
|
#endif
|
|
|
|
|
2021-02-27 13:50:44 -06:00
|
|
|
#if HAS_L64XX
|
|
|
|
SETUP_RUN(L64xxManager.init()); // Set up SPI, init drivers
|
|
|
|
#endif
|
|
|
|
|
2019-07-08 22:59:51 -05:00
|
|
|
#if HAS_TMC220x
|
2020-04-11 21:29:52 -05:00
|
|
|
SETUP_RUN(tmc_serial_begin());
|
2019-05-26 06:07:12 -05:00
|
|
|
#endif
|
2019-06-04 23:18:51 -05:00
|
|
|
|
2016-09-11 20:21:54 -05:00
|
|
|
#if HAS_STEPPER_RESET
|
2020-04-11 21:29:52 -05:00
|
|
|
SETUP_RUN(disableStepperDrivers());
|
2016-09-11 20:21:54 -05:00
|
|
|
#endif
|
|
|
|
|
2020-02-08 21:01:57 -06:00
|
|
|
#if HAS_TMC_SPI
|
2018-10-03 02:48:49 -05:00
|
|
|
#if DISABLED(TMC_USE_SW_SPI)
|
2020-04-16 03:36:53 -05:00
|
|
|
SETUP_RUN(SPI.begin());
|
2018-10-03 02:48:49 -05:00
|
|
|
#endif
|
2020-04-16 03:36:53 -05:00
|
|
|
SETUP_RUN(tmc_init_cs_pins());
|
2018-02-10 14:08:53 -06:00
|
|
|
#endif
|
|
|
|
|
2018-07-01 23:11:42 -05:00
|
|
|
#ifdef BOARD_INIT
|
2020-04-16 03:36:53 -05:00
|
|
|
SETUP_LOG("BOARD_INIT");
|
2018-07-01 23:11:42 -05:00
|
|
|
BOARD_INIT();
|
|
|
|
#endif
|
|
|
|
|
2020-04-16 03:55:33 -05:00
|
|
|
SETUP_RUN(esp_wifi_init());
|
|
|
|
|
2016-09-11 20:21:54 -05:00
|
|
|
// Check startup - does nothing if bootloader sets MCUSR to 0
|
2020-04-11 21:29:52 -05:00
|
|
|
const byte mcu = HAL_get_reset_source();
|
2020-06-29 01:02:36 -05:00
|
|
|
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);
|
2017-06-17 18:36:10 -05:00
|
|
|
HAL_clear_reset_source();
|
|
|
|
|
2020-02-08 22:25:24 -06:00
|
|
|
serialprintPGM(GET_TEXT(MSG_MARLIN));
|
2016-09-12 17:49:35 -05:00
|
|
|
SERIAL_CHAR(' ');
|
|
|
|
SERIAL_ECHOLNPGM(SHORT_BUILD_VERSION);
|
2017-06-09 10:51:23 -05:00
|
|
|
SERIAL_EOL();
|
2016-09-12 17:49:35 -05:00
|
|
|
#if defined(STRING_DISTRIBUTION_DATE) && defined(STRING_CONFIG_H_AUTHOR)
|
2019-09-26 03:47:26 -05:00
|
|
|
SERIAL_ECHO_MSG(
|
2020-09-10 20:44:13 -05:00
|
|
|
" Last Updated: " STRING_DISTRIBUTION_DATE
|
|
|
|
" | Author: " STRING_CONFIG_H_AUTHOR
|
2019-09-26 03:47:26 -05:00
|
|
|
);
|
2016-09-12 17:49:35 -05:00
|
|
|
#endif
|
2020-09-10 20:44:13 -05:00
|
|
|
SERIAL_ECHO_MSG("Compiled: " __DATE__);
|
2021-02-08 00:37:24 -06:00
|
|
|
SERIAL_ECHO_MSG(STR_FREE_MEMORY, freeMemory(), STR_PLANNER_BUFFER_BYTES, sizeof(block_t) * (BLOCK_BUFFER_SIZE));
|
2016-09-11 20:21:54 -05:00
|
|
|
|
2021-02-05 22:43:51 -06:00
|
|
|
// Some HAL need precise delay adjustment
|
|
|
|
calibrate_delay_loop();
|
|
|
|
|
2020-09-30 20:14:19 -05:00
|
|
|
// Init buzzer pin(s)
|
|
|
|
#if USE_BEEPER
|
|
|
|
SETUP_RUN(buzzer.init());
|
|
|
|
#endif
|
|
|
|
|
2019-09-25 18:41:04 -05:00
|
|
|
// Set up LEDs early
|
|
|
|
#if HAS_COLOR_LEDS
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(leds.setup());
|
2019-09-25 18:41:04 -05:00
|
|
|
#endif
|
|
|
|
|
2020-08-27 14:18:16 -05:00
|
|
|
#if ENABLED(NEOPIXEL2_SEPARATE)
|
|
|
|
SETUP_RUN(leds2.setup());
|
|
|
|
#endif
|
|
|
|
|
2020-03-18 13:41:12 -05:00
|
|
|
#if ENABLED(USE_CONTROLLER_FAN) // Set up fan controller to initialize also the default configurations.
|
|
|
|
SETUP_RUN(controllerFan.setup());
|
|
|
|
#endif
|
|
|
|
|
2020-04-11 21:29:52 -05:00
|
|
|
// UI must be initialized before EEPROM
|
|
|
|
// (because EEPROM code calls the UI).
|
|
|
|
|
2020-06-16 01:45:27 -05:00
|
|
|
#if ENABLED(DWIN_CREALITY_LCD)
|
|
|
|
delay(800); // Required delay (since boot?)
|
|
|
|
SERIAL_ECHOPGM("\nDWIN handshake ");
|
|
|
|
if (DWIN_Handshake()) SERIAL_ECHOLNPGM("ok."); else SERIAL_ECHOLNPGM("error.");
|
|
|
|
DWIN_Frame_SetDir(1); // Orientation 90°
|
|
|
|
DWIN_UpdateLCD(); // Show bootscreen (first image)
|
|
|
|
#else
|
|
|
|
SETUP_RUN(ui.init());
|
2020-09-28 01:13:27 -05:00
|
|
|
#if HAS_WIRED_LCD && ENABLED(SHOW_BOOTSCREEN)
|
2020-06-16 01:45:27 -05:00
|
|
|
SETUP_RUN(ui.show_bootscreen());
|
|
|
|
#endif
|
|
|
|
SETUP_RUN(ui.reset_status()); // Load welcome message early. (Retained if no errors exist.)
|
|
|
|
#endif
|
2020-03-07 22:33:38 -06:00
|
|
|
|
2020-12-27 16:23:18 -06:00
|
|
|
#if ENABLED(PROBE_TARE)
|
|
|
|
SETUP_RUN(probe.tare_init());
|
|
|
|
#endif
|
|
|
|
|
2020-04-04 00:08:25 -05:00
|
|
|
#if BOTH(SDSUPPORT, SDCARD_EEPROM_EMULATION)
|
|
|
|
SETUP_RUN(card.mount()); // Mount media with settings before first_load
|
2020-03-07 22:33:38 -06:00
|
|
|
#endif
|
|
|
|
|
|
|
|
SETUP_RUN(settings.first_load()); // Load data from EEPROM if available (or use defaults)
|
|
|
|
// This also updates variables in the planner, elsewhere
|
|
|
|
|
2020-10-20 14:35:29 -05:00
|
|
|
#if HAS_ETHERNET
|
|
|
|
SETUP_RUN(ethernet.init());
|
|
|
|
#endif
|
|
|
|
|
2020-11-15 16:39:58 -06:00
|
|
|
#if HAS_TOUCH_BUTTONS
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(touch.init());
|
2019-07-14 18:16:26 -05:00
|
|
|
#endif
|
|
|
|
|
2020-04-22 16:35:03 -05:00
|
|
|
TERN_(HAS_M206_COMMAND, current_position += home_offset); // Init current position based on home_offset
|
2016-09-11 20:21:54 -05:00
|
|
|
|
2020-03-07 22:33:38 -06:00
|
|
|
sync_plan_position(); // Vital to init stepper/planner equivalent for current_position
|
2016-09-11 20:21:54 -05:00
|
|
|
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(thermalManager.init()); // Initialize temperature loop
|
2016-09-11 20:21:54 -05:00
|
|
|
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(print_job_timer.init()); // Initial setup of print job timer
|
2018-03-04 21:23:43 -06:00
|
|
|
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(endstops.init()); // Init endstops and pullups
|
2018-05-16 02:08:43 -05:00
|
|
|
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(stepper.init()); // Init stepper. This enables interrupts!
|
2017-09-08 15:35:25 -05:00
|
|
|
|
|
|
|
#if HAS_SERVOS
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(servo_init());
|
2017-09-08 15:35:25 -05:00
|
|
|
#endif
|
2016-09-11 20:21:54 -05:00
|
|
|
|
2018-04-01 23:54:12 -05:00
|
|
|
#if HAS_Z_SERVO_PROBE
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(probe.servo_probe_init());
|
2017-11-19 13:39:46 -06:00
|
|
|
#endif
|
|
|
|
|
2016-11-01 06:24:21 -05:00
|
|
|
#if HAS_PHOTOGRAPH
|
|
|
|
OUT_WRITE(PHOTOGRAPH_PIN, LOW);
|
|
|
|
#endif
|
|
|
|
|
2019-06-27 23:06:49 -05:00
|
|
|
#if HAS_CUTTER
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(cutter.init());
|
2017-04-07 13:52:45 -05:00
|
|
|
#endif
|
|
|
|
|
2019-06-13 18:43:11 -05: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-11 20:21:54 -05:00
|
|
|
#if HAS_BED_PROBE
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(endstops.enable_z_probe(false));
|
2016-09-11 20:21:54 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAS_STEPPER_RESET
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(enableStepperDrivers());
|
2016-09-11 20:21:54 -05:00
|
|
|
#endif
|
|
|
|
|
2020-10-11 14:58:35 -05:00
|
|
|
#if HAS_MOTOR_CURRENT_I2C
|
|
|
|
SETUP_RUN(digipot_i2c.init());
|
2016-09-11 20:21:54 -05:00
|
|
|
#endif
|
|
|
|
|
2020-10-11 14:58:35 -05:00
|
|
|
#if ENABLED(HAS_MOTOR_CURRENT_DAC)
|
|
|
|
SETUP_RUN(stepper_dac.init());
|
2016-09-11 20:21:54 -05:00
|
|
|
#endif
|
|
|
|
|
2019-03-16 23:43:06 -05:00
|
|
|
#if EITHER(Z_PROBE_SLED, SOLENOID_PROBE) && HAS_SOLENOID_1
|
2018-10-01 18:33:52 -05:00
|
|
|
OUT_WRITE(SOL1_PIN, LOW); // OFF
|
2017-04-14 16:36:02 -05:00
|
|
|
#endif
|
2016-09-11 20:21:54 -05:00
|
|
|
|
2017-07-02 02:26:49 -05:00
|
|
|
#if HAS_HOME
|
|
|
|
SET_INPUT_PULLUP(HOME_PIN);
|
|
|
|
#endif
|
2016-09-11 20:21:54 -05:00
|
|
|
|
2016-09-24 15:33:29 -05:00
|
|
|
#if PIN_EXISTS(STAT_LED_RED)
|
2018-10-01 18:33:52 -05:00
|
|
|
OUT_WRITE(STAT_LED_RED_PIN, LOW); // OFF
|
2016-09-11 20:21:54 -05:00
|
|
|
#endif
|
|
|
|
|
2016-09-24 15:33:29 -05:00
|
|
|
#if PIN_EXISTS(STAT_LED_BLUE)
|
2018-10-01 18:33:52 -05:00
|
|
|
OUT_WRITE(STAT_LED_BLUE_PIN, LOW); // OFF
|
2016-09-11 20:21:54 -05:00
|
|
|
#endif
|
|
|
|
|
2020-08-06 08:14:00 -05:00
|
|
|
#if ENABLED(CASE_LIGHT_ENABLE)
|
2021-02-27 16:06:48 -06:00
|
|
|
SETUP_RUN(caselight.init());
|
2019-01-15 18:50:56 -06:00
|
|
|
#endif
|
|
|
|
|
2020-11-18 01:27:21 -06:00
|
|
|
#if HAS_PRUSA_MMU1
|
|
|
|
SETUP_LOG("Prusa MMU1");
|
2017-06-02 13:57:31 -05:00
|
|
|
SET_OUTPUT(E_MUX0_PIN);
|
|
|
|
SET_OUTPUT(E_MUX1_PIN);
|
|
|
|
SET_OUTPUT(E_MUX2_PIN);
|
|
|
|
#endif
|
2017-08-25 17:03:07 -05:00
|
|
|
|
2017-08-15 07:48:10 -05:00
|
|
|
#if HAS_FANMUX
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(fanmux_init());
|
2017-08-15 07:48:10 -05:00
|
|
|
#endif
|
2017-08-25 17:03:07 -05:00
|
|
|
|
2018-10-16 03:38:57 -05:00
|
|
|
#if ENABLED(MIXING_EXTRUDER)
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(mixer.init());
|
2016-09-11 20:21:54 -05:00
|
|
|
#endif
|
|
|
|
|
2017-01-21 18:10:02 -06:00
|
|
|
#if ENABLED(BLTOUCH)
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(bltouch.init(/*set_voltage=*/true));
|
2017-01-21 18:10:02 -06:00
|
|
|
#endif
|
|
|
|
|
2017-06-09 07:06:23 -05:00
|
|
|
#if ENABLED(I2C_POSITION_ENCODERS)
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(I2CPEM.init());
|
2017-06-09 07:06:23 -05:00
|
|
|
#endif
|
|
|
|
|
2016-09-11 20:21:54 -05:00
|
|
|
#if ENABLED(EXPERIMENTAL_I2CBUS) && I2C_SLAVE_ADDRESS > 0
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_LOG("i2c...");
|
2016-09-11 20:21:54 -05:00
|
|
|
i2c.onReceive(i2c_on_receive);
|
|
|
|
i2c.onRequest(i2c_on_request);
|
|
|
|
#endif
|
2016-11-05 16:38:48 -05:00
|
|
|
|
2018-05-18 13:16:59 -05:00
|
|
|
#if DO_SWITCH_EXTRUDER
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(move_extruder_servo(0)); // Initialize extruder servo
|
2017-06-04 08:40:57 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(SWITCHING_NOZZLE)
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_LOG("SWITCHING_NOZZLE");
|
2019-02-04 00:19:56 -06: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 08:40:57 -05:00
|
|
|
#endif
|
2017-08-21 16:30:08 -05:00
|
|
|
|
2019-02-06 06:30:53 -06:00
|
|
|
#if ENABLED(MAGNETIC_PARKING_EXTRUDER)
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(mpe_settings_init());
|
2019-02-06 06:30:53 -06:00
|
|
|
#endif
|
|
|
|
|
2017-08-13 16:35:59 -05:00
|
|
|
#if ENABLED(PARKING_EXTRUDER)
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(pe_solenoid_init());
|
2017-08-13 16:35:59 -05:00
|
|
|
#endif
|
2018-03-08 17:34:50 -06:00
|
|
|
|
2020-03-08 16:13:41 -05:00
|
|
|
#if ENABLED(SWITCHING_TOOLHEAD)
|
2020-04-20 00:01:14 -05:00
|
|
|
SETUP_RUN(swt_init());
|
2020-03-08 16:13:41 -05:00
|
|
|
#endif
|
|
|
|
|
2019-07-01 05:55:23 -05:00
|
|
|
#if ENABLED(ELECTROMAGNETIC_SWITCHING_TOOLHEAD)
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(est_init());
|
2019-07-01 05:55:23 -05:00
|
|
|
#endif
|
|
|
|
|
2018-11-16 20:47:07 -06:00
|
|
|
#if ENABLED(USE_WATCHDOG)
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(watchdog_init()); // Reinit watchdog after HAL_get_reset_source call
|
2018-03-08 17:34:50 -06:00
|
|
|
#endif
|
2018-09-08 12:08:31 -05:00
|
|
|
|
|
|
|
#if ENABLED(EXTERNAL_CLOSED_LOOP_CONTROLLER)
|
2020-06-28 13:48:48 -05:00
|
|
|
SETUP_RUN(closedloop.init());
|
2018-09-08 12:08:31 -05:00
|
|
|
#endif
|
2018-09-12 03:49:46 -05:00
|
|
|
|
2019-08-14 21:05:15 -05:00
|
|
|
#ifdef STARTUP_COMMANDS
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_LOG("STARTUP_COMMANDS");
|
2019-08-14 21:05:15 -05:00
|
|
|
queue.inject_P(PSTR(STARTUP_COMMANDS));
|
|
|
|
#endif
|
|
|
|
|
2019-09-27 17:06:26 -05:00
|
|
|
#if ENABLED(HOST_PROMPT_SUPPORT)
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(host_action_prompt_end());
|
2019-09-27 17:06:26 -05:00
|
|
|
#endif
|
|
|
|
|
2020-03-02 12:03:43 -06:00
|
|
|
#if HAS_TRINAMIC_CONFIG && DISABLED(PSU_DEFAULT_OFF)
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(test_tmc_connection(true, true, true, true));
|
2018-12-09 20:54:48 -06:00
|
|
|
#endif
|
2019-01-31 19:10:52 -06:00
|
|
|
|
2020-11-18 01:27:21 -06:00
|
|
|
#if HAS_PRUSA_MMU2
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(mmu2.init());
|
2020-02-26 03:04:02 -06:00
|
|
|
#endif
|
2020-03-07 00:16:33 -06:00
|
|
|
|
2020-06-16 01:45:27 -05:00
|
|
|
#if ENABLED(IIC_BL24CXX_EEPROM)
|
|
|
|
BL24CXX::init();
|
|
|
|
const uint8_t err = BL24CXX::check();
|
2020-07-24 03:09:14 -05:00
|
|
|
SERIAL_ECHO_TERNARY(err, "BL24CXX Check ", "failed", "succeeded", "!\n");
|
2020-06-16 01:45:27 -05:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(DWIN_CREALITY_LCD)
|
|
|
|
Encoder_Configuration();
|
|
|
|
HMI_Init();
|
|
|
|
HMI_StartFrame(true);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if HAS_SERVICE_INTERVALS && DISABLED(DWIN_CREALITY_LCD)
|
|
|
|
ui.reset_status(true); // Show service messages or keep current status
|
|
|
|
#endif
|
|
|
|
|
2020-03-07 00:16:33 -06:00
|
|
|
#if ENABLED(MAX7219_DEBUG)
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_RUN(max7219.init());
|
2020-03-07 00:16:33 -06:00
|
|
|
#endif
|
2020-03-07 22:33:38 -06:00
|
|
|
|
2020-05-11 19:22:41 -05:00
|
|
|
#if ENABLED(DIRECT_STEPPING)
|
|
|
|
SETUP_RUN(page_manager.init());
|
|
|
|
#endif
|
|
|
|
|
2020-07-25 00:52:07 -05:00
|
|
|
#if HAS_TFT_LVGL_UI
|
2020-08-03 21:55:37 -05:00
|
|
|
#if ENABLED(SDSUPPORT)
|
|
|
|
if (!card.isMounted()) SETUP_RUN(card.mount()); // Mount SD to load graphics and fonts
|
|
|
|
#endif
|
2020-06-15 21:05:33 -05:00
|
|
|
SETUP_RUN(tft_lvgl_init());
|
|
|
|
#endif
|
|
|
|
|
2020-08-08 20:00:42 -05:00
|
|
|
#if ENABLED(PASSWORD_ON_STARTUP)
|
|
|
|
SETUP_RUN(password.lock_machine()); // Will not proceed until correct password provided
|
|
|
|
#endif
|
|
|
|
|
2020-11-15 16:39:58 -06:00
|
|
|
#if BOTH(HAS_LCD_MENU, TOUCH_SCREEN_CALIBRATION) && EITHER(TFT_CLASSIC_UI, TFT_COLOR_UI)
|
|
|
|
ui.check_touch_calibration();
|
|
|
|
#endif
|
|
|
|
|
2020-03-14 18:47:44 -05:00
|
|
|
marlin_state = MF_RUNNING;
|
|
|
|
|
2020-03-07 22:33:38 -06:00
|
|
|
SETUP_LOG("setup() completed.");
|
2016-09-11 20:21:54 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The main Marlin program loop
|
|
|
|
*
|
2020-02-25 22:18:14 -06: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-11 20:21:54 -05:00
|
|
|
*/
|
|
|
|
void loop() {
|
2020-01-01 21:13:43 -06:00
|
|
|
do {
|
|
|
|
idle();
|
2019-08-05 20:33:15 -05:00
|
|
|
|
2018-05-01 01:01:02 -05:00
|
|
|
#if ENABLED(SDSUPPORT)
|
2019-10-29 16:00:17 -05:00
|
|
|
if (card.flag.abort_sd_printing) abortSDPrinting();
|
2020-03-28 03:18:53 -05:00
|
|
|
if (marlin_state == MF_SD_COMPLETE) finishSDPrinting();
|
2019-10-29 16:00:17 -05:00
|
|
|
#endif
|
2018-04-15 18:27:54 -05:00
|
|
|
|
2019-06-19 00:00:19 -05:00
|
|
|
queue.advance();
|
2019-10-29 16:00:17 -05:00
|
|
|
|
2018-07-11 17:33:26 -05:00
|
|
|
endstops.event_handler();
|
2020-01-01 21:13:43 -06:00
|
|
|
|
2020-07-25 00:52:07 -05:00
|
|
|
TERN_(HAS_TFT_LVGL_UI, printer_state_polling());
|
2020-06-15 21:05:33 -05:00
|
|
|
|
2020-03-07 22:20:41 -06:00
|
|
|
} while (ENABLED(__AVR__)); // Loop forever on slower (AVR) boards
|
2016-09-11 20:21:54 -05:00
|
|
|
}
|