Z Probe Offset Wizard (#18866)

This commit is contained in:
Mathew Winters 2020-10-05 18:31:20 +13:00 committed by Scott Lahteine
parent fb28e0cba9
commit cc863ba378
6 changed files with 162 additions and 1 deletions

View File

@ -1048,6 +1048,14 @@
#if HAS_LCD_MENU #if HAS_LCD_MENU
// Add Probe Z Offset calibration to the Bed Leveling menu
#if HAS_BED_PROBE
//#define PROBE_OFFSET_WIZARD
#if ENABLED(PROBE_OFFSET_WIZARD)
#define PROBE_OFFSET_START -4.0 // Estimated nozzle-to-probe Z offset, plus a little extra
#endif
#endif
// Include a page of printer information in the LCD Main Menu // Include a page of printer information in the LCD Main Menu
//#define LCD_INFO_MENU //#define LCD_INFO_MENU
#if ENABLED(LCD_INFO_MENU) #if ENABLED(LCD_INFO_MENU)

View File

@ -445,6 +445,7 @@ namespace Language_en {
PROGMEM Language_Str MSG_ZPROBE_XOFFSET = _UxGT("Probe X Offset"); PROGMEM Language_Str MSG_ZPROBE_XOFFSET = _UxGT("Probe X Offset");
PROGMEM Language_Str MSG_ZPROBE_YOFFSET = _UxGT("Probe Y Offset"); PROGMEM Language_Str MSG_ZPROBE_YOFFSET = _UxGT("Probe Y Offset");
PROGMEM Language_Str MSG_ZPROBE_ZOFFSET = _UxGT("Probe Z Offset"); PROGMEM Language_Str MSG_ZPROBE_ZOFFSET = _UxGT("Probe Z Offset");
PROGMEM Language_Str MSG_MOVE_NOZZLE_TO_BED = _UxGT("Move Nozzle to Bed");
PROGMEM Language_Str MSG_BABYSTEP_X = _UxGT("Babystep X"); PROGMEM Language_Str MSG_BABYSTEP_X = _UxGT("Babystep X");
PROGMEM Language_Str MSG_BABYSTEP_Y = _UxGT("Babystep Y"); PROGMEM Language_Str MSG_BABYSTEP_Y = _UxGT("Babystep Y");
PROGMEM Language_Str MSG_BABYSTEP_Z = _UxGT("Babystep Z"); PROGMEM Language_Str MSG_BABYSTEP_Z = _UxGT("Babystep Z");
@ -653,6 +654,8 @@ namespace Language_en {
#endif #endif
PROGMEM Language_Str MSG_REHEAT = _UxGT("Reheat"); PROGMEM Language_Str MSG_REHEAT = _UxGT("Reheat");
PROGMEM Language_Str MSG_REHEATING = _UxGT("Reheating..."); PROGMEM Language_Str MSG_REHEATING = _UxGT("Reheating...");
PROGMEM Language_Str MSG_PROBE_WIZARD = _UxGT("Z Probe Wizard");
} }
#if FAN_COUNT == 1 #if FAN_COUNT == 1

View File

@ -219,6 +219,10 @@ void _lcd_draw_homing();
void _lcd_zoffset_overlay_gfx(const float zvalue); void _lcd_zoffset_overlay_gfx(const float zvalue);
#endif #endif
#if ENABLED(PROBE_OFFSET_WIZARD)
void goto_probe_offset_wizard();
#endif
#if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS)) #if ENABLED(LCD_BED_LEVELING) || (HAS_LEVELING && DISABLED(SLIM_LCD_MENUS))
void _lcd_toggle_bed_leveling(); void _lcd_toggle_bed_leveling();
#endif #endif

View File

@ -283,6 +283,10 @@ void menu_bed_leveling() {
EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX); EDIT_ITEM(LCD_Z_OFFSET_TYPE, MSG_ZPROBE_ZOFFSET, &probe.offset.z, Z_PROBE_OFFSET_RANGE_MIN, Z_PROBE_OFFSET_RANGE_MAX);
#endif #endif
#if ENABLED(PROBE_OFFSET_WIZARD)
SUBMENU(MSG_PROBE_WIZARD, goto_probe_offset_wizard);
#endif
#if ENABLED(LEVEL_BED_CORNERS) #if ENABLED(LEVEL_BED_CORNERS)
SUBMENU(MSG_LEVEL_CORNERS, _lcd_level_bed_corners); SUBMENU(MSG_LEVEL_CORNERS, _lcd_level_bed_corners);
#endif #endif

View File

@ -0,0 +1,142 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* 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/>.
*
*/
//
// Calibrate Probe offset menu.
//
#include "../../inc/MarlinConfigPre.h"
#if ENABLED(PROBE_OFFSET_WIZARD)
#ifndef PROBE_OFFSET_START
#error "PROBE_OFFSET_WIZARD requires a PROBE_OFFSET_START with a negative value."
#else
static_assert(PROBE_OFFSET_START < 0, "PROBE_OFFSET_START must be < 0. Please update your configuration.");
#endif
#include "menu_item.h"
#include "menu_addon.h"
#include "../../module/motion.h"
#include "../../module/planner.h"
#include "../../module/probe.h"
#if HAS_LEVELING
#include "../../feature/bedlevel/bedlevel.h"
#endif
// Global storage
float z_offset_backup, calculated_z_offset;
TERN_(HAS_LEVELING, bool leveling_was_active);
TERN_(HAS_SOFTWARE_ENDSTOPS, bool store_soft_endstops_enabled);
void prepare_for_calibration() {
z_offset_backup = probe.offset.z;
// Disable soft endstops for free Z movement
#if HAS_SOFTWARE_ENDSTOPS
store_soft_endstops_enabled = soft_endstops_enabled;
soft_endstops_enabled = false;
#endif
// Disable leveling for raw planner motion
#if HAS_LEVELING
leveling_was_active = planner.leveling_active;
set_bed_leveling_enabled(false);
#endif
}
void set_offset_and_go_back(const float &z) {
probe.offset.z = z;
TERN_(HAS_SOFTWARE_ENDSTOPS, soft_endstops_enabled = store_soft_endstops_enabled);
TERN_(HAS_LEVELING, set_bed_leveling_enabled(leveling_was_active));
ui.goto_previous_screen_no_defer();
}
void _goto_manual_move_z(const float scale) {
ui.manual_move.menu_scale = scale;
ui.goto_screen(lcd_move_z);
}
void probe_offset_wizard_menu() {
START_MENU();
calculated_z_offset = probe.offset.z + current_position.z;
if (LCD_HEIGHT >= 4)
STATIC_ITEM(MSG_MOVE_NOZZLE_TO_BED, SS_CENTER|SS_INVERT);
STATIC_ITEM_P(PSTR("Z="), SS_CENTER, ftostr42_52(current_position.z));
STATIC_ITEM(MSG_ZPROBE_ZOFFSET, SS_LEFT, ftostr42_52(calculated_z_offset));
SUBMENU(MSG_MOVE_1MM, []{ _goto_manual_move_z( 1); });
SUBMENU(MSG_MOVE_01MM, []{ _goto_manual_move_z( 0.1f); });
if ((SHORT_MANUAL_Z_MOVE) > 0.0f && (SHORT_MANUAL_Z_MOVE) < 0.1f) {
extern const char NUL_STR[];
SUBMENU_P(NUL_STR, []{ _goto_manual_move_z(float(SHORT_MANUAL_Z_MOVE)); });
MENU_ITEM_ADDON_START(0 + ENABLED(HAS_CHARACTER_LCD));
char tmp[20], numstr[10];
// Determine digits needed right of decimal
const uint8_t digs = !UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 1000 - int((SHORT_MANUAL_Z_MOVE) * 1000)) ? 4 :
!UNEAR_ZERO((SHORT_MANUAL_Z_MOVE) * 100 - int((SHORT_MANUAL_Z_MOVE) * 100)) ? 3 : 2;
sprintf_P(tmp, GET_TEXT(MSG_MOVE_Z_DIST), dtostrf(SHORT_MANUAL_Z_MOVE, 1, digs, numstr));
lcd_put_u8str(tmp);
MENU_ITEM_ADDON_END();
}
ACTION_ITEM(MSG_BUTTON_DONE, []{
set_offset_and_go_back(calculated_z_offset);
do_z_clearance(20.0
#ifdef Z_AFTER_HOMING
- 20.0 + Z_AFTER_HOMING
#endif
);
});
ACTION_ITEM(MSG_BUTTON_CANCEL, []{
set_offset_and_go_back(z_offset_backup);
});
END_MENU();
}
void goto_probe_offset_wizard() {
ui.defer_status_screen();
prepare_for_calibration();
probe.offset.z = PROBE_OFFSET_START;
set_all_unhomed();
queue.inject_P(G28_STR);
ui.goto_screen([]{
_lcd_draw_homing();
if (all_axes_homed()) {
ui.goto_screen(probe_offset_wizard_menu);
ui.defer_status_screen();
}
});
}
#endif // PROBE_OFFSET_WIZARD

View File

@ -139,7 +139,7 @@ opt_enable COREYX USE_XMAX_PLUG MIXING_EXTRUDER GRADIENT_MIX \
BABYSTEPPING BABYSTEP_DISPLAY_TOTAL FILAMENT_LCD_DISPLAY \ BABYSTEPPING BABYSTEP_DISPLAY_TOTAL FILAMENT_LCD_DISPLAY \
REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER MENU_ADDAUTOSTART SDSUPPORT SDCARD_SORT_ALPHA \ REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER MENU_ADDAUTOSTART SDSUPPORT SDCARD_SORT_ALPHA \
ENDSTOP_NOISE_THRESHOLD FAN_SOFT_PWM \ ENDSTOP_NOISE_THRESHOLD FAN_SOFT_PWM \
FIX_MOUNTED_PROBE AUTO_BED_LEVELING_LINEAR DEBUG_LEVELING_FEATURE FILAMENT_WIDTH_SENSOR \ FIX_MOUNTED_PROBE AUTO_BED_LEVELING_LINEAR DEBUG_LEVELING_FEATURE FILAMENT_WIDTH_SENSOR PROBE_OFFSET_WIZARD \
Z_SAFE_HOMING SHOW_TEMP_ADC_VALUES HOME_Y_BEFORE_X EMERGENCY_PARSER \ Z_SAFE_HOMING SHOW_TEMP_ADC_VALUES HOME_Y_BEFORE_X EMERGENCY_PARSER \
SD_ABORT_ON_ENDSTOP_HIT HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT ADVANCED_OK M114_DETAIL \ SD_ABORT_ON_ENDSTOP_HIT HOST_ACTION_COMMANDS HOST_PROMPT_SUPPORT ADVANCED_OK M114_DETAIL \
VOLUMETRIC_DEFAULT_ON NO_WORKSPACE_OFFSETS EXTRA_FAN_SPEED FWRETRACT \ VOLUMETRIC_DEFAULT_ON NO_WORKSPACE_OFFSETS EXTRA_FAN_SPEED FWRETRACT \