Merge pull request #8575 from thinkyhead/kuru_to_upstream
[2.0.x] Make MBL work more like PROBE_MANUALLY
This commit is contained in:
commit
47099af3ec
@ -36,9 +36,10 @@
|
|||||||
|
|
||||||
#if ENABLED(PROBE_MANUALLY)
|
#if ENABLED(PROBE_MANUALLY)
|
||||||
bool g29_in_progress = false;
|
bool g29_in_progress = false;
|
||||||
#if ENABLED(LCD_BED_LEVELING)
|
#endif
|
||||||
#include "../../lcd/ultralcd.h"
|
|
||||||
#endif
|
#if ENABLED(LCD_BED_LEVELING)
|
||||||
|
#include "../../lcd/ultralcd.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(G26_MESH_VALIDATION)
|
#if ENABLED(G26_MESH_VALIDATION)
|
||||||
@ -273,7 +274,7 @@ void reset_bed_level() {
|
|||||||
current_position[X_AXIS] = rx;
|
current_position[X_AXIS] = rx;
|
||||||
current_position[Y_AXIS] = ry;
|
current_position[Y_AXIS] = ry;
|
||||||
|
|
||||||
#if ENABLED(PROBE_MANUALLY) && ENABLED(LCD_BED_LEVELING)
|
#if ENABLED(LCD_BED_LEVELING)
|
||||||
lcd_wait_for_move = false;
|
lcd_wait_for_move = false;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -41,18 +41,6 @@
|
|||||||
// Save 130 bytes with non-duplication of PSTR
|
// Save 130 bytes with non-duplication of PSTR
|
||||||
void echo_not_entered() { SERIAL_PROTOCOLLNPGM(" not entered."); }
|
void echo_not_entered() { SERIAL_PROTOCOLLNPGM(" not entered."); }
|
||||||
|
|
||||||
void mesh_probing_done() {
|
|
||||||
mbl.has_mesh = true;
|
|
||||||
gcode.home_all_axes();
|
|
||||||
set_bed_leveling_enabled(true);
|
|
||||||
#if ENABLED(MESH_G28_REST_ORIGIN)
|
|
||||||
current_position[Z_AXIS] = Z_MIN_POS;
|
|
||||||
set_destination_from_current();
|
|
||||||
buffer_line_to_destination(homing_feedrate(Z_AXIS));
|
|
||||||
stepper.synchronize();
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* G29: Mesh-based Z probe, probes a grid and produces a
|
* G29: Mesh-based Z probe, probes a grid and produces a
|
||||||
* mesh to compensate for variable bed height
|
* mesh to compensate for variable bed height
|
||||||
@ -102,7 +90,7 @@ void GcodeSuite::G29() {
|
|||||||
case MeshStart:
|
case MeshStart:
|
||||||
mbl.reset();
|
mbl.reset();
|
||||||
mbl_probe_index = 0;
|
mbl_probe_index = 0;
|
||||||
enqueue_and_echo_commands_P(PSTR("G28\nG29 S2"));
|
enqueue_and_echo_commands_P(lcd_wait_for_move ? PSTR("G29 S2") : PSTR("G28\nG29 S2"));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MeshNext:
|
case MeshNext:
|
||||||
@ -148,7 +136,15 @@ void GcodeSuite::G29() {
|
|||||||
SERIAL_PROTOCOLLNPGM("Mesh probing done.");
|
SERIAL_PROTOCOLLNPGM("Mesh probing done.");
|
||||||
BUZZ(100, 659);
|
BUZZ(100, 659);
|
||||||
BUZZ(100, 698);
|
BUZZ(100, 698);
|
||||||
mesh_probing_done();
|
mbl.has_mesh = true;
|
||||||
|
gcode.home_all_axes();
|
||||||
|
set_bed_leveling_enabled(true);
|
||||||
|
#if ENABLED(MESH_G28_REST_ORIGIN)
|
||||||
|
current_position[Z_AXIS] = Z_MIN_POS;
|
||||||
|
set_destination_from_current();
|
||||||
|
buffer_line_to_destination(homing_feedrate(Z_AXIS));
|
||||||
|
stepper.synchronize();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -177,9 +173,8 @@ void GcodeSuite::G29() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (parser.seenval('Z')) {
|
if (parser.seenval('Z'))
|
||||||
mbl.z_values[px][py] = parser.value_linear_units();
|
mbl.z_values[px][py] = parser.value_linear_units();
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
SERIAL_CHAR('Z'); echo_not_entered();
|
SERIAL_CHAR('Z'); echo_not_entered();
|
||||||
return;
|
return;
|
||||||
@ -187,9 +182,8 @@ void GcodeSuite::G29() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case MeshSetZOffset:
|
case MeshSetZOffset:
|
||||||
if (parser.seenval('Z')) {
|
if (parser.seenval('Z'))
|
||||||
mbl.z_offset = parser.value_linear_units();
|
mbl.z_offset = parser.value_linear_units();
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
SERIAL_CHAR('Z'); echo_not_entered();
|
SERIAL_CHAR('Z'); echo_not_entered();
|
||||||
return;
|
return;
|
||||||
@ -202,6 +196,11 @@ void GcodeSuite::G29() {
|
|||||||
|
|
||||||
} // switch(state)
|
} // switch(state)
|
||||||
|
|
||||||
|
if (state == MeshStart || state == MeshNext) {
|
||||||
|
SERIAL_PROTOCOLPAIR("MBL G29 point ", min(mbl_probe_index, GRID_MAX_POINTS));
|
||||||
|
SERIAL_PROTOCOLLNPAIR(" of ", int(GRID_MAX_POINTS));
|
||||||
|
}
|
||||||
|
|
||||||
report_current_position();
|
report_current_position();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -215,7 +215,6 @@ uint16_t max_display_update_time = 0;
|
|||||||
|
|
||||||
#if ENABLED(MESH_BED_LEVELING) && ENABLED(LCD_BED_LEVELING)
|
#if ENABLED(MESH_BED_LEVELING) && ENABLED(LCD_BED_LEVELING)
|
||||||
#include "../feature/bedlevel/mbl/mesh_bed_leveling.h"
|
#include "../feature/bedlevel/mbl/mesh_bed_leveling.h"
|
||||||
extern void mesh_probing_done();
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
////////////////////////////////////////////
|
////////////////////////////////////////////
|
||||||
@ -1742,58 +1741,33 @@ void kill_screen(const char* lcd_msg) {
|
|||||||
#endif
|
#endif
|
||||||
);
|
);
|
||||||
|
|
||||||
|
bool lcd_wait_for_move;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Bed leveling is done. Wait for G29 to complete.
|
||||||
|
// A flag is used so that this can release control
|
||||||
|
// and allow the command queue to be processed.
|
||||||
|
//
|
||||||
|
// When G29 finishes the last move:
|
||||||
|
// - Raise Z to the "manual probe height"
|
||||||
|
// - Don't return until done.
|
||||||
//
|
//
|
||||||
// Raise Z to the "manual probe height"
|
|
||||||
// Don't return until done.
|
|
||||||
// ** This blocks the command queue! **
|
// ** This blocks the command queue! **
|
||||||
//
|
//
|
||||||
void _lcd_after_probing() {
|
void _lcd_level_bed_done() {
|
||||||
#if MANUAL_PROBE_HEIGHT > 0
|
if (!lcd_wait_for_move) {
|
||||||
line_to_z(Z_MIN_POS + MANUAL_PROBE_HEIGHT);
|
#if MANUAL_PROBE_HEIGHT > 0 && DISABLED(MESH_BED_LEVELING)
|
||||||
#endif
|
// Display "Done" screen and wait for moves to complete
|
||||||
// Display "Done" screen and wait for moves to complete
|
|
||||||
#if MANUAL_PROBE_HEIGHT > 0 || ENABLED(MESH_BED_LEVELING)
|
|
||||||
lcd_synchronize(PSTR(MSG_LEVEL_BED_DONE));
|
|
||||||
#endif
|
|
||||||
lcd_goto_previous_menu();
|
|
||||||
lcd_completion_feedback();
|
|
||||||
defer_return_to_status = false;
|
|
||||||
//LCD_MESSAGEPGM(MSG_LEVEL_BED_DONE);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if ENABLED(MESH_BED_LEVELING)
|
|
||||||
|
|
||||||
// Utility to go to the next mesh point
|
|
||||||
inline void _manual_probe_goto_xy(const float &rx, const float &ry) {
|
|
||||||
#if MANUAL_PROBE_HEIGHT > 0
|
|
||||||
const float prev_z = current_position[Z_AXIS];
|
|
||||||
line_to_z(Z_MIN_POS + MANUAL_PROBE_HEIGHT);
|
line_to_z(Z_MIN_POS + MANUAL_PROBE_HEIGHT);
|
||||||
|
lcd_synchronize(PSTR(MSG_LEVEL_BED_DONE));
|
||||||
#endif
|
#endif
|
||||||
current_position[X_AXIS] = rx;
|
lcd_goto_previous_menu();
|
||||||
current_position[Y_AXIS] = ry;
|
lcd_completion_feedback();
|
||||||
planner.buffer_line_kinematic(current_position, MMM_TO_MMS(XY_PROBE_SPEED), active_extruder);
|
defer_return_to_status = false;
|
||||||
#if MANUAL_PROBE_HEIGHT > 0
|
|
||||||
line_to_z(prev_z);
|
|
||||||
#endif
|
|
||||||
lcd_synchronize();
|
|
||||||
}
|
}
|
||||||
|
if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, PSTR(MSG_LEVEL_BED_DONE));
|
||||||
#elif ENABLED(PROBE_MANUALLY)
|
lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
|
||||||
|
}
|
||||||
bool lcd_wait_for_move;
|
|
||||||
|
|
||||||
//
|
|
||||||
// Bed leveling is done. Wait for G29 to complete.
|
|
||||||
// A flag is used so that this can release control
|
|
||||||
// and allow the command queue to be processed.
|
|
||||||
//
|
|
||||||
void _lcd_level_bed_done() {
|
|
||||||
if (!lcd_wait_for_move) _lcd_after_probing();
|
|
||||||
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_DONE));
|
|
||||||
lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void _lcd_level_goto_next_point();
|
void _lcd_level_goto_next_point();
|
||||||
|
|
||||||
@ -1806,46 +1780,24 @@ void kill_screen(const char* lcd_msg) {
|
|||||||
if (lcd_clicked) {
|
if (lcd_clicked) {
|
||||||
|
|
||||||
//
|
//
|
||||||
// Save the current Z position
|
// Save the current Z position and move
|
||||||
//
|
//
|
||||||
|
|
||||||
#if ENABLED(MESH_BED_LEVELING)
|
|
||||||
|
|
||||||
//
|
|
||||||
// MBL records the position but doesn't move to the next one
|
|
||||||
//
|
|
||||||
|
|
||||||
mbl.set_zigzag_z(manual_probe_index, current_position[Z_AXIS]);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// If done...
|
// If done...
|
||||||
if (++manual_probe_index >= total_probe_points) {
|
if (++manual_probe_index >= total_probe_points) {
|
||||||
|
//
|
||||||
|
// The last G29 records the point and enables bed leveling
|
||||||
|
//
|
||||||
|
lcd_wait_for_move = true;
|
||||||
|
lcd_goto_screen(_lcd_level_bed_done);
|
||||||
#if ENABLED(PROBE_MANUALLY)
|
#if ENABLED(PROBE_MANUALLY)
|
||||||
|
|
||||||
//
|
|
||||||
// The last G29 will record and enable but not move.
|
|
||||||
//
|
|
||||||
lcd_wait_for_move = true;
|
|
||||||
enqueue_and_echo_commands_P(PSTR("G29 V1"));
|
enqueue_and_echo_commands_P(PSTR("G29 V1"));
|
||||||
lcd_goto_screen(_lcd_level_bed_done);
|
|
||||||
|
|
||||||
#elif ENABLED(MESH_BED_LEVELING)
|
#elif ENABLED(MESH_BED_LEVELING)
|
||||||
|
enqueue_and_echo_commands_P(PSTR("G29 S2"));
|
||||||
_lcd_after_probing();
|
|
||||||
|
|
||||||
mbl.has_mesh = true;
|
|
||||||
mesh_probing_done();
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
// MESH_BED_LEVELING: Z already stored, just move
|
|
||||||
// PROBE_MANUALLY: Send G29 to record Z, then move
|
|
||||||
_lcd_level_goto_next_point();
|
_lcd_level_goto_next_point();
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1873,7 +1825,6 @@ void kill_screen(const char* lcd_msg) {
|
|||||||
/**
|
/**
|
||||||
* Step 6: Display "Next point: 1 / 9" while waiting for move to finish
|
* Step 6: Display "Next point: 1 / 9" while waiting for move to finish
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void _lcd_level_bed_moving() {
|
void _lcd_level_bed_moving() {
|
||||||
if (lcdDrawUpdate) {
|
if (lcdDrawUpdate) {
|
||||||
char msg[10];
|
char msg[10];
|
||||||
@ -1881,36 +1832,22 @@ void kill_screen(const char* lcd_msg) {
|
|||||||
lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_NEXT_POINT), msg);
|
lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_NEXT_POINT), msg);
|
||||||
}
|
}
|
||||||
lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
|
lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
|
||||||
#if ENABLED(PROBE_MANUALLY)
|
if (!lcd_wait_for_move) lcd_goto_screen(_lcd_level_bed_get_z);
|
||||||
if (!lcd_wait_for_move) lcd_goto_screen(_lcd_level_bed_get_z);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Step 5: Initiate a move to the next point
|
* Step 5: Initiate a move to the next point
|
||||||
*/
|
*/
|
||||||
void _lcd_level_goto_next_point() {
|
void _lcd_level_goto_next_point() {
|
||||||
|
|
||||||
// Set the menu to display ahead of blocking call
|
// Set the menu to display ahead of blocking call
|
||||||
lcd_goto_screen(_lcd_level_bed_moving);
|
lcd_goto_screen(_lcd_level_bed_moving);
|
||||||
|
|
||||||
#if ENABLED(MESH_BED_LEVELING)
|
// G29 Records Z, moves, and signals when it pauses
|
||||||
|
lcd_wait_for_move = true;
|
||||||
int8_t px, py;
|
#if ENABLED(PROBE_MANUALLY)
|
||||||
mbl.zigzag(manual_probe_index, px, py);
|
|
||||||
|
|
||||||
// Controls the loop until the move is done
|
|
||||||
_manual_probe_goto_xy(mbl.index_to_xpos[px], mbl.index_to_ypos[py]);
|
|
||||||
|
|
||||||
// After the blocking function returns, change menus
|
|
||||||
lcd_goto_screen(_lcd_level_bed_get_z);
|
|
||||||
|
|
||||||
#elif ENABLED(PROBE_MANUALLY)
|
|
||||||
|
|
||||||
// G29 Records Z, moves, and signals when it pauses
|
|
||||||
lcd_wait_for_move = true;
|
|
||||||
enqueue_and_echo_commands_P(PSTR("G29 V1"));
|
enqueue_and_echo_commands_P(PSTR("G29 V1"));
|
||||||
|
#elif ENABLED(MESH_BED_LEVELING)
|
||||||
|
enqueue_and_echo_commands_P(manual_probe_index ? PSTR("G29 S2") : PSTR("G29 S1"));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1976,11 +1913,15 @@ void kill_screen(const char* lcd_msg) {
|
|||||||
START_MENU();
|
START_MENU();
|
||||||
MENU_BACK(MSG_PREPARE);
|
MENU_BACK(MSG_PREPARE);
|
||||||
|
|
||||||
if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]))
|
#if DISABLED(MESH_BED_LEVELING)
|
||||||
MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
|
if (!(axis_known_position[X_AXIS] && axis_known_position[Y_AXIS] && axis_known_position[Z_AXIS]))
|
||||||
else if (leveling_is_valid()) {
|
MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
|
||||||
MENU_ITEM_EDIT_CALLBACK(bool, MSG_BED_LEVELING, &new_level_state, _lcd_toggle_bed_leveling);
|
else
|
||||||
}
|
#endif
|
||||||
|
if (leveling_is_valid()) {
|
||||||
|
new_level_state = planner.leveling_active;
|
||||||
|
MENU_ITEM_EDIT_CALLBACK(bool, MSG_BED_LEVELING, &new_level_state, _lcd_toggle_bed_leveling);
|
||||||
|
}
|
||||||
|
|
||||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||||
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height);
|
MENU_MULTIPLIER_ITEM_EDIT_CALLBACK(float62, MSG_Z_FADE_HEIGHT, &new_z_fade_height, 0.0, 100.0, _lcd_set_z_fade_height);
|
||||||
@ -2016,9 +1957,6 @@ void kill_screen(const char* lcd_msg) {
|
|||||||
|
|
||||||
void _lcd_goto_bed_leveling() {
|
void _lcd_goto_bed_leveling() {
|
||||||
lcd_goto_screen(lcd_bed_leveling);
|
lcd_goto_screen(lcd_bed_leveling);
|
||||||
#if ENABLED(LCD_BED_LEVELING)
|
|
||||||
new_level_state = planner.leveling_active;
|
|
||||||
#endif
|
|
||||||
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
||||||
new_z_fade_height = planner.z_fade_height;
|
new_z_fade_height = planner.z_fade_height;
|
||||||
#endif
|
#endif
|
||||||
|
@ -40,8 +40,10 @@
|
|||||||
|
|
||||||
extern int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
|
extern int16_t lcd_preheat_hotend_temp[2], lcd_preheat_bed_temp[2], lcd_preheat_fan_speed[2];
|
||||||
|
|
||||||
#if ENABLED(LCD_BED_LEVELING) && ENABLED(PROBE_MANUALLY)
|
#if ENABLED(LCD_BED_LEVELING)
|
||||||
extern bool lcd_wait_for_move;
|
extern bool lcd_wait_for_move;
|
||||||
|
#else
|
||||||
|
constexpr bool lcd_wait_for_move = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int16_t lcd_strlen(const char* s);
|
int16_t lcd_strlen(const char* s);
|
||||||
|
Loading…
Reference in New Issue
Block a user