Browse Source

Refuse to run TM calibration if the printer is not idle

Yuri D'Elia 2 years ago
parent
commit
ea0840dee9
3 changed files with 11 additions and 1 deletions
  1. 2 0
      Firmware/Marlin.h
  2. 4 0
      Firmware/Marlin_main.cpp
  3. 5 1
      Firmware/temperature.cpp

+ 2 - 0
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

+ 4 - 0
Firmware/Marlin_main.cpp

@@ -572,6 +572,10 @@ void servo_init()
   #endif
 }
 
+bool printer_active()
+{
+    return PRINTER_ACTIVE;
+}
 
 bool fans_check_enabled = true;
 

+ 5 - 1
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