Skip to content

Commit

Permalink
stop_and_save_print_to_ram should not overwrite valid partial backup
Browse files Browse the repository at this point in the history
Thermal errors need to take a backup of the target temperatures.
When the print is then later paused, stop_and_save_print_to_ram
should not overwrite the partial backup if it is still valid.

Change in memory:
Flash: -150 bytes
SRAM: 0 bytes
  • Loading branch information
gudnimg committed Nov 3, 2023
1 parent fca93b0 commit a53fd06
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 18 deletions.
23 changes: 8 additions & 15 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9512,16 +9512,8 @@ void ThermalStop(bool allow_recovery)

// 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.
uint8_t bed_temp = saved_bed_temperature;
uint16_t ext_temp = saved_extruder_temperature;
uint8_t fan_speed = saved_fan_speed;
// disable heaters and save the original temperatures to saved_*
lcd_pause_print();
saved_bed_temperature = bed_temp;
saved_extruder_temperature = ext_temp;
saved_fan_speed = fan_speed;
}
} else {
// We got a hard thermal error and/or there is no print going on. Just stop.
Expand Down Expand Up @@ -10559,14 +10551,15 @@ void stop_and_save_print_to_ram(float z_move, float e_move)

planner_abort_hard(); //abort printing

memcpy(saved_pos, current_position, sizeof(saved_pos));
if (!isPartialBackupAvailable) {
refresh_print_state_in_ram();
}

if (pos_invalid) saved_pos[X_AXIS] = X_COORD_INVALID;

saved_feedmultiply2 = feedmultiply; //save feedmultiply
saved_extruder_temperature = (uint16_t)degTargetHotend(active_extruder);
saved_bed_temperature = (uint8_t)degTargetBed();
saved_extruder_relative_mode = axis_relative_modes & E_AXIS_MASK;
saved_fan_speed = fanSpeed;
// Reset partial backup flag, we have a full back-up now
clear_print_state_in_ram();

cmdqueue_reset(); //empty cmdqueue
card.sdprinting = false;
// card.closefile();
Expand Down
4 changes: 1 addition & 3 deletions Firmware/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -512,9 +512,7 @@ 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_printing) {
saved_bed_temperature = target_temperature_bed;
saved_extruder_temperature = target_temperature[index];
saved_fan_speed = fanSpeed;
refresh_print_state_in_ram();
}

// keep disabling heaters and keep fans on as long as the condition is asserted
Expand Down

0 comments on commit a53fd06

Please sign in to comment.