Internal G29N for G28+G29 (#20800)

This commit is contained in:
Scott Lahteine 2021-01-17 12:08:40 -06:00
parent f101e19257
commit 6162560b69
12 changed files with 24 additions and 18 deletions

View File

@ -3344,7 +3344,7 @@
//#define USER_SCRIPT_RETURN // Return to status screen after a script
#define USER_DESC_1 "Home & UBL Info"
#define USER_GCODE_1 "G28\nG29 W"
#define USER_GCODE_1 "G29NW"
#define USER_DESC_2 "Preheat for " PREHEAT_1_LABEL
#define USER_GCODE_2 "M140 S" STRINGIFY(PREHEAT_1_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_1_TEMP_HOTEND)
@ -3353,7 +3353,7 @@
#define USER_GCODE_3 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nM104 S" STRINGIFY(PREHEAT_2_TEMP_HOTEND)
#define USER_DESC_4 "Heat Bed/Home/Level"
#define USER_GCODE_4 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nG28\nG29"
#define USER_GCODE_4 "M140 S" STRINGIFY(PREHEAT_2_TEMP_BED) "\nG29N"
#define USER_DESC_5 "Home & Info"
#define USER_GCODE_5 "G28\nM503"

View File

@ -321,7 +321,8 @@
// Check for commands that require the printer to be homed
if (may_move) {
planner.synchronize();
if (axes_should_home()) gcode.home_all_axes();
// Send 'N' to force homing before G29 (internal only)
if (axes_should_home() || parser.seen('N')) gcode.home_all_axes();
TERN_(HAS_MULTI_HOTEND, if (active_extruder) tool_change(0));
}

View File

@ -181,14 +181,18 @@ G29_TYPE GcodeSuite::G29() {
no_action = seenA || seenQ,
faux = ENABLED(DEBUG_LEVELING_FEATURE) && DISABLED(PROBE_MANUALLY) ? parser.boolval('C') : no_action;
// Don't allow auto-leveling without homing first
if (homing_needed_error()) G29_RETURN(false);
if (!no_action && planner.leveling_active && parser.boolval('O')) { // Auto-level only if needed
if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("> Auto-level not needed, skip");
G29_RETURN(false);
}
// Send 'N' to force homing before G29 (internal only)
if (parser.seen('N'))
gcode.process_subcommands_now_P(TERN(G28_L0_ENSURES_LEVELING_OFF, PSTR("G28L0"), G28_STR));
// Don't allow auto-leveling without homing first
if (homing_needed_error()) G29_RETURN(false);
// Define local vars 'static' for manual probing, 'auto' otherwise
#define ABL_VAR TERN_(PROBE_MANUALLY, static)
@ -249,7 +253,6 @@ G29_TYPE GcodeSuite::G29() {
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
struct linear_fit_data lsf_results;
incremental_LSF_reset(&lsf_results);
#endif
/**
@ -324,6 +327,8 @@ G29_TYPE GcodeSuite::G29() {
#if ENABLED(AUTO_BED_LEVELING_LINEAR)
incremental_LSF_reset(&lsf_results);
do_topography_map = verbose_level > 2 || parser.boolval('T');
// X and Y specify points in each direction, overriding the default

View File

@ -85,7 +85,7 @@ void GcodeSuite::G29() {
mbl.reset();
mbl_probe_index = 0;
if (!ui.wait_for_move) {
queue.inject_P(PSTR("G28\nG29 S2"));
queue.inject_P(parser.seen('N') ? PSTR("G28" TERN(G28_L0_ENSURES_LEVELING_OFF, "L0", "") "\nG29S2") : PSTR("G29S2"));
return;
}
state = MeshNext;

View File

@ -102,7 +102,7 @@ void GcodeSuite::M600() {
#if ENABLED(HOME_BEFORE_FILAMENT_CHANGE)
// If needed, home before parking for filament change
if (!all_axes_trusted()) home_all_axes();
if (!all_axes_trusted()) home_all_axes(true);
#endif
#if HAS_MULTI_EXTRUDER

View File

@ -369,9 +369,9 @@ public:
static void process_subcommands_now_P(PGM_P pgcode);
static void process_subcommands_now(char * gcode);
static inline void home_all_axes() {
static inline void home_all_axes(const bool keep_leveling=false) {
extern const char G28_STR[];
process_subcommands_now_P(G28_STR);
process_subcommands_now_P(keep_leveling ? G28_STR : TERN(G28_L0_ENSURES_LEVELING_OFF, PSTR("G28L0"), G28_STR));
}
#if EITHER(HAS_AUTO_REPORTING, HOST_KEEPALIVE_FEATURE)

View File

@ -324,7 +324,7 @@ void AnycubicTFTClass::HandleSpecialMenu() {
case '2': // "<02ABL>"
SERIAL_ECHOLNPGM("Special Menu: Auto Bed Leveling");
ExtUI::injectCommands_P(PSTR("G28\nG29"));
ExtUI::injectCommands_P(PSTR("G29N"));
break;
case '3': // "<03HtendPID>"

View File

@ -75,7 +75,7 @@ extern lv_group_t *g;
extern void LCD_IO_WriteData(uint16_t RegValue);
static const char custom_gcode_command[][100] = {
"G28\nG29\nM500",
"G29N\nM500",
"G28",
"G28",
"G28",

View File

@ -213,7 +213,7 @@ static inline void _lcd_level_bed_corners_get_next_position() {
void _lcd_draw_level_prompt() {
if (!ui.should_draw()) return;
MenuItem_confirm::confirm_screen(
[]{ queue.inject_P(TERN(HAS_LEVELING, PSTR("G28\nG29"), G28_STR));
[]{ queue.inject_P(TERN(HAS_LEVELING, PSTR("G29N"), G28_STR));
ui.return_to_status();
}
, []{ ui.goto_previous_screen_no_defer(); }

View File

@ -254,7 +254,7 @@ void menu_bed_leveling() {
SUBMENU(MSG_LEVEL_BED, _lcd_level_bed_continue);
#else
// Automatic leveling can just run the G-code
GCODES_ITEM(MSG_LEVEL_BED, is_homed ? PSTR("G29") : PSTR("G28\nG29"));
GCODES_ITEM(MSG_LEVEL_BED, is_homed ? PSTR("G29") : PSTR("G29N"));
#endif
#if ENABLED(MESH_EDIT_MENU)

View File

@ -382,7 +382,7 @@ void menu_motion() {
#elif HAS_LEVELING && DISABLED(SLIM_LCD_MENUS)
#if DISABLED(PROBE_MANUALLY)
GCODES_ITEM(MSG_LEVEL_BED, PSTR("G28\nG29"));
GCODES_ITEM(MSG_LEVEL_BED, PSTR("G29N"));
#endif
if (all_axes_homed() && leveling_is_valid()) {

View File

@ -355,7 +355,7 @@ void _lcd_ubl_build_mesh() {
#endif // PREHEAT_COUNT
SUBMENU(MSG_UBL_BUILD_CUSTOM_MESH, _lcd_ubl_custom_mesh);
GCODES_ITEM(MSG_UBL_BUILD_COLD_MESH, PSTR("G28\nG29P1"));
GCODES_ITEM(MSG_UBL_BUILD_COLD_MESH, PSTR("G29NP1"));
SUBMENU(MSG_UBL_FILLIN_MESH, _menu_ubl_fillin);
GCODES_ITEM(MSG_UBL_CONTINUE_MESH, PSTR("G29P1C"));
ACTION_ITEM(MSG_UBL_INVALIDATE_ALL, _lcd_ubl_invalidate);
@ -589,7 +589,7 @@ void _menu_ubl_tools() {
void _lcd_ubl_step_by_step() {
START_MENU();
BACK_ITEM(MSG_UBL_LEVEL_BED);
GCODES_ITEM(MSG_UBL_1_BUILD_COLD_MESH, PSTR("G28\nG29P1"));
GCODES_ITEM(MSG_UBL_1_BUILD_COLD_MESH, PSTR("G29NP1"));
GCODES_ITEM(MSG_UBL_2_SMART_FILLIN, PSTR("G29P3T0"));
SUBMENU(MSG_UBL_3_VALIDATE_MESH_MENU, _lcd_ubl_validate_mesh);
GCODES_ITEM(MSG_UBL_4_FINE_TUNE_ALL, PSTR("G29P4R999T"));