2018-10-28 02:48:37 +02:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2018-10-28 02:48:37 +02:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2018-10-28 02:48:37 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
//
|
|
|
|
// Bed Leveling Menus
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "../../inc/MarlinConfigPre.h"
|
|
|
|
|
2018-11-11 19:16:24 +01:00
|
|
|
#if ENABLED(LCD_BED_LEVELING)
|
2018-10-28 02:48:37 +02:00
|
|
|
|
|
|
|
#include "menu.h"
|
|
|
|
#include "../../module/planner.h"
|
|
|
|
#include "../../feature/bedlevel/bedlevel.h"
|
|
|
|
|
2018-11-01 22:13:33 +01:00
|
|
|
#if HAS_BED_PROBE && DISABLED(BABYSTEP_ZPROBE_OFFSET)
|
|
|
|
#include "../../module/probe.h"
|
|
|
|
#endif
|
|
|
|
|
2019-03-17 05:43:06 +01:00
|
|
|
#if EITHER(PROBE_MANUALLY, MESH_BED_LEVELING)
|
2018-10-28 02:48:37 +02:00
|
|
|
|
|
|
|
#include "../../module/motion.h"
|
|
|
|
#include "../../gcode/queue.h"
|
|
|
|
|
|
|
|
//
|
|
|
|
// Motion > Level Bed handlers
|
|
|
|
//
|
|
|
|
|
|
|
|
static uint8_t manual_probe_index;
|
|
|
|
|
|
|
|
// LCD probed points are from defaults
|
|
|
|
constexpr uint8_t total_probe_points = (
|
|
|
|
#if ENABLED(AUTO_BED_LEVELING_3POINT)
|
|
|
|
3
|
|
|
|
#elif ABL_GRID || ENABLED(MESH_BED_LEVELING)
|
|
|
|
GRID_MAX_POINTS
|
|
|
|
#endif
|
|
|
|
);
|
|
|
|
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// ** This blocks the command queue! **
|
|
|
|
//
|
|
|
|
void _lcd_level_bed_done() {
|
2020-01-26 07:02:06 +01:00
|
|
|
if (!ui.wait_for_move) {
|
2018-10-28 02:48:37 +02:00
|
|
|
#if MANUAL_PROBE_HEIGHT > 0 && DISABLED(MESH_BED_LEVELING)
|
|
|
|
// Display "Done" screen and wait for moves to complete
|
|
|
|
line_to_z(MANUAL_PROBE_HEIGHT);
|
2019-10-10 02:46:10 +02:00
|
|
|
ui.synchronize(GET_TEXT(MSG_LEVEL_BED_DONE));
|
2018-10-28 02:48:37 +02:00
|
|
|
#endif
|
2018-11-11 19:16:24 +01:00
|
|
|
ui.goto_previous_screen_no_defer();
|
2019-07-29 02:14:50 +02:00
|
|
|
#if HAS_BUZZER
|
|
|
|
ui.completion_feedback();
|
|
|
|
#endif
|
2018-10-28 02:48:37 +02:00
|
|
|
}
|
2019-11-02 13:28:20 +01:00
|
|
|
if (ui.should_draw()) MenuItem_static::draw(LCD_HEIGHT >= 4, GET_TEXT(MSG_LEVEL_BED_DONE));
|
2018-11-11 19:16:24 +01:00
|
|
|
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
|
2018-10-28 02:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void _lcd_level_goto_next_point();
|
|
|
|
|
|
|
|
//
|
|
|
|
// Step 7: Get the Z coordinate, click goes to the next point or exits
|
|
|
|
//
|
|
|
|
void _lcd_level_bed_get_z() {
|
|
|
|
|
2018-11-11 19:16:24 +01:00
|
|
|
if (ui.use_click()) {
|
2018-10-28 02:48:37 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// Save the current Z position and move
|
|
|
|
//
|
|
|
|
|
|
|
|
// If done...
|
|
|
|
if (++manual_probe_index >= total_probe_points) {
|
|
|
|
//
|
|
|
|
// The last G29 records the point and enables bed leveling
|
|
|
|
//
|
2020-01-26 07:02:06 +01:00
|
|
|
ui.wait_for_move = true;
|
2018-11-11 19:16:24 +01:00
|
|
|
ui.goto_screen(_lcd_level_bed_done);
|
2018-10-28 02:48:37 +02:00
|
|
|
#if ENABLED(MESH_BED_LEVELING)
|
2019-06-19 07:00:19 +02:00
|
|
|
queue.inject_P(PSTR("G29 S2"));
|
2018-10-28 02:48:37 +02:00
|
|
|
#elif ENABLED(PROBE_MANUALLY)
|
2019-06-19 07:00:19 +02:00
|
|
|
queue.inject_P(PSTR("G29 V1"));
|
2018-10-28 02:48:37 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
else
|
|
|
|
_lcd_level_goto_next_point();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Encoder knob or keypad buttons adjust the Z position
|
|
|
|
//
|
2018-11-11 19:16:24 +01:00
|
|
|
if (ui.encoderPosition) {
|
2019-10-22 01:34:29 +02:00
|
|
|
const float z = current_position.z + float(int32_t(ui.encoderPosition)) * (MESH_EDIT_Z_STEP);
|
2018-10-28 02:48:37 +02:00
|
|
|
line_to_z(constrain(z, -(LCD_PROBE_Z_RANGE) * 0.5f, (LCD_PROBE_Z_RANGE) * 0.5f));
|
2018-11-11 19:16:24 +01:00
|
|
|
ui.refresh(LCDVIEW_CALL_REDRAW_NEXT);
|
|
|
|
ui.encoderPosition = 0;
|
2018-10-28 02:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Draw on first display, then only on Z change
|
|
|
|
//
|
2018-11-11 19:16:24 +01:00
|
|
|
if (ui.should_draw()) {
|
2019-09-29 11:25:39 +02:00
|
|
|
const float v = current_position.z;
|
2019-11-15 03:30:30 +01:00
|
|
|
MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_MOVE_Z), ftostr43sign(v + (v < 0 ? -0.0001f : 0.0001f), '+'));
|
2018-10-28 02:48:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Step 6: Display "Next point: 1 / 9" while waiting for move to finish
|
|
|
|
//
|
|
|
|
void _lcd_level_bed_moving() {
|
2018-11-11 19:16:24 +01:00
|
|
|
if (ui.should_draw()) {
|
2018-10-28 02:48:37 +02:00
|
|
|
char msg[10];
|
2019-10-22 01:34:29 +02:00
|
|
|
sprintf_P(msg, PSTR("%i / %u"), int(manual_probe_index + 1), total_probe_points);
|
2019-11-15 03:30:30 +01:00
|
|
|
MenuEditItemBase::draw_edit_screen(GET_TEXT(MSG_LEVEL_BED_NEXT_POINT), msg);
|
2018-10-28 02:48:37 +02:00
|
|
|
}
|
2018-11-11 19:16:24 +01:00
|
|
|
ui.refresh(LCDVIEW_CALL_NO_REDRAW);
|
2020-01-26 07:02:06 +01:00
|
|
|
if (!ui.wait_for_move) ui.goto_screen(_lcd_level_bed_get_z);
|
2018-10-28 02:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Step 5: Initiate a move to the next point
|
|
|
|
//
|
|
|
|
void _lcd_level_goto_next_point() {
|
2018-11-11 19:16:24 +01:00
|
|
|
ui.goto_screen(_lcd_level_bed_moving);
|
2018-10-28 02:48:37 +02:00
|
|
|
|
|
|
|
// G29 Records Z, moves, and signals when it pauses
|
2020-01-26 07:02:06 +01:00
|
|
|
ui.wait_for_move = true;
|
2018-10-28 02:48:37 +02:00
|
|
|
#if ENABLED(MESH_BED_LEVELING)
|
2019-06-19 07:00:19 +02:00
|
|
|
queue.inject_P(manual_probe_index ? PSTR("G29 S2") : PSTR("G29 S1"));
|
2018-10-28 02:48:37 +02:00
|
|
|
#elif ENABLED(PROBE_MANUALLY)
|
2019-06-19 07:00:19 +02:00
|
|
|
queue.inject_P(PSTR("G29 V1"));
|
2018-10-28 02:48:37 +02:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Step 4: Display "Click to Begin", wait for click
|
|
|
|
// Move to the first probe position
|
|
|
|
//
|
|
|
|
void _lcd_level_bed_homing_done() {
|
2019-11-02 13:28:20 +01:00
|
|
|
if (ui.should_draw()) MenuItem_static::draw(1, GET_TEXT(MSG_LEVEL_BED_WAITING));
|
2018-11-11 19:16:24 +01:00
|
|
|
if (ui.use_click()) {
|
2018-10-28 02:48:37 +02:00
|
|
|
manual_probe_index = 0;
|
|
|
|
_lcd_level_goto_next_point();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Step 3: Display "Homing XYZ" - Wait for homing to finish
|
|
|
|
//
|
|
|
|
void _lcd_level_bed_homing() {
|
|
|
|
_lcd_draw_homing();
|
2018-11-11 19:16:24 +01:00
|
|
|
if (all_axes_homed()) ui.goto_screen(_lcd_level_bed_homing_done);
|
2018-10-28 02:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#if ENABLED(PROBE_MANUALLY)
|
|
|
|
extern bool g29_in_progress;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//
|
|
|
|
// Step 2: Continue Bed Leveling...
|
|
|
|
//
|
|
|
|
void _lcd_level_bed_continue() {
|
2019-03-23 22:30:43 +01:00
|
|
|
ui.defer_status_screen();
|
2018-10-31 23:07:52 +01:00
|
|
|
set_all_unhomed();
|
2018-11-11 19:16:24 +01:00
|
|
|
ui.goto_screen(_lcd_level_bed_homing);
|
2019-11-02 05:51:25 +01:00
|
|
|
queue.inject_P(G28_STR);
|
2018-10-28 02:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif // PROBE_MANUALLY || MESH_BED_LEVELING
|
|
|
|
|
2018-06-06 04:57:25 +02:00
|
|
|
#if ENABLED(MESH_EDIT_MENU)
|
|
|
|
|
|
|
|
inline void refresh_planner() {
|
|
|
|
set_current_from_steppers_for_axis(ALL_AXES);
|
|
|
|
sync_plan_position();
|
|
|
|
}
|
|
|
|
|
2018-11-05 12:12:56 +01:00
|
|
|
void menu_edit_mesh() {
|
2018-06-06 04:57:25 +02:00
|
|
|
static uint8_t xind, yind; // =0
|
|
|
|
START_MENU();
|
2019-10-03 12:38:30 +02:00
|
|
|
BACK_ITEM(MSG_BED_LEVELING);
|
|
|
|
EDIT_ITEM(uint8, MSG_MESH_X, &xind, 0, GRID_MAX_POINTS_X - 1);
|
|
|
|
EDIT_ITEM(uint8, MSG_MESH_Y, &yind, 0, GRID_MAX_POINTS_Y - 1);
|
|
|
|
EDIT_ITEM_FAST(float43, MSG_MESH_EDIT_Z, &Z_VALUES(xind, yind), -(LCD_PROBE_Z_RANGE) * 0.5, (LCD_PROBE_Z_RANGE) * 0.5, refresh_planner);
|
2018-06-06 04:57:25 +02:00
|
|
|
END_MENU();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // MESH_EDIT_MENU
|
|
|
|
|
2018-10-28 02:48:37 +02:00
|
|
|
/**
|
|
|
|
* Step 1: Bed Level entry-point
|
|
|
|
*
|
|
|
|
* << Motion
|
|
|
|
* Auto Home (if homing needed)
|
|
|
|
* Leveling On/Off (if data exists, and homed)
|
|
|
|
* Fade Height: --- (Req: ENABLE_LEVELING_FADE_HEIGHT)
|
|
|
|
* Mesh Z Offset: --- (Req: MESH_BED_LEVELING)
|
|
|
|
* Z Probe Offset: --- (Req: HAS_BED_PROBE, Opt: BABYSTEP_ZPROBE_OFFSET)
|
|
|
|
* Level Bed >
|
|
|
|
* Level Corners > (if homed)
|
|
|
|
* Load Settings (Req: EEPROM_SETTINGS)
|
|
|
|
* Save Settings (Req: EEPROM_SETTINGS)
|
|
|
|
*/
|
|
|
|
void menu_bed_leveling() {
|
|
|
|
START_MENU();
|
2019-10-03 12:38:30 +02:00
|
|
|
BACK_ITEM(MSG_MOTION);
|
2018-10-28 02:48:37 +02:00
|
|
|
|
|
|
|
const bool is_homed = all_axes_known();
|
|
|
|
|
|
|
|
// Auto Home if not using manual probing
|
2019-07-06 01:20:15 +02:00
|
|
|
#if NONE(PROBE_MANUALLY, MESH_BED_LEVELING)
|
2019-11-02 05:51:25 +01:00
|
|
|
if (!is_homed) GCODES_ITEM(MSG_AUTO_HOME, G28_STR);
|
2018-10-28 02:48:37 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Level Bed
|
2019-03-17 05:43:06 +01:00
|
|
|
#if EITHER(PROBE_MANUALLY, MESH_BED_LEVELING)
|
2018-10-28 02:48:37 +02:00
|
|
|
// Manual leveling uses a guided procedure
|
2019-10-03 12:38:30 +02:00
|
|
|
SUBMENU(MSG_LEVEL_BED, _lcd_level_bed_continue);
|
2018-10-28 02:48:37 +02:00
|
|
|
#else
|
|
|
|
// Automatic leveling can just run the G-code
|
2019-10-03 12:38:30 +02:00
|
|
|
GCODES_ITEM(MSG_LEVEL_BED, is_homed ? PSTR("G29") : PSTR("G28\nG29"));
|
2018-10-28 02:48:37 +02:00
|
|
|
#endif
|
|
|
|
|
2018-06-06 04:57:25 +02:00
|
|
|
#if ENABLED(MESH_EDIT_MENU)
|
2018-11-05 12:12:56 +01:00
|
|
|
if (leveling_is_valid())
|
2019-10-03 12:38:30 +02:00
|
|
|
SUBMENU(MSG_EDIT_MESH, menu_edit_mesh);
|
2018-06-06 04:57:25 +02:00
|
|
|
#endif
|
|
|
|
|
2018-10-28 02:48:37 +02:00
|
|
|
// Homed and leveling is valid? Then leveling can be toggled.
|
|
|
|
if (is_homed && leveling_is_valid()) {
|
2019-10-08 02:44:33 +02:00
|
|
|
bool show_state = planner.leveling_active;
|
|
|
|
EDIT_ITEM(bool, MSG_BED_LEVELING, &show_state, _lcd_toggle_bed_leveling);
|
2018-10-28 02:48:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Z Fade Height
|
|
|
|
#if ENABLED(ENABLE_LEVELING_FADE_HEIGHT)
|
2019-10-08 02:44:33 +02:00
|
|
|
// Shadow for editing the fade height
|
|
|
|
editable.decimal = planner.z_fade_height;
|
2019-11-02 06:05:05 +01:00
|
|
|
EDIT_ITEM_FAST(float3, MSG_Z_FADE_HEIGHT, &editable.decimal, 0, 100, []{ set_z_fade_height(editable.decimal); });
|
2018-10-28 02:48:37 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
//
|
2018-06-06 04:57:25 +02:00
|
|
|
// Mesh Bed Leveling Z-Offset
|
2018-10-28 02:48:37 +02:00
|
|
|
//
|
|
|
|
#if ENABLED(MESH_BED_LEVELING)
|
2019-10-03 12:38:30 +02:00
|
|
|
EDIT_ITEM(float43, MSG_BED_Z, &mbl.z_offset, -1, 1);
|
2018-10-28 02:48:37 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(BABYSTEP_ZPROBE_OFFSET)
|
2019-10-03 12:38:30 +02:00
|
|
|
SUBMENU(MSG_ZPROBE_ZOFFSET, lcd_babystep_zoffset);
|
2018-10-28 02:48:37 +02:00
|
|
|
#elif HAS_BED_PROBE
|
2020-01-03 03:40:40 +01:00
|
|
|
EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe_offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
|
2018-10-28 02:48:37 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(LEVEL_BED_CORNERS)
|
2019-10-03 12:38:30 +02:00
|
|
|
SUBMENU(MSG_LEVEL_CORNERS, _lcd_level_bed_corners);
|
2018-10-28 02:48:37 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if ENABLED(EEPROM_SETTINGS)
|
2019-10-03 12:38:30 +02:00
|
|
|
ACTION_ITEM(MSG_LOAD_EEPROM, lcd_load_settings);
|
|
|
|
ACTION_ITEM(MSG_STORE_EEPROM, lcd_store_settings);
|
2018-10-28 02:48:37 +02:00
|
|
|
#endif
|
|
|
|
END_MENU();
|
|
|
|
}
|
|
|
|
|
2018-11-11 19:16:24 +01:00
|
|
|
#endif // LCD_BED_LEVELING
|