Skip to content

Commit

Permalink
G30 Rework
Browse files Browse the repository at this point in the history
  • Loading branch information
kisslorand committed Nov 2, 2022
1 parent cd7fa1f commit f0fac52
Showing 1 changed file with 24 additions and 13 deletions.
37 changes: 24 additions & 13 deletions Marlin/src/gcode/probe/G30.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,27 @@
* E Engage the probe for each probe (default 1)
* C Enable probe temperature compensation (0 or 1, default 1)
*/
void GcodeSuite::G30() {

void GcodeSuite::G30()
{
#if HAS_MULTI_HOTEND
const uint8_t old_tool_index = active_extruder;
tool_change(0);
#endif

const xy_pos_t pos = { parser.linearval('X', current_position.x + probe.offset_xy.x),
parser.linearval('Y', current_position.y + probe.offset_xy.y) };
const xy_pos_t pos = {parser.seenval('X') ? parser.value_linear_units()
#if #define HAS_WORKSPACE_OFFSET
- workspace_offset.x
#endif
: current_position.x,
parser.seenval('Y') ? parser.value_linear_units()
#if HAS_WORKSPACE_OFFSET
- workspace_offset.y
#endif
: current_position.y};

if (!probe.can_reach(pos)) {
#if ENABLED(DWIN_LCD_PROUI)
SERIAL_ECHOLNF(GET_EN_TEXT_F(MSG_ZPROBE_OUT));
LCD_MESSAGE(MSG_ZPROBE_OUT);
#endif
}
else {

if (probe.can_reach(pos))
{
// Disable leveling so the planner won't mess with us
TERN_(HAS_LEVELING, set_bed_leveling_enabled(false));

Expand All @@ -80,10 +84,10 @@ void GcodeSuite::G30() {
const ProbePtRaise raise_after = parser.boolval('E', true) ? PROBE_PT_STOW : PROBE_PT_NONE;

TERN_(HAS_PTC, ptc.set_enabled(!parser.seen('C') || parser.value_bool()));
const float measured_z = probe.probe_at_point(pos, raise_after, 1);
const float measured_z = probe.probe_at_point(pos, raise_after, true, true);
TERN_(HAS_PTC, ptc.set_enabled(true));
if (!isnan(measured_z)) {
SERIAL_ECHOLNPGM("Bed X: ", pos.x, " Y: ", pos.y, " Z: ", measured_z);
SERIAL_ECHOLNPGM("Bed X: ", pos.asLogical().x, " Y: ", pos.asLogical().y, " Z: ", measured_z);
#if EITHER(DWIN_LCD_PROUI, DWIN_CREALITY_LCD_JYERSUI)
char msg[31], str_1[6], str_2[6], str_3[6];
sprintf_P(msg, PSTR("X:%s, Y:%s, Z:%s"),
Expand All @@ -102,6 +106,13 @@ void GcodeSuite::G30() {

report_current_position();
}
#if ENABLED(DWIN_LCD_PROUI)
else
{
SERIAL_ECHOLNF(GET_EN_TEXT_F(MSG_ZPROBE_OUT));
LCD_MESSAGE(MSG_ZPROBE_OUT);
}
#endif

// Restore the active tool
TERN_(HAS_MULTI_HOTEND, tool_change(old_tool_index));
Expand Down

0 comments on commit f0fac52

Please sign in to comment.