From ea0840dee909c02977891d108cf0d7dbdc4bac4b Mon Sep 17 00:00:00 2001 From: Yuri D'Elia Date: Mon, 27 Jun 2022 12:25:38 +0200 Subject: [PATCH] Refuse to run TM calibration if the printer is not idle --- Firmware/Marlin.h | 2 ++ Firmware/Marlin_main.cpp | 4 ++++ Firmware/temperature.cpp | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Firmware/Marlin.h b/Firmware/Marlin.h index bc76988e6..868f9790b 100755 --- a/Firmware/Marlin.h +++ b/Firmware/Marlin.h @@ -358,6 +358,8 @@ extern LongTimer safetyTimer; #define PRINT_PERCENT_DONE_INIT 0xff #define PRINTER_ACTIVE (IS_SD_PRINTING || usb_timer.running() || isPrintPaused || (custom_message_type == CustomMsg::TempCal) || saved_printing || (lcd_commands_type == LcdCommands::Layer1Cal) || mmu_print_saved || homing_flag || mesh_bed_leveling_flag) +extern bool printer_active(); + //! Beware - mcode_in_progress is set as soon as the command gets really processed, //! which is not the same as posting the M600 command into the command queue //! There can be a considerable lag between posting M600 and its real processing which might result diff --git a/Firmware/Marlin_main.cpp b/Firmware/Marlin_main.cpp index 4dda163e2..f05856b0c 100644 --- a/Firmware/Marlin_main.cpp +++ b/Firmware/Marlin_main.cpp @@ -572,6 +572,10 @@ void servo_init() #endif } +bool printer_active() +{ + return PRINTER_ACTIVE; +} bool fans_check_enabled = true; diff --git a/Firmware/temperature.cpp b/Firmware/temperature.cpp index 0e46f1aef..0a95a2194 100755 --- a/Firmware/temperature.cpp +++ b/Firmware/temperature.cpp @@ -2838,7 +2838,11 @@ bool autotune(int16_t cal_temp) void temp_model_autotune(int16_t temp) { - // TODO: ensure printer is idle/queue empty/buffer empty + if(moves_planned() || printer_active()) { + SERIAL_ECHOLNPGM("TM: printer needs to be idle for calibration"); + return; + } + KEEPALIVE_STATE(IN_PROCESS); // disable the model checking during self-calibration