Ver Fonte

Save/restore temperatures during a thermal pause

Re-used saved_* vars (as normally used during the paused state) to
backup the original values when a thermal error occurs.
Yuri D'Elia há 2 anos atrás
pai
commit
eccfcd7424
3 ficheiros alterados com 19 adições e 2 exclusões
  1. 3 0
      Firmware/Marlin.h
  2. 10 2
      Firmware/Marlin_main.cpp
  3. 6 0
      Firmware/temperature.cpp

+ 3 - 0
Firmware/Marlin.h

@@ -338,6 +338,9 @@ extern uint8_t saved_printing_type;
 #define PRINTING_TYPE_USB 1
 #define PRINTING_TYPE_NONE 2
 
+extern float saved_extruder_temperature; //!< Active extruder temperature
+extern float saved_bed_temperature; //!< Bed temperature
+
 //save/restore printing in case that mmu is not responding
 extern bool mmu_print_saved;
 

+ 10 - 2
Firmware/Marlin_main.cpp

@@ -380,8 +380,8 @@ static float saved_pos[4] = { X_COORD_INVALID, 0, 0, 0 };
 static uint16_t saved_feedrate2 = 0; //!< Default feedrate (truncated from float)
 static int saved_feedmultiply2 = 0;
 static uint8_t saved_active_extruder = 0;
-static float saved_extruder_temperature = 0.0; //!< Active extruder temperature
-static float saved_bed_temperature = 0.0; //!< Bed temperature
+float saved_extruder_temperature = 0.0; //!< Active extruder temperature
+float saved_bed_temperature = 0.0; //!< Bed temperature
 static bool saved_extruder_relative_mode = false;
 static int saved_fanSpeed = 0; //!< Print fan speed
 //! @}
@@ -9991,7 +9991,15 @@ void ThermalStop(bool allow_pause)
         if(allow_pause && (IS_SD_PRINTING || usb_timer.running())) {
             if (!isPrintPaused) {
                 // we cannot make a distinction for the host here, the pause must be instantaneous
+                // so we call the lcd_pause_print to save the print state internally. Thermal errors
+                // disable heaters and save the original temperatures to saved_*, which will get
+                // overwritten by stop_and_save_print_to_ram. For this corner-case, re-instate the
+                // original values after the pause handler is called.
+                float bed_temp = saved_bed_temperature;
+                float ext_temp = saved_extruder_temperature;
                 lcd_pause_print();
+                saved_bed_temperature = bed_temp;
+                saved_extruder_temperature = ext_temp;
             }
         } else {
             // We got a hard thermal error and/or there is no print going on. Just stop.

+ 6 - 0
Firmware/temperature.cpp

@@ -496,6 +496,12 @@ volatile static union
 // - prevent the user to set temperatures until all errors are cleared
 void set_temp_error(TempErrorSource source, uint8_t index, TempErrorType type)
 {
+    // save the original target temperatures for recovery before disabling heaters
+    if(!temp_error_state.error) {
+        saved_bed_temperature = target_temperature_bed;
+        saved_extruder_temperature = target_temperature[index];
+    }
+
     // keep disabling heaters and keep fans on as long as the condition is asserted
     disable_heater();
     hotendFanSetFullSpeed();