Patch up LCD level bed menus

master
Scott Lahteine 8 years ago
parent 78af2b1444
commit b3a97b5013

@ -3800,6 +3800,10 @@ void home_all_axes() { gcode_G28(true); }
#if ENABLED(MESH_BED_LEVELING) || ENABLED(PROBE_MANUALLY) #if ENABLED(MESH_BED_LEVELING) || ENABLED(PROBE_MANUALLY)
#if ENABLED(PROBE_MANUALLY) && ENABLED(LCD_BED_LEVELING)
extern bool lcd_wait_for_move;
#endif
inline void _manual_goto_xy(const float &x, const float &y) { inline void _manual_goto_xy(const float &x, const float &y) {
const float old_feedrate_mm_s = feedrate_mm_s; const float old_feedrate_mm_s = feedrate_mm_s;
@ -3822,6 +3826,10 @@ void home_all_axes() { gcode_G28(true); }
feedrate_mm_s = old_feedrate_mm_s; feedrate_mm_s = old_feedrate_mm_s;
stepper.synchronize(); stepper.synchronize();
#if ENABLED(PROBE_MANUALLY) && ENABLED(LCD_BED_LEVELING)
lcd_wait_for_move = false;
#endif
} }
#endif #endif
@ -4414,16 +4422,20 @@ void home_all_axes() { gcode_G28(true); }
#endif #endif
planner.abl_enabled = abl_should_enable; planner.abl_enabled = abl_should_enable;
g29_in_progress = false; g29_in_progress = false;
#if ENABLED(LCD_BED_LEVELING)
lcd_wait_for_move = false;
#endif
} }
// Query G29 status // Query G29 status
if (verbose_level || seenQ) { if (verbose_level || seenQ) {
if (!g29_in_progress) SERIAL_PROTOCOLPGM("Manual G29 ");
SERIAL_PROTOCOLLNPGM("Manual G29 idle"); if (g29_in_progress) {
else { SERIAL_PROTOCOLPAIR("point ", abl_probe_index + 1);
SERIAL_PROTOCOLPAIR("Manual G29 point ", abl_probe_index + 1);
SERIAL_PROTOCOLLNPAIR(" of ", abl2); SERIAL_PROTOCOLLNPAIR(" of ", abl2);
} }
else
SERIAL_PROTOCOLLNPGM("idle");
} }
if (seenA || seenQ) return; if (seenA || seenQ) return;
@ -4681,6 +4693,10 @@ void home_all_axes() { gcode_G28(true); }
if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position); if (DEBUGGING(LEVELING)) DEBUG_POS("> probing complete", current_position);
#endif #endif
#if ENABLED(PROBE_MANUALLY) && ENABLED(LCD_BED_LEVELING)
lcd_wait_for_move = false;
#endif
// Calculate leveling, print reports, correct the position // Calculate leveling, print reports, correct the position
#if ENABLED(AUTO_BED_LEVELING_BILINEAR) #if ENABLED(AUTO_BED_LEVELING_BILINEAR)

@ -78,9 +78,6 @@ uint16_t max_display_update_time = 0;
#if ENABLED(DOGLCD) #if ENABLED(DOGLCD)
bool drawing_screen = false; bool drawing_screen = false;
#define LCDVIEW_KEEP_REDRAWING LCDVIEW_CALL_REDRAW_NEXT
#else
#define LCDVIEW_KEEP_REDRAWING LCDVIEW_REDRAW_NOW
#endif #endif
#if ENABLED(DAC_STEPPER_CURRENT) #if ENABLED(DAC_STEPPER_CURRENT)
@ -479,22 +476,18 @@ uint16_t max_display_update_time = 0;
} }
/** /**
* Synchronize safely while holding the current screen * Show "Moving..." till moves are done, then revert to previous display.
* This blocks all further screen or stripe updates once called
*/ */
extern uint8_t commands_in_queue;
inline void lcd_synchronize() { inline void lcd_synchronize() {
static bool no_reentry = false; static bool no_reentry = false;
lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, PSTR(MSG_MOVING)); lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, PSTR(MSG_MOVING));
if (no_reentry) return; if (no_reentry) return;
// Make this the current handler till all moves are done
no_reentry = true; no_reentry = true;
screenFunc_t old_screen = currentScreen; screenFunc_t old_screen = currentScreen;
lcd_goto_screen(lcd_synchronize); lcd_goto_screen(lcd_synchronize);
while (commands_in_queue) {
idle();
stepper.synchronize(); stepper.synchronize();
}
no_reentry = false; no_reentry = false;
lcd_goto_screen(old_screen); lcd_goto_screen(old_screen);
} }
@ -879,7 +872,7 @@ void kill_screen(const char* lcd_msg) {
if (encoderPosition) { if (encoderPosition) {
const int babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR); const int babystep_increment = (int32_t)encoderPosition * (BABYSTEP_MULTIPLICATOR);
encoderPosition = 0; encoderPosition = 0;
lcdDrawUpdate = LCDVIEW_KEEP_REDRAWING; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
thermalManager.babystep_axis(axis, babystep_increment); thermalManager.babystep_axis(axis, babystep_increment);
babysteps_done += babystep_increment; babysteps_done += babystep_increment;
} }
@ -912,7 +905,7 @@ void kill_screen(const char* lcd_msg) {
zprobe_zoffset = new_zoffset; zprobe_zoffset = new_zoffset;
refresh_zprobe_zoffset(true); refresh_zprobe_zoffset(true);
lcdDrawUpdate = LCDVIEW_KEEP_REDRAWING; lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
} }
} }
if (lcdDrawUpdate) if (lcdDrawUpdate)
@ -943,7 +936,7 @@ void kill_screen(const char* lcd_msg) {
mesh_edit_accumulator += float(ubl_encoderPosition) * 0.005 / 2.0; mesh_edit_accumulator += float(ubl_encoderPosition) * 0.005 / 2.0;
mesh_edit_value = mesh_edit_accumulator; mesh_edit_value = mesh_edit_accumulator;
encoderPosition = 0; encoderPosition = 0;
lcdDrawUpdate = LCDVIEW_KEEP_REDRAWING; lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
const int32_t rounded = (int32_t)(mesh_edit_value * 1000.0); const int32_t rounded = (int32_t)(mesh_edit_value * 1000.0);
mesh_edit_value = float(rounded - (rounded % 5L)) / 1000.0; mesh_edit_value = float(rounded - (rounded % 5L)) / 1000.0;
@ -1422,7 +1415,7 @@ void kill_screen(const char* lcd_msg) {
constexpr uint8_t total_probe_points = ( constexpr uint8_t total_probe_points = (
#if ENABLED(AUTO_BED_LEVELING_3POINT) #if ENABLED(AUTO_BED_LEVELING_3POINT)
3 3
#elif ABL_GRID || ENABLED(AUTO_BED_LEVELING_UBL) || ENABLED(MESH_BED_LEVELING) #elif ABL_GRID || ENABLED(MESH_BED_LEVELING)
GRID_MAX_POINTS GRID_MAX_POINTS
#endif #endif
); );
@ -1447,26 +1440,12 @@ void kill_screen(const char* lcd_msg) {
#endif // MESH_BED_LEVELING #endif // MESH_BED_LEVELING
#if ENABLED(MESH_BED_LEVELING) || ENABLED(PROBE_MANUALLY)
void _lcd_level_goto_next_point();
#endif
void _lcd_level_bed_done() { void _lcd_level_bed_done() {
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_DONE)); if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_DONE));
lcdDrawUpdate = LCDVIEW_KEEP_REDRAWING; lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
} }
/** void _lcd_level_goto_next_point();
* Step 6: Display "Next point: 1 / 9" while waiting for move to finish
*/
void _lcd_level_bed_moving() {
if (lcdDrawUpdate) {
char msg[10];
sprintf_P(msg, PSTR("%i / %u"), (int)(manual_probe_index + 1), total_probe_points);
lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_NEXT_POINT), msg);
}
lcdDrawUpdate = LCDVIEW_KEEP_REDRAWING;
}
/** /**
* Step 7: Get the Z coordinate, click goes to the next point or exits * Step 7: Get the Z coordinate, click goes to the next point or exits
@ -1474,40 +1453,24 @@ void kill_screen(const char* lcd_msg) {
void _lcd_level_bed_get_z() { void _lcd_level_bed_get_z() {
ENCODER_DIRECTION_NORMAL(); ENCODER_DIRECTION_NORMAL();
// Encoder knob or keypad buttons adjust the Z position
if (encoderPosition) {
refresh_cmd_timeout();
current_position[Z_AXIS] += float((int32_t)encoderPosition) * (MBL_Z_STEP);
NOLESS(current_position[Z_AXIS], -(LCD_PROBE_Z_RANGE) * 0.5);
NOMORE(current_position[Z_AXIS], (LCD_PROBE_Z_RANGE) * 0.5);
line_to_current(Z_AXIS);
lcdDrawUpdate = LCDVIEW_KEEP_REDRAWING;
encoderPosition = 0;
}
if (lcd_clicked) { if (lcd_clicked) {
// Use a hook to set the probe point z // Use a hook to set the probe point z
// (zigzag arranges in XY order) #if ENABLED(MESH_BED_LEVELING)
#if ENABLED(AUTO_BED_LEVELING_UBL)
// UBL set-z handling goes here // MBL records the position but doesn't move to the next one
mbl.set_zigzag_z(manual_probe_index, current_position[Z_AXIS]);
#elif ENABLED(PROBE_MANUALLY) #elif ENABLED(PROBE_MANUALLY)
// G29 helpfully records Z and goes to the next // The last G29 will record but not move
// point (or beeps if done) if (manual_probe_index == total_probe_points - 1)
enqueue_and_echo_commands_P(PSTR("G29")); enqueue_and_echo_commands_P("G29 V1");
manual_probe_index++;
#elif ENABLED(MESH_BED_LEVELING)
mbl.set_zigzag_z(manual_probe_index++, current_position[Z_AXIS]);
#endif #endif
// If done... // If done...
if (manual_probe_index == total_probe_points) { if (++manual_probe_index >= total_probe_points) {
// Say "Done!" // Say "Done!"
lcd_goto_screen(_lcd_level_bed_done); lcd_goto_screen(_lcd_level_bed_done);
@ -1526,10 +1489,6 @@ void kill_screen(const char* lcd_msg) {
mbl.set_has_mesh(true); mbl.set_has_mesh(true);
mesh_probing_done(); mesh_probing_done();
#elif ENABLED(AUTO_BED_LEVELING_UBL)
// UBL enable goes here
#elif ENABLED(PROBE_MANUALLY) #elif ENABLED(PROBE_MANUALLY)
// ABL will be enabled due to "G29". // ABL will be enabled due to "G29".
@ -1540,19 +1499,21 @@ void kill_screen(const char* lcd_msg) {
//LCD_MESSAGEPGM(MSG_LEVEL_BED_DONE); //LCD_MESSAGEPGM(MSG_LEVEL_BED_DONE);
lcd_completion_feedback(); lcd_completion_feedback();
} }
else { else
// Move to the next probe point, if needed
#if ENABLED(MESH_BED_LEVELING) || ENABLED(PROBE_MANUALLY)
_lcd_level_goto_next_point(); _lcd_level_goto_next_point();
#elif ENABLED(AUTO_BED_LEVELING_UBL) return;
// UBL goto-next-point goes here
#endif
} }
// Encoder knob or keypad buttons adjust the Z position
if (encoderPosition) {
refresh_cmd_timeout();
current_position[Z_AXIS] += float((int32_t)encoderPosition) * (MBL_Z_STEP);
NOLESS(current_position[Z_AXIS], -(LCD_PROBE_Z_RANGE) * 0.5);
NOMORE(current_position[Z_AXIS], (LCD_PROBE_Z_RANGE) * 0.5);
line_to_current(Z_AXIS);
lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
encoderPosition = 0;
} }
// Update on first display, then only on updates to Z position // Update on first display, then only on updates to Z position
@ -1563,7 +1524,25 @@ void kill_screen(const char* lcd_msg) {
} }
} }
#if ENABLED(MESH_BED_LEVELING) || ENABLED(PROBE_MANUALLY) /**
* Step 6: Display "Next point: 1 / 9" while waiting for move to finish
*/
#if ENABLED(PROBE_MANUALLY)
bool lcd_wait_for_move;
#endif
void _lcd_level_bed_moving() {
if (lcdDrawUpdate) {
char msg[10];
sprintf_P(msg, PSTR("%i / %u"), (int)(manual_probe_index + 1), total_probe_points);
lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_NEXT_POINT), msg);
}
lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
#if ENABLED(PROBE_MANUALLY)
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
@ -1584,23 +1563,18 @@ void kill_screen(const char* lcd_msg) {
LOGICAL_Y_POSITION(mbl.index_to_ypos[py]) LOGICAL_Y_POSITION(mbl.index_to_ypos[py])
); );
#elif ENABLED(AUTO_BED_LEVELING_UBL) // After the blocking function returns, change menus
lcd_goto_screen(_lcd_level_bed_get_z);
// UBL may have its own methodology
#elif ENABLED(PROBE_MANUALLY) #elif ENABLED(PROBE_MANUALLY)
// Just wait for the G29 move to complete // G29 will signal when it's done
lcd_synchronize(); lcd_wait_for_move = true;
enqueue_and_echo_commands_P(PSTR("G29 V1"));
#endif #endif
// After the blocking function returns, change menus
lcd_goto_screen(_lcd_level_bed_get_z);
} }
#endif // MESH_BED_LEVELING
/** /**
* Step 4: Display "Click to Begin", wait for click * Step 4: Display "Click to Begin", wait for click
* Move to the first probe position * Move to the first probe position
@ -1609,14 +1583,7 @@ void kill_screen(const char* lcd_msg) {
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING)); if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_WAITING));
if (lcd_clicked) { if (lcd_clicked) {
manual_probe_index = 0; manual_probe_index = 0;
#if ENABLED(MESH_BED_LEVELING)
_lcd_level_goto_next_point(); _lcd_level_goto_next_point();
#elif ENABLED(AUTO_BED_LEVELING_UBL)
// UBL click handling should go here
#elif ENABLED(PROBE_MANUALLY)
enqueue_and_echo_commands_P(PSTR("G29"));
_lcd_level_goto_next_point();
#endif
} }
} }
@ -1625,15 +1592,11 @@ void kill_screen(const char* lcd_msg) {
*/ */
void _lcd_level_bed_homing() { void _lcd_level_bed_homing() {
if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_HOMING), NULL); if (lcdDrawUpdate) lcd_implementation_drawedit(PSTR(MSG_LEVEL_BED_HOMING), NULL);
lcdDrawUpdate = LCDVIEW_CALL_NO_REDRAW;
if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS])
lcd_goto_screen(_lcd_level_bed_homing_done); lcd_goto_screen(_lcd_level_bed_homing_done);
lcdDrawUpdate = LCDVIEW_KEEP_REDRAWING;
} }
#endif // LCD_BED_LEVELING
#if ENABLED(LCD_BED_LEVELING) || HAS_ABL
#if ENABLED(PROBE_MANUALLY) #if ENABLED(PROBE_MANUALLY)
extern bool g29_in_progress; extern bool g29_in_progress;
#endif #endif
@ -1642,15 +1605,10 @@ void kill_screen(const char* lcd_msg) {
* Step 2: Continue Bed Leveling... * Step 2: Continue Bed Leveling...
*/ */
void _lcd_level_bed_continue() { void _lcd_level_bed_continue() {
#if ENABLED(LCD_BED_LEVELING)
defer_return_to_status = true; defer_return_to_status = true;
axis_homed[X_AXIS] = axis_homed[Y_AXIS] = axis_homed[Z_AXIS] = false; axis_homed[X_AXIS] = axis_homed[Y_AXIS] = axis_homed[Z_AXIS] = false;
lcd_goto_screen(_lcd_level_bed_homing); lcd_goto_screen(_lcd_level_bed_homing);
enqueue_and_echo_commands_P(PSTR("G28")); enqueue_and_echo_commands_P(PSTR("G28"));
#else
lcd_return_to_status();
enqueue_and_echo_commands_P(axis_homed[X_AXIS] && axis_homed[Y_AXIS] ? PSTR("G29") : PSTR("G28\nG29"));
#endif
} }
/** /**
@ -1663,7 +1621,7 @@ void kill_screen(const char* lcd_msg) {
END_MENU(); END_MENU();
} }
#if ENABLED(AUTO_BED_LEVELING_UBL) #elif ENABLED(AUTO_BED_LEVELING_UBL)
void _lcd_ubl_level_bed(); void _lcd_ubl_level_bed();
@ -2022,9 +1980,8 @@ void kill_screen(const char* lcd_msg) {
MENU_ITEM(gcode, MSG_UBL_INFO_UBL, PSTR("G29 W")); MENU_ITEM(gcode, MSG_UBL_INFO_UBL, PSTR("G29 W"));
END_MENU(); END_MENU();
} }
#endif
#endif // LCD_BED_LEVELING || HAS_ABL #endif // AUTO_BED_LEVELING_UBL
/** /**
* *
@ -2061,19 +2018,15 @@ void kill_screen(const char* lcd_msg) {
// //
// Level Bed // Level Bed
// //
#if ENABLED(LCD_BED_LEVELING) || HAS_ABL #if ENABLED(AUTO_BED_LEVELING_UBL)
MENU_ITEM(submenu, MSG_UBL_LEVEL_BED, _lcd_ubl_level_bed);
#elif ENABLED(LCD_BED_LEVELING)
#if ENABLED(PROBE_MANUALLY) #if ENABLED(PROBE_MANUALLY)
if (!g29_in_progress) if (!g29_in_progress)
#endif #endif
#if ENABLED(AUTO_BED_LEVELING_UBL)
MENU_ITEM(submenu, MSG_UBL_LEVEL_BED, _lcd_ubl_level_bed);
#else
MENU_ITEM(submenu, MSG_LEVEL_BED, lcd_level_bed); MENU_ITEM(submenu, MSG_LEVEL_BED, lcd_level_bed);
#endif #endif
#endif // LCD_BED_LEVELING || HAS_ABL
#if HAS_M206_COMMAND #if HAS_M206_COMMAND
// //
// Set Home Offsets // Set Home Offsets
@ -2158,7 +2111,7 @@ void kill_screen(const char* lcd_msg) {
void _lcd_calibrate_homing() { void _lcd_calibrate_homing() {
if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, PSTR(MSG_LEVEL_BED_HOMING)); if (lcdDrawUpdate) lcd_implementation_drawmenu_static(LCD_HEIGHT >= 4 ? 1 : 0, PSTR(MSG_LEVEL_BED_HOMING));
lcdDrawUpdate = LCDVIEW_KEEP_REDRAWING; lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT;
if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS]) if (axis_homed[X_AXIS] && axis_homed[Y_AXIS] && axis_homed[Z_AXIS])
lcd_goto_previous_menu(); lcd_goto_previous_menu();
} }
@ -2292,7 +2245,7 @@ void kill_screen(const char* lcd_msg) {
manual_move_to_current(axis); manual_move_to_current(axis);
encoderPosition = 0; encoderPosition = 0;
lcdDrawUpdate = LCDVIEW_KEEP_REDRAWING; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
} }
if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr41sign(current_position[axis])); if (lcdDrawUpdate) lcd_implementation_drawedit(name, ftostr41sign(current_position[axis]));
} }
@ -2314,7 +2267,7 @@ void kill_screen(const char* lcd_msg) {
, eindex , eindex
#endif #endif
); );
lcdDrawUpdate = LCDVIEW_KEEP_REDRAWING; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
} }
if (lcdDrawUpdate) { if (lcdDrawUpdate) {
PGM_P pos_label; PGM_P pos_label;
@ -3243,7 +3196,7 @@ void kill_screen(const char* lcd_msg) {
encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \ encoderPosition += ENCODER_STEPS_PER_MENU_ITEM; \
++encoderLine; \ ++encoderLine; \
} \ } \
lcdDrawUpdate = LCDVIEW_KEEP_REDRAWING; \ lcdDrawUpdate = LCDVIEW_CALL_REDRAW_NEXT; \
} \ } \
++_thisItemNr; \ ++_thisItemNr; \
} while(0) } while(0)
@ -3775,9 +3728,9 @@ bool lcd_blink() {
* - if (lcdDrawUpdate) { redraw } * - if (lcdDrawUpdate) { redraw }
* - Before exiting the handler set lcdDrawUpdate to: * - Before exiting the handler set lcdDrawUpdate to:
* - LCDVIEW_CLEAR_CALL_REDRAW to clear screen and set LCDVIEW_CALL_REDRAW_NEXT. * - LCDVIEW_CLEAR_CALL_REDRAW to clear screen and set LCDVIEW_CALL_REDRAW_NEXT.
* - LCDVIEW_REDRAW_NOW or LCDVIEW_NONE to keep drawing, but only in this loop. * - LCDVIEW_REDRAW_NOW to draw now (including remaining stripes).
* - LCDVIEW_CALL_REDRAW_NEXT to keep drawing and draw on the next loop also. * - LCDVIEW_CALL_REDRAW_NEXT to draw now and get LCDVIEW_REDRAW_NOW on the next loop.
* - LCDVIEW_CALL_NO_REDRAW to keep drawing (or start drawing) with no redraw on the next loop. * - LCDVIEW_CALL_NO_REDRAW to draw now and get LCDVIEW_NONE on the next loop.
* - NOTE: For graphical displays menu handlers may be called 2 or more times per loop, * - NOTE: For graphical displays menu handlers may be called 2 or more times per loop,
* so don't change lcdDrawUpdate without considering this. * so don't change lcdDrawUpdate without considering this.
* *
@ -3897,7 +3850,7 @@ void lcd_update() {
encoderDiff = 0; encoderDiff = 0;
} }
return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS; return_to_status_ms = ms + LCD_TIMEOUT_TO_STATUS;
lcdDrawUpdate = LCDVIEW_KEEP_REDRAWING; lcdDrawUpdate = LCDVIEW_REDRAW_NOW;
} }
#endif // ULTIPANEL #endif // ULTIPANEL

Loading…
Cancel
Save