Skip to content

Commit

Permalink
Merge branch 'bugfix-2.0.x' of https://github.com/MarlinFirmware/Marlin
Browse files Browse the repository at this point in the history
… into bugfix-2.0.x
  • Loading branch information
crysxd committed Feb 28, 2020
2 parents a430d32 + c669420 commit 1f8289d
Show file tree
Hide file tree
Showing 16 changed files with 144 additions and 174 deletions.
10 changes: 9 additions & 1 deletion Marlin/src/MarlinCore.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,18 @@ void stop();

void idle(
#if ENABLED(ADVANCED_PAUSE_FEATURE)
bool no_stepper_sleep = false // pass true to keep steppers from disabling on timeout
bool no_stepper_sleep=false // Pass true to keep steppers from timing out
#endif
);

inline void idle_no_sleep() {
idle(
#if ENABLED(ADVANCED_PAUSE_FEATURE)
true
#endif
);
}

#if ENABLED(EXPERIMENTAL_I2CBUS)
#include "feature/twibus.h"
extern TWIBus i2c;
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1249,7 +1249,7 @@
if (isnan(z_values[i][j])) { // Invalid mesh point?

// Skip points the probe can't reach
if (!position_is_reachable_by_probe(mesh_index_to_xpos(i), mesh_index_to_ypos(j)))
if (!probe.can_reach(mesh_index_to_xpos(i), mesh_index_to_ypos(j)))
continue;

found_a_NAN = true;
Expand Down Expand Up @@ -1316,7 +1316,7 @@
// Also for round beds, there are grid points outside the bed the nozzle can't reach.
// Prune them from the list and ignore them till the next Phase (manual nozzle probing).

if (probe_relative ? !position_is_reachable_by_probe(mpos) : !position_is_reachable(mpos))
if (!(probe_relative ? probe.can_reach(mpos) : position_is_reachable(mpos)))
continue;

// Reachable. Check if it's the best_so_far location to the nozzle.
Expand Down
9 changes: 4 additions & 5 deletions Marlin/src/feature/pause.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
#if HAS_BUZZER
filament_change_beep(max_beep_count);
#endif
idle(true);
idle_no_sleep();
}
}

Expand Down Expand Up @@ -280,7 +280,7 @@ bool load_filament(const float &slow_load_length/*=0*/, const float &fast_load_l
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = false;
lcd_pause_show_message(PAUSE_MESSAGE_OPTION);
while (pause_menu_response == PAUSE_RESPONSE_WAIT_FOR) idle(true);
while (pause_menu_response == PAUSE_RESPONSE_WAIT_FOR) idle_no_sleep();
}
#endif

Expand Down Expand Up @@ -541,7 +541,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
#endif

// Wait for LCD click or M108
while (wait_for_user) idle(true);
while (wait_for_user) idle_no_sleep();

#if ENABLED(HOST_PROMPT_SUPPORT)
host_prompt_do(PROMPT_INFO, PSTR("Reheating"));
Expand Down Expand Up @@ -576,8 +576,7 @@ void wait_for_confirmation(const bool is_reload/*=false*/, const int8_t max_beep
filament_change_beep(max_beep_count, true);
#endif
}

idle(true);
idle_no_sleep();
}
#if ENABLED(DUAL_X_CARRIAGE)
active_extruder = saved_ext;
Expand Down
16 changes: 8 additions & 8 deletions Marlin/src/feature/probe_temp_compensation.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,16 +57,16 @@ class ProbeTempComp {
static const temp_calib_t cali_info[TSI_COUNT];

// Where to park nozzle to wait for probe cooldown
static constexpr xyz_pos_t park_point = xyz_pos_t({ PTC_PARK_POS_X, PTC_PARK_POS_Y, PTC_PARK_POS_Z });
static constexpr float park_point_x = PTC_PARK_POS_X,
park_point_y = PTC_PARK_POS_Y,
park_point_z = PTC_PARK_POS_Z,
// XY coordinates of nozzle for probing the bed
measure_point_x = PTC_PROBE_POS_X, // Coordinates to probe
measure_point_y = PTC_PROBE_POS_Y;
//measure_point_x = 12.0f, // Coordinates to probe on MK52 magnetic heatbed
//measure_point_y = 7.3f;

static constexpr int max_bed_temp = PTC_MAX_BED_TEMP, // Max temperature to avoid heating errors

// XY coordinates of nozzle for probing the bed
measure_point_x = PTC_PROBE_POS_X, // X-coordinate to probe
measure_point_y = PTC_PROBE_POS_Y, // Y-coordinate to probe
//measure_point_x = 12.0f, // X-coordinate to probe on MK52 magnetic heatbed
//measure_point_y = 7.3f, // Y-coordinate to probe on MK52 magnetic heatbed

probe_calib_bed_temp = max_bed_temp, // Bed temperature while calibrating probe
bed_calib_probe_temp = 30; // Probe temperature while calibrating bed

Expand Down
14 changes: 2 additions & 12 deletions Marlin/src/gcode/bedlevel/abl/G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -417,17 +417,7 @@ G29_TYPE GcodeSuite::G29() {
);
}

if (
#if IS_SCARA || ENABLED(DELTA)
!position_is_reachable_by_probe(probe_position_lf.x, 0)
|| !position_is_reachable_by_probe(probe_position_rb.x, 0)
|| !position_is_reachable_by_probe(0, probe_position_lf.y)
|| !position_is_reachable_by_probe(0, probe_position_rb.y)
#else
!position_is_reachable_by_probe(probe_position_lf)
|| !position_is_reachable_by_probe(probe_position_rb)
#endif
) {
if (!probe.good_bounds(probe_position_lf, probe_position_rb)) {
SERIAL_ECHOLNPGM("? (L,R,F,B) out of bounds.");
G29_RETURN(false);
}
Expand Down Expand Up @@ -704,7 +694,7 @@ G29_TYPE GcodeSuite::G29() {

#if IS_KINEMATIC
// Avoid probing outside the round or hexagonal area
if (!position_is_reachable_by_probe(probePos)) continue;
if (!probe.can_reach(probePos)) continue;
#endif

if (verbose_level) SERIAL_ECHOLNPAIR("Probing mesh point ", int(pt_index), "/", int(GRID_MAX_POINTS), ".");
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/gcode/calibrate/G34_M422.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,11 +432,11 @@ void GcodeSuite::M422() {
};

if (is_probe_point) {
if (!position_is_reachable_by_probe(pos.x, Y_CENTER)) {
if (!probe.can_reach(pos.x, Y_CENTER)) {
SERIAL_ECHOLNPGM("?(X) out of bounds.");
return;
}
if (!position_is_reachable_by_probe(pos)) {
if (!probe.can_reach(pos)) {
SERIAL_ECHOLNPGM("?(Y) out of bounds.");
return;
}
Expand Down
109 changes: 39 additions & 70 deletions Marlin/src/gcode/calibrate/G76_M871.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,8 @@ void GcodeSuite::G76() {
set_bltouch_deployed(false);
#endif

bool do_bed_cal = parser.boolval('B'),
do_probe_cal = parser.boolval('P');
if (!do_bed_cal && !do_probe_cal)
do_bed_cal = do_probe_cal = true;
bool do_bed_cal = parser.boolval('B'), do_probe_cal = parser.boolval('P');
if (!do_bed_cal && !do_probe_cal) do_bed_cal = do_probe_cal = true;

// Synchronize with planner
planner.synchronize();
Expand All @@ -105,8 +103,8 @@ void GcodeSuite::G76() {

if (do_bed_cal || do_probe_cal) {
// Ensure park position is reachable
if (!position_is_reachable(ProbeTempComp::park_point.x, ProbeTempComp::park_point.y)
|| !(WITHIN(ProbeTempComp::park_point.z, Z_MIN_POS - 0.001f, Z_MAX_POS + 0.001f))
if (!position_is_reachable(temp_comp.park_point_x, temp_comp.park_point_y)
|| !(WITHIN(temp_comp.park_point_z, Z_MIN_POS - 0.001f, Z_MAX_POS + 0.001f))
) {
SERIAL_ECHOLNPGM("!Park position unreachable - aborting.");
return;
Expand All @@ -116,12 +114,12 @@ void GcodeSuite::G76() {
temp_comp.measure_point_x - probe.offset_xy.x,
temp_comp.measure_point_y - probe.offset_xy.y
);
if (!position_is_reachable_by_probe(destination)) {
if (!probe.can_reach(destination)) {
SERIAL_ECHOLNPGM("!Probe position unreachable - aborting.");
return;
}

G28(true);
process_subcommands_now_P(PSTR("G28"));
}

/******************************************
Expand All @@ -133,15 +131,9 @@ void GcodeSuite::G76() {
uint16_t target_bed = temp_comp.cali_info_init[TSI_BED].start_temp,
target_probe = temp_comp.bed_calib_probe_temp;

SERIAL_ECHOLNPGM("Waiting for printer to cool down.");
while (thermalManager.degBed() > target_bed
|| thermalManager.degProbe() > target_probe
) {
idle(
#if ENABLED(ADVANCED_PAUSE_FEATURE)
true
#endif
);
SERIAL_ECHOLNPGM("Waiting for cooling.");
while (thermalManager.degBed() > target_bed || thermalManager.degProbe() > target_probe) {
idle_no_sleep();
const millis_t ms = millis();
if (ELAPSED(ms, next_temp_report)) {
thermalManager.print_heater_states(active_extruder);
Expand All @@ -155,23 +147,19 @@ void GcodeSuite::G76() {
#endif

bool timeout = false;
while (true) {
for (;;) {
thermalManager.setTargetBed(target_bed);

SERIAL_ECHOLNPAIR("Target Bed: ", target_bed, "; Probe: ", target_probe);
SERIAL_ECHOLNPAIR("Target Bed:", target_bed, " Probe:", target_probe);

// Park nozzle
do_blocking_move_to(ProbeTempComp::park_point.x, ProbeTempComp::park_point.y, ProbeTempComp::park_point.z);
do_blocking_move_to(temp_comp.park_point_x, temp_comp.park_point_y, temp_comp.park_point_z);

// Wait for heatbed to reach target temp and probe to cool below target temp
SERIAL_ECHOLNPGM("Waiting for bed and probe to reach target temp.");
SERIAL_ECHOLNPGM("Waiting for bed / probe to reach target.");
const millis_t probe_timeout_ms = millis() + 900UL * 1000UL;
while (fabs(thermalManager.degBed() - float(target_bed)) > 0.1 || thermalManager.degProbe() > target_probe) {
idle(
#if ENABLED(ADVANCED_PAUSE_FEATURE)
true
#endif
);
idle_no_sleep();
const millis_t ms = millis();
if (ELAPSED(ms, next_temp_report)) {
thermalManager.print_heater_states(active_extruder);
Expand All @@ -186,16 +174,12 @@ void GcodeSuite::G76() {

if (timeout) break;

// Move probe to probing point and wait for probe to reach target temp
destination.set(temp_comp.measure_point_x, temp_comp.measure_point_y, 0.5);
do_blocking_move_to(destination.x, destination.y, destination.z);
// Move the nozzle to the probing point and wait for the probe to reach target temp
destination.set(temp_comp.measure_point_x, temp_comp.measure_point_y);
do_blocking_move_to(destination);
SERIAL_ECHOLNPGM("Waiting for probe heating.");
while (thermalManager.degProbe() < target_probe) {
idle(
#if ENABLED(ADVANCED_PAUSE_FEATURE)
true
#endif
);
idle_no_sleep();
const millis_t ms = millis();
if (ELAPSED(ms, next_temp_report)) {
thermalManager.print_heater_states(active_extruder);
Expand All @@ -207,17 +191,14 @@ void GcodeSuite::G76() {
destination.z = 5.0;
do_blocking_move_to_z(destination.z);

// Do a single probe
// Do a single probe at the current position
remember_feedrate_scaling_off();
const float measured_z = probe.probe_at_point(
destination.x + probe.offset_xy.x,
destination.y + probe.offset_xy.y,
PROBE_PT_NONE
);
const xy_pos_t probe_xy = destination + probe.offset_xy;
const float measured_z = probe.probe_at_point(probe_xy, PROBE_PT_NONE);
restore_feedrate_and_scaling();

if (isnan(measured_z)) {
SERIAL_ECHOLNPGM("!Received NAN measurement - aborting.");
SERIAL_ECHOLNPGM("!Received NAN. Aborting.");
break;
}
else
Expand All @@ -236,7 +217,7 @@ void GcodeSuite::G76() {
if (temp_comp.finish_calibration(TSI_BED))
SERIAL_ECHOLNPGM("Successfully calibrated bed.");
else
SERIAL_ECHOLNPGM("!Failed to calibrated bed - reset calibration values.");
SERIAL_ECHOLNPGM("!Failed to calibrate bed. Values reset.");

// Cleanup
thermalManager.setTargetBed(0);
Expand All @@ -252,21 +233,19 @@ void GcodeSuite::G76() {
if (do_probe_cal) {

// Park nozzle
do_blocking_move_to(ProbeTempComp::park_point.x, ProbeTempComp::park_point.y, ProbeTempComp::park_point.z);
do_blocking_move_to(temp_comp.park_point_x, temp_comp.park_point_y, temp_comp.park_point_z);

// Initialize temperatures
uint16_t target_bed = temp_comp.probe_calib_bed_temp,
target_probe = temp_comp.cali_info_init[TSI_PROBE].start_temp;
const uint16_t target_bed = temp_comp.probe_calib_bed_temp;
thermalManager.setTargetBed(target_bed);

uint16_t target_probe = temp_comp.cali_info_init[TSI_PROBE].start_temp;

SERIAL_ECHOLNPGM("Waiting for bed and probe temperature.");
while (fabs(thermalManager.degBed() - float(target_bed)) > 0.1f
|| thermalManager.degProbe() > target_probe
) {
idle(
#if ENABLED(ADVANCED_PAUSE_FEATURE)
true
#endif
);
idle_no_sleep();
const millis_t ms = millis();
if (ELAPSED(ms, next_temp_report)) {
thermalManager.print_heater_states(active_extruder);
Expand All @@ -280,31 +259,23 @@ void GcodeSuite::G76() {
#endif

bool timeout = false;
while (true) {
for (;;) {
// Move probe to probing point and wait for it to reach target temperature
destination.set(temp_comp.measure_point_x, temp_comp.measure_point_y, 0.5);
destination.set(temp_comp.measure_point_x, temp_comp.measure_point_y);
do_blocking_move_to(destination);

SERIAL_ECHOLNPAIR(
"Bed temp: ", target_bed,
"; Probe temp: ", target_probe,
" Waiting for probe heating."
);
SERIAL_ECHOLNPAIR("Waiting for probe heating. Bed:", target_bed, " Probe:", target_probe);

const millis_t probe_timeout_ms = millis() + 900UL * 1000UL;
while (thermalManager.degProbe() < target_probe) {
idle(
#if ENABLED(ADVANCED_PAUSE_FEATURE)
true
#endif
);
idle_no_sleep();
const millis_t ms = millis();
if (ELAPSED(ms, next_temp_report)) {
thermalManager.print_heater_states(active_extruder);
next_temp_report = ms + 1000;
}
if (ELAPSED(ms, probe_timeout_ms)) {
SERIAL_ECHOLNPGM("!Probe heating aborted due to timeout.");
SERIAL_ECHOLNPGM("!Probe heating timed out.");
timeout = true;
break;
}
Expand All @@ -318,11 +289,8 @@ void GcodeSuite::G76() {

// Do a single probe
remember_feedrate_scaling_off();
const float measured_z = probe.probe_at_point(
destination.x + probe.offset_xy.x,
destination.y + probe.offset_xy.y,
PROBE_PT_NONE
);
const xy_pos_t probe_xy = destination + probe.offset_xy;
const float measured_z = probe.probe_at_point(probe_xy, PROBE_PT_NONE);
restore_feedrate_and_scaling();

if (isnan(measured_z)) {
Expand All @@ -343,9 +311,10 @@ void GcodeSuite::G76() {

SERIAL_ECHOLNPAIR("Retrieved measurements: ", temp_comp.get_index());
if (temp_comp.finish_calibration(TSI_PROBE))
SERIAL_ECHOLNPGM("Successfully calibrated probe.");
SERIAL_ECHOPGM("Successfully calibrated");
else
SERIAL_ECHOLNPGM("!Failed to calibrated probe.");
SERIAL_ECHOPGM("!Failed to calibrate");
SERIAL_ECHOLNPGM(" probe.");

// Cleanup
thermalManager.setTargetBed(0);
Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/gcode/calibrate/M48.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ void GcodeSuite::M48() {
xy_float_t next_pos = current_position;

const xy_pos_t probe_pos = {
parser.linearval('X', next_pos.x + probe.offset_xy.x),
parser.linearval('Y', next_pos.y + probe.offset_xy.y)
parser.linearval('X', next_pos.x + probe.offset_xy.x), // If no X use the probe's current X position
parser.linearval('Y', next_pos.y + probe.offset_xy.y) // If no Y, ditto
};

if (!position_is_reachable_by_probe(probe_pos)) {
if (!probe.can_reach(probe_pos)) {
SERIAL_ECHOLNPGM("? (X,Y) out of bounds.");
return;
}
Expand Down Expand Up @@ -179,7 +179,7 @@ void GcodeSuite::M48() {
#else
// If we have gone out too far, we can do a simple fix and scale the numbers
// back in closer to the origin.
while (!position_is_reachable_by_probe(next_pos)) {
while (!probe.can_reach(next_pos)) {
next_pos *= 0.8f;
if (verbose_level > 3)
SERIAL_ECHOLNPAIR_P(PSTR("Moving inward: X"), next_pos.x, SP_Y_STR, next_pos.y);
Expand Down
Loading

0 comments on commit 1f8289d

Please sign in to comment.