Skip to content

Commit

Permalink
G80: Call temp_compensation_stop only if retraction took place
Browse files Browse the repository at this point in the history
  • Loading branch information
gudnimg committed Aug 16, 2023
1 parent d819a0b commit 154fe4e
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions Firmware/Marlin_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ static void gcode_G28(bool home_x_axis, bool home_y_axis, bool home_z_axis);
static void gcode_M105();

#ifndef PINDA_THERMISTOR
static void temp_compensation_start();
static bool temp_compensation_start();
static void temp_compensation_apply();
#endif

Expand Down Expand Up @@ -2838,9 +2838,10 @@ static void gcode_G80()
bool magnet_elimination = (eeprom_read_byte((uint8_t*)EEPROM_MBL_MAGNET_ELIMINATION) > 0);

#ifndef PINDA_THERMISTOR
static bool temp_compensation_retracted = false;
if (run == false && eeprom_read_byte((uint8_t *)EEPROM_TEMP_CAL_ACTIVE) && calibration_status_pinda() == true && target_temperature_bed >= 50)
{
temp_compensation_start();
temp_compensation_retracted = temp_compensation_start();
run = true;
repeatcommand_front(); // repeat G80 with all its parameters
enquecommand_front_P(G28W);
Expand Down Expand Up @@ -3161,9 +3162,13 @@ static void gcode_G80()
// SERIAL_ECHOLNPGM("Mesh bed leveling activated");
go_home_with_z_lift();
// SERIAL_ECHOLNPGM("Go home finished");
//unretract (after PINDA preheat retraction)
#ifndef PINDA_THERMISTOR
temp_compensation_stop();
//unretract (after PINDA preheat retraction)
if (temp_compensation_retracted) {
temp_compensation_retracted = false;
current_position[E_AXIS] += default_retraction;
plan_buffer_line_curposXYZE(400);
}
#endif // !PINDA_THERMISTOR
KEEPALIVE_STATE(NOT_BUSY);
// Restore custom message state
Expand Down Expand Up @@ -10237,13 +10242,14 @@ void bed_analysis(float x_dimension, float y_dimension, int x_points_num, int y_
#endif //HEATBED_ANALYSIS

#ifndef PINDA_THERMISTOR
static void temp_compensation_start() {

static bool temp_compensation_start() {
bool retracted = false;
custom_message_type = CustomMsg::TempCompPreheat;
custom_message_state = PINDA_HEAT_T + 1;
lcd_update(2);
if ((int)degHotend(active_extruder) > extrude_min_temp) {
current_position[E_AXIS] -= default_retraction;
retracted = true;
}
plan_buffer_line_curposXYZE(400);

Expand All @@ -10262,15 +10268,7 @@ static void temp_compensation_start() {
}
custom_message_type = CustomMsg::Status;
custom_message_state = 0;
}

static void temp_compensation_stop()
{
//unretract (after PINDA preheat retraction)
if (((int)degHotend(active_extruder) > extrude_min_temp) && eeprom_read_byte((unsigned char *)EEPROM_TEMP_CAL_ACTIVE) && calibration_status_pinda() && (target_temperature_bed >= 50)) {
current_position[E_AXIS] += default_retraction;
plan_buffer_line_curposXYZE(400);
}
return retracted;
}

static void temp_compensation_apply() {
Expand Down

0 comments on commit 154fe4e

Please sign in to comment.