Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LCD_BED_TRAMMING fixes #25425

Merged
merged 31 commits into from
Mar 18, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
9b6fc48
Fix LCD_BED_TRAMMING
Farva42 Feb 24, 2023
78c59c0
Update menu_bed_corners.cpp
Farva42 Feb 24, 2023
532cef0
Fix bad definition
Farva42 Feb 24, 2023
85ee6d9
Fix un-garded bool use
Farva42 Feb 24, 2023
993adf4
Fix BLTOUCH guarding
Farva42 Feb 25, 2023
927bc43
add CI test
thinkyhead Feb 25, 2023
eb00519
Don't use 'N' as a G-code word
thinkyhead Feb 25, 2023
c34384e
probe.* cleanup
thinkyhead Feb 25, 2023
bc40c0d
misc formatting
thinkyhead Feb 25, 2023
d6c0ad7
distinct *_leveling_was_active
thinkyhead Feb 25, 2023
a081650
escape from _lcd_level_bed_corners
thinkyhead Feb 25, 2023
4ff4e4f
fix up _lcd_draw_level_prompt
thinkyhead Feb 25, 2023
830105e
misc. followup
thinkyhead Feb 25, 2023
b031452
Distinguish DONE from BACK
thinkyhead Feb 26, 2023
f054389
deploy_probe() calls ui.goto…
thinkyhead Feb 26, 2023
a021e01
avoid low hop
thinkyhead Feb 27, 2023
06fdb23
Change STOW_BETWEEN_PROBES
Farva42 Mar 3, 2023
e54c6b7
Add current_position back in
Farva42 Mar 4, 2023
c8dc3b3
rename
thinkyhead Mar 7, 2023
bebb507
cleanup
thinkyhead Mar 7, 2023
ec8e4c3
Catch fringe case
Farva42 Mar 12, 2023
63e3601
use BOTH
thinkyhead Mar 15, 2023
feeb45d
rename var
thinkyhead Mar 15, 2023
fc4da6e
🎨 Misc. formatting
thinkyhead Mar 14, 2023
8ba8894
Merge branch 'bugfix-2.1.x' into pr/25425
thinkyhead Mar 15, 2023
30322b8
tweaks
thinkyhead Mar 15, 2023
3070cd6
Merge branch 'bugfix-2.1.x' into pr/25425
thinkyhead Mar 15, 2023
78b0c76
expand _lcd_goto_next_corner
thinkyhead Mar 15, 2023
a63038f
Fix looping & pull current_position.z from hop
Farva42 Mar 17, 2023
3b22010
final touch
thinkyhead Mar 18, 2023
d483145
Merge branch 'bugfix-2.1.x' into pr/25425
thinkyhead Mar 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Marlin/src/gcode/probe/M401_M402.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@
* With BLTOUCH_HS_MODE:
* H Report the current BLTouch HS mode state and exit
* S<bool> Set High Speed (HS) Mode and exit without deploy
*
* N<bool> True no return to prior location. Default is false
*/
void GcodeSuite::M401() {
const bool seenH = parser.seen_test('H'),
seenS = parser.seen('S');
seenS = parser.seen('S'),
seenN = parser.seen('N');
if (seenH || seenS) {
#ifdef BLTOUCH_HS_MODE
if (seenS) bltouch.high_speed_mode = parser.value_bool();
Expand All @@ -51,7 +54,8 @@ void GcodeSuite::M401() {
#endif
}
else {
probe.deploy();
if (seenN) probe.deploy(true);
else probe.deploy();
TERN_(PROBE_TARE, probe.tare());
report_current_position();
}
Expand All @@ -61,7 +65,9 @@ void GcodeSuite::M401() {
* M402: Deactivate and stow the Z probe
*/
void GcodeSuite::M402() {
probe.stow();
const bool seenN = parser.seen('N');
if (seenN) probe.stow(true);
else probe.stow();
probe.move_z_after_probing();
report_current_position();
}
Expand Down
122 changes: 84 additions & 38 deletions Marlin/src/lcd/menu/menu_bed_corners.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ constexpr xy_pos_t lf { (X_MIN_BED) + inset_lfrb[0], (Y_MIN_BED) + inset_lfrb[1]
rb { (X_MAX_BED) - inset_lfrb[2], (Y_MAX_BED) - inset_lfrb[3] };

static int8_t bed_corner;
xy_pos_t corner_point;

/**
* Select next corner coordinates
Expand All @@ -105,45 +106,44 @@ static void _lcd_level_bed_corners_get_next_position() {
switch (bed_corner) {
case 0 ... 1:
// First two corners set explicitly by the configuration
current_position = lf; // Left front
corner_point = lf; // Left front
switch (lco[bed_corner]) {
case RF: current_position.x = rb.x; break; // Right Front
case RB: current_position = rb; break; // Right Back
case LB: current_position.y = rb.y; break; // Left Back
case RF: corner_point.x = rb.x; break; // Right Front
case RB: corner_point = rb; break; // Right Back
case LB: corner_point.y = rb.y; break; // Left Back
}
break;

case 2:
// Determine which edge to probe for 3rd point
current_position.set(lf.x + (rb.x - lf.x) / 2, lf.y + (rb.y - lf.y) / 2);
if ((lco[0] == LB && lco[1] == RB) || (lco[0] == RB && lco[1] == LB)) current_position.y = lf.y; // Front Center
if ((lco[0] == LF && lco[1] == LB) || (lco[0] == LB && lco[1] == LF)) current_position.x = rb.x; // Center Right
if ((lco[0] == RF && lco[1] == RB) || (lco[0] == RB && lco[1] == RF)) current_position.x = lf.x; // Left Center
if ((lco[0] == LF && lco[1] == RF) || (lco[0] == RF && lco[1] == LF)) current_position.y = rb.y; // Center Back
corner_point.set(lf.x + (rb.x - lf.x) / 2, lf.y + (rb.y - lf.y) / 2);
if ((lco[0] == LB && lco[1] == RB) || (lco[0] == RB && lco[1] == LB)) corner_point.y = lf.y; // Front Center
if ((lco[0] == LF && lco[1] == LB) || (lco[0] == LB && lco[1] == LF)) corner_point.x = rb.x; // Center Right
if ((lco[0] == RF && lco[1] == RB) || (lco[0] == RB && lco[1] == RF)) corner_point.x = lf.x; // Left Center
if ((lco[0] == LF && lco[1] == RF) || (lco[0] == RF && lco[1] == LF)) corner_point.y = rb.y; // Center Back
#if DISABLED(BED_TRAMMING_INCLUDE_CENTER) && ENABLED(BED_TRAMMING_USE_PROBE)
bed_corner++; // Must increment the count to ensure it resets the loop if the 3rd point is out of tolerance
#endif
break;

#if ENABLED(BED_TRAMMING_INCLUDE_CENTER)
case 3:
current_position.set(X_CENTER, Y_CENTER);
corner_point.set(X_CENTER, Y_CENTER);
break;
#endif
}
}
else {
// Four-Corner Bed Tramming with optional center
if (TERN0(BED_TRAMMING_INCLUDE_CENTER, bed_corner == center_index)) {
current_position.set(X_CENTER, Y_CENTER);
TERN_(BED_TRAMMING_USE_PROBE, good_points--); // Decrement to allow one additional probe point
corner_point.set(X_CENTER, Y_CENTER);
}
else {
current_position = lf; // Left front
corner_point = lf; // Left front
switch (lco[bed_corner]) {
case RF: current_position.x = rb.x; break; // Right front
case RB: current_position = rb; break; // Right rear
case LB: current_position.y = rb.y; break; // Left rear
case RF: corner_point.x = rb.x; break; // Right front
case RB: corner_point = rb; break; // Right rear
case LB: corner_point.y = rb.y; break; // Left rear
}
}
}
Expand Down Expand Up @@ -208,9 +208,15 @@ static void _lcd_level_bed_corners_get_next_position() {
if (!ui.should_draw()) return;
MenuItem_confirm::select_screen(
GET_TEXT_F(TERN(HAS_LEVELING, MSG_BUTTON_LEVEL, MSG_BUTTON_DONE)),
TERN(HAS_LEVELING, GET_TEXT_F(MSG_BUTTON_BACK), nullptr)
, []{ queue.inject(TERN(HAS_LEVELING, F("G29N"), FPSTR(G28_STR))); ui.return_to_status(); }
, TERN(HAS_LEVELING, ui.goto_previous_screen_no_defer, []{})
TERN(HAS_LEVELING, GET_TEXT_F(MSG_BUTTON_DONE), nullptr)
, []{ TERN(HAS_LEVELING, []{queue.inject(F("G29N")); corner_probing_done = true;}, queue.inject(FPSTR(G28_STR))); ui.goto_previous_screen_no_defer();}
, []{
TERN(HAS_LEVELING, ui.goto_previous_screen_no_defer(), []{});
#if HAS_STOWABLE_PROBE && DISABLED(BLTOUCH)
probe.stow(true);
#endif
corner_probing_done = true;
}
, GET_TEXT_F(MSG_BED_TRAMMING_IN_RANGE)
);
}
Expand All @@ -229,6 +235,9 @@ static void _lcd_level_bed_corners_get_next_position() {
last_z = current_position.z; // Above tolerance. Set a new Z for subsequent corners.
good_points = 0; // ...and start over
}
#if HAS_STOWABLE_PROBE && DISABLED(BLTOUCH)
if (good_points == (nr_edge_points-1))do_blocking_move_to_z(current_position.z + BED_TRAMMING_Z_HOP) // Get the probe off the bed to let it be stowed
#endif
return true; // probe triggered
}
do_blocking_move_to_z(last_z); // go back to tolerance middle point before raise
Expand Down Expand Up @@ -267,9 +276,8 @@ static void _lcd_level_bed_corners_get_next_position() {
do_blocking_move_to_z(current_position.z + BED_TRAMMING_Z_HOP + TERN0(BLTOUCH, bltouch.z_extra_clearance())); // clearance

_lcd_level_bed_corners_get_next_position(); // Select next corner coordinates
current_position -= probe.offset_xy; // Account for probe offsets
do_blocking_move_to_xy(current_position); // Goto corner

corner_point -= probe.offset_xy; // Account for probe offsets
do_blocking_move_to_xy(corner_point); // Goto corner
TERN_(BLTOUCH, if (bltouch.high_speed_mode) bltouch.deploy()); // Deploy in HIGH SPEED MODE
if (!_lcd_level_bed_corners_probe()) { // Probe down to tolerance
if (_lcd_level_bed_corners_raise()) { // Prompt user to raise bed if needed
Expand Down Expand Up @@ -311,21 +319,35 @@ static void _lcd_level_bed_corners_get_next_position() {
// Select next corner coordinates
_lcd_level_bed_corners_get_next_position();

line_to_current_position(manual_feedrate_mm_s.x);
do_blocking_move_to(corner_point, manual_feedrate_mm_s.x);
line_to_z(BED_TRAMMING_HEIGHT);
if (++bed_corner >= available_points) bed_corner = 0;
}

#endif // !BED_TRAMMING_USE_PROBE

static void _lcd_level_bed_corners_homing() {
_lcd_draw_homing();
void _lcd_level_bed_corners_homing() {
#if HAS_STOWABLE_PROBE && DISABLED(BLTOUCH)
if (!all_axes_homed() && probe.deploy) return;
#else
if (!all_axes_homed()) return;
#endif
#if HAS_LEVELING // Disable leveling so the planner won't mess with us
leveling_was_active = planner.leveling_active;
set_bed_leveling_enabled(false);
#endif
#if ENABLED(BED_TRAMMING_USE_PROBE)
_lcd_test_corners();
if (corner_probing_done) ui.goto_previous_screen_no_defer();
if (!corner_probing_done)_lcd_test_corners();
#if HAS_STOWABLE_PROBE && DISABLED(BLTOUCH)
if (corner_probing_done) {ui.goto_previous_screen_no_defer(); probe.stow(true);}
#else
if (corner_probing_done) {ui.goto_previous_screen_no_defer()}
#endif
corner_probing_done = true;
TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_was_active));
endstops.enable_z_probe(false);
#if ENABLED(BLTOUCH)
endstops.enable_z_probe(false);
#endif
#else
bed_corner = 0;
ui.goto_screen([]{
Expand All @@ -346,20 +368,44 @@ static void _lcd_level_bed_corners_homing() {
#endif
}

void _lcd_level_bed_corners() {
ui.defer_status_screen();
if (!all_axes_trusted()) {
set_all_unhomed();
queue.inject_P(G28_STR);
#if HAS_STOWABLE_PROBE && DISABLED(BLTOUCH)
void _deploy_probe() {
if (ui.should_draw()) {
constexpr uint8_t line = (LCD_HEIGHT - 1) / 2;
MenuItem_static::draw(line, GET_TEXT_F(MSG_MANUAL_DEPLOY));
}
}

// Disable leveling so the planner won't mess with us
#if HAS_LEVELING
leveling_was_active = planner.leveling_active;
set_bed_leveling_enabled(false);
void deploy_probe() {
if (!corner_probing_done) probe.deploy(true);
ui.goto_screen([]{
_deploy_probe();
if(!probe.deploy() && !corner_probing_done) {
_lcd_level_bed_corners_homing();
}
});

}

#endif

void _lcd_level_bed_corners() {
#if ENABLED(BED_TRAMMING_USE_PROBE)
corner_probing_done = false;
#endif
ui.defer_status_screen();
set_all_unhomed();
queue.inject(TERN(CAN_SET_LEVELING_AFTER_G28, F("G28L0"), FPSTR(G28_STR)));
ui.goto_screen([]{
_lcd_draw_homing();
if (all_axes_homed())
#if HAS_STOWABLE_PROBE && DISABLED(BLTOUCH)
deploy_probe();
#else
_lcd_level_bed_corners_homing();
#endif
});

ui.goto_screen(_lcd_level_bed_corners_homing);
}

#endif // HAS_MARLINUI_MENU && LCD_BED_TRAMMING
7 changes: 4 additions & 3 deletions Marlin/src/module/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,11 +495,12 @@ void Probe::probe_error_stop() {
*
* Return TRUE if the probe could not be deployed/stowed
*/
bool Probe::set_deployed(const bool deploy) {
bool Probe::set_deployed(const bool deploy, const bool no_mem = false) {

if (DEBUGGING(LEVELING)) {
DEBUG_POS("Probe::set_deployed", current_position);
DEBUG_ECHOLNPGM("deploy: ", deploy);
DEBUG_ECHOLNPGM("no_mem: ", no_mem);
}

if (endstops.z_probe_enabled == deploy) return false;
Expand All @@ -523,7 +524,7 @@ bool Probe::set_deployed(const bool deploy) {
}
#endif

const xy_pos_t old_xy = current_position;
const xy_pos_t old_xy = current_position; //remember location before call

#if ENABLED(PROBE_TRIGGERED_WHEN_STOWED_TEST)

Expand Down Expand Up @@ -552,7 +553,7 @@ bool Probe::set_deployed(const bool deploy) {
// If preheating is required before any probing...
TERN_(PREHEAT_BEFORE_PROBING, if (deploy) preheat_for_probing(PROBING_NOZZLE_TEMP, PROBING_BED_TEMP));

do_blocking_move_to(old_xy);
if (!no_mem)do_blocking_move_to(old_xy); // only return to call location if needed
endstops.enable_z_probe(deploy);
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/module/probe.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class Probe {

static void probe_error_stop();

static bool set_deployed(const bool deploy);
static bool set_deployed(const bool deploy, const bool no_mem);

#if IS_KINEMATIC

Expand Down Expand Up @@ -182,7 +182,7 @@ class Probe {

static constexpr xyz_pos_t offset = xyz_pos_t(NUM_AXIS_ARRAY_1(0)); // See #16767

static bool set_deployed(const bool) { return false; }
static bool set_deployed(const bool, const bool no_mem = false) { return false; }

static bool can_reach(const_float_t rx, const_float_t ry, const bool=true) { return position_is_reachable(rx, ry); }

Expand Down Expand Up @@ -216,8 +216,8 @@ class Probe {
static constexpr xy_pos_t offset_xy = xy_pos_t({ 0, 0 }); // See #16767
#endif

static bool deploy() { return set_deployed(true); }
static bool stow() { return set_deployed(false); }
static bool deploy(bool no_mem =false) { return set_deployed(true, no_mem); }
static bool stow(bool no_mem =false) { return set_deployed(false, no_mem); }

#if HAS_BED_PROBE || HAS_LEVELING
#if IS_KINEMATIC
Expand Down
3 changes: 2 additions & 1 deletion buildroot/tests/BIGTREE_GTR_V1_0
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ opt_set E0_AUTO_FAN_PIN PC10 E1_AUTO_FAN_PIN PC11 E2_AUTO_FAN_PIN PC12 NEOPIXEL_
FIL_RUNOUT6_PIN 8 FIL_RUNOUT7_PIN 9 FIL_RUNOUT8_PIN 10 FIL_RUNOUT4_STATE HIGH FIL_RUNOUT8_STATE HIGH \
FILAMENT_RUNOUT_SCRIPT '"M600 T%c"'
opt_enable REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER BLTOUCH NEOPIXEL_LED Z_SAFE_HOMING NOZZLE_PARK_FEATURE ADVANCED_PAUSE_FEATURE \
FILAMENT_RUNOUT_SENSOR FIL_RUNOUT4_PULLUP FIL_RUNOUT8_PULLUP FILAMENT_CHANGE_RESUME_ON_INSERT PAUSE_REHEAT_FAST_RESUME
FILAMENT_RUNOUT_SENSOR FIL_RUNOUT4_PULLUP FIL_RUNOUT8_PULLUP FILAMENT_CHANGE_RESUME_ON_INSERT PAUSE_REHEAT_FAST_RESUME \
LCD_BED_TRAMMING BED_TRAMMING_USE_PROBE
exec_test $1 $2 "BigTreeTech GTR | 8 Extruders | Auto-Fan | Mixed TMC Drivers | Runout Sensors w/ distinct states" "$3"

restore_configs
Expand Down