Replace MBL Z hacking

This commit is contained in:
Scott Lahteine
2017-03-15 03:20:41 -05:00
parent 4e53124681
commit 3e927ff204
28 changed files with 148 additions and 195 deletions

View File

@ -1223,18 +1223,17 @@ void kill_screen(const char* lcd_msg) {
static uint8_t _lcd_level_bed_position;
// Utility to go to the next mesh point
// A raise is added between points if Z_HOMING_HEIGHT is in use
// Note: During Manual Bed Leveling the homed Z position is MESH_HOME_SEARCH_Z
// Z position will be restored with the final action, a G28
inline void _mbl_goto_xy(float x, float y) {
inline void _manual_probe_xy(float x, float y) {
if (no_reentrance) return;
current_position[Z_AXIS] = LOGICAL_Z_POSITION(MESH_HOME_SEARCH_Z + Z_HOMING_HEIGHT);
line_to_current(Z_AXIS);
#if MANUAL_PROBE_HEIGHT > 0
current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS) + MANUAL_PROBE_HEIGHT;
line_to_current(Z_AXIS);
#endif
current_position[X_AXIS] = LOGICAL_X_POSITION(x);
current_position[Y_AXIS] = LOGICAL_Y_POSITION(y);
planner.buffer_line_kinematic(current_position, MMM_TO_MMS(XY_PROBE_SPEED), active_extruder);
#if Z_HOMING_HEIGHT > 0
current_position[Z_AXIS] = LOGICAL_Z_POSITION(MESH_HOME_SEARCH_Z);
#if MANUAL_PROBE_HEIGHT > 0
current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS) + 0.2;
line_to_current(Z_AXIS);
#endif
lcd_synchronize();
@ -1259,48 +1258,44 @@ void kill_screen(const char* lcd_msg) {
if (encoderPosition) {
refresh_cmd_timeout();
current_position[Z_AXIS] += float((int32_t)encoderPosition) * (MBL_Z_STEP);
NOLESS(current_position[Z_AXIS], 0);
NOMORE(current_position[Z_AXIS], MESH_HOME_SEARCH_Z * 2);
NOLESS(current_position[Z_AXIS], -(MANUAL_PROBE_Z_RANGE) * 0.5);
NOMORE(current_position[Z_AXIS], (MANUAL_PROBE_Z_RANGE) * 0.5);
line_to_current(Z_AXIS);
lcdDrawUpdate = LCDVIEW_KEEP_REDRAWING;
encoderPosition = 0;
}
static bool debounce_click = false;
if (lcd_clicked) {
if (!debounce_click) {
debounce_click = true; // ignore multiple "clicks" in a row
mbl.set_zigzag_z(_lcd_level_bed_position++, current_position[Z_AXIS]);
if (_lcd_level_bed_position == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) {
lcd_goto_screen(_lcd_level_bed_done);
mbl.set_zigzag_z(_lcd_level_bed_position++, current_position[Z_AXIS]);
if (_lcd_level_bed_position == (MESH_NUM_X_POINTS) * (MESH_NUM_Y_POINTS)) {
lcd_goto_screen(_lcd_level_bed_done);
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z + Z_HOMING_HEIGHT;
#if MANUAL_PROBE_HEIGHT > 0
current_position[Z_AXIS] = LOGICAL_Z_POSITION(Z_MIN_POS) + MANUAL_PROBE_HEIGHT;
line_to_current(Z_AXIS);
lcd_synchronize();
#endif
mbl.set_has_mesh(true);
enqueue_and_echo_commands_P(PSTR("G28"));
lcd_return_to_status();
//LCD_MESSAGEPGM(MSG_LEVEL_BED_DONE);
#if HAS_BUZZER
lcd_buzz(200, 659);
lcd_buzz(200, 698);
#endif
}
else {
lcd_goto_screen(_lcd_level_goto_next_point);
}
mbl.set_has_mesh(true);
mbl.set_reactivate(true);
enqueue_and_echo_commands_P(PSTR("G28"));
lcd_return_to_status();
//LCD_MESSAGEPGM(MSG_LEVEL_BED_DONE);
#if HAS_BUZZER
lcd_buzz(200, 659);
lcd_buzz(200, 698);
#endif
}
else {
lcd_goto_screen(_lcd_level_goto_next_point);
}
}
else {
debounce_click = false;
}
KeepDrawing:
// Update on first display, then only on updates to Z position
// Show message above on clicks instead
if (lcdDrawUpdate) {
float v = current_position[Z_AXIS] - MESH_HOME_SEARCH_Z;
const float v = current_position[Z_AXIS];
lcd_implementation_drawedit(PSTR(MSG_MOVE_Z), ftostr43sign(v + (v < 0 ? -0.0001 : 0.0001), '+'));
}
@ -1326,10 +1321,10 @@ KeepDrawing:
// Set the menu to display ahead of blocking call
lcd_goto_screen(_lcd_level_bed_moving);
// _mbl_goto_xy runs the menu loop until the move is done
// _manual_probe_xy runs the menu loop until the move is done
int8_t px, py;
mbl.zigzag(_lcd_level_bed_position, px, py);
_mbl_goto_xy(mbl.get_probe_x(px), mbl.get_probe_y(py));
_manual_probe_xy(mbl.get_probe_x(px), mbl.get_probe_y(py));
// After the blocking function returns, change menus
lcd_goto_screen(_lcd_level_bed_get_z);
@ -1343,12 +1338,6 @@ KeepDrawing:
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING));
if (lcd_clicked) {
_lcd_level_bed_position = 0;
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z
#if Z_HOME_DIR > 0
+ Z_MAX_POS
#endif
;
planner.set_position_mm(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]);
lcd_goto_screen(_lcd_level_goto_next_point);
}
}