From 0cc6955ab72ea03663fa52b5a4f9ecddf40d6bba Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 9 Oct 2021 13:58:25 -0400 Subject: [PATCH 01/15] BLTouch High Speed EEPROM Control --- Marlin/Configuration_adv.h | 2 ++ Marlin/src/feature/bltouch.cpp | 3 ++- Marlin/src/feature/bltouch.h | 7 ++----- Marlin/src/gcode/bedlevel/G35.cpp | 3 ++- Marlin/src/gcode/calibrate/G34_M422.cpp | 2 +- Marlin/src/gcode/probe/M401_M402.cpp | 12 ++++++++++++ Marlin/src/lcd/language/language_en.h | 1 + Marlin/src/lcd/menu/menu_bed_corners.cpp | 15 ++++++++------- Marlin/src/lcd/menu/menu_configuration.cpp | 1 + Marlin/src/lcd/menu/menu_tramming.cpp | 3 ++- Marlin/src/module/motion.cpp | 9 +++++---- Marlin/src/module/probe.cpp | 19 +++++++++++-------- Marlin/src/module/settings.cpp | 22 ++++++++++++++++------ 13 files changed, 65 insertions(+), 34 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 8e1f673c87..0b01ec0d61 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -857,6 +857,8 @@ * Danger: Disable if your probe sometimes fails. Only suitable for stable well-adjusted systems. * This feature was designed for Deltabots with very fast Z moves; however, higher speed Cartesians * might be able to use it. If the machine can't raise Z fast enough the BLTouch may go into ALARM. + * + * This sets the default state. Can be changed through the SCD */ //#define BLTOUCH_HS_MODE diff --git a/Marlin/src/feature/bltouch.cpp b/Marlin/src/feature/bltouch.cpp index 49a10f62b1..fbe6012bbe 100644 --- a/Marlin/src/feature/bltouch.cpp +++ b/Marlin/src/feature/bltouch.cpp @@ -28,7 +28,8 @@ BLTouch bltouch; -bool BLTouch::last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain +bool BLTouch::last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain +bool BLTouch::bltouch_high_speed; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed #include "../module/servo.h" #include "../module/probe.h" diff --git a/Marlin/src/feature/bltouch.h b/Marlin/src/feature/bltouch.h index 9ecccb4256..7d9a0bb126 100644 --- a/Marlin/src/feature/bltouch.h +++ b/Marlin/src/feature/bltouch.h @@ -23,10 +23,6 @@ #include "../inc/MarlinConfigPre.h" -#if DISABLED(BLTOUCH_HS_MODE) - #define BLTOUCH_SLOW_MODE 1 -#endif - // BLTouch commands are sent as servo angles typedef unsigned char BLTCommand; @@ -71,7 +67,8 @@ typedef unsigned char BLTCommand; class BLTouch { public: static void init(const bool set_voltage=false); - static bool last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain + static bool last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain + static bool bltouch_high_speed; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed // DEPLOY and STOW are wrapped for error handling - these are used by homing and by probing static bool deploy() { return deploy_proc(); } diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index e45e18b7fb..08539f8966 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -102,7 +102,8 @@ void GcodeSuite::G35() { // In BLTOUCH HS mode, the probe travels in a deployed state. // Users of G35 might have a badly misaligned bed, so raise Z by the // length of the deployed pin (BLTOUCH stroke < 7mm) - do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, Z_CLEARANCE_BETWEEN_PROBES, 7)); + float z_raise_probe = Z_CLEARANCE_BETWEEN_PROBES if(bltouch.bltouch_high_speed) + 7; + do_blocking_move_to_z(z_raise_probe); const float z_probed_height = probe.probe_at_point(tramming_points[i], PROBE_PT_RAISE, 0, true); if (isnan(z_probed_height)) { diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 8f4eab2c97..5b70dc588e 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -149,7 +149,7 @@ void GcodeSuite::G34() { // In BLTOUCH HS mode, the probe travels in a deployed state. // Users of G34 might have a badly misaligned bed, so raise Z by the // length of the deployed pin (BLTOUCH stroke < 7mm) - #define Z_BASIC_CLEARANCE (Z_CLEARANCE_BETWEEN_PROBES + 7.0f * BOTH(BLTOUCH, BLTOUCH_HS_MODE)) + #define Z_BASIC_CLEARANCE (Z_CLEARANCE_BETWEEN_PROBES + 7.0f * bltouch.bltouch_high_speed) // Compute a worst-case clearance height to probe from. After the first // iteration this will be re-calculated based on the actual bed position diff --git a/Marlin/src/gcode/probe/M401_M402.cpp b/Marlin/src/gcode/probe/M401_M402.cpp index bd9bb44c40..aef34f3a1e 100644 --- a/Marlin/src/gcode/probe/M401_M402.cpp +++ b/Marlin/src/gcode/probe/M401_M402.cpp @@ -27,11 +27,23 @@ #include "../gcode.h" #include "../../module/motion.h" #include "../../module/probe.h" +#if ENABLED(BLTOUCH) + #include "../../feature/bltouch.h" +#endif /** * M401: Deploy and activate the Z probe */ void GcodeSuite::M401() { + #if ENABLED(BLTOUCH) + const bool seen_S = parser.seen('S'), + to_enable = (seen_S && parser.value_bool()); + if (seen_S) + if(to_enable) + bltouch.bltouch_high_speed = true; + else + bltouch.bltouch_high_speed = false; + #endif probe.deploy(); TERN_(PROBE_TARE, probe.tare()); report_current_position(); diff --git a/Marlin/src/lcd/language/language_en.h b/Marlin/src/lcd/language/language_en.h index c9413d3cea..8b8073b5bb 100644 --- a/Marlin/src/lcd/language/language_en.h +++ b/Marlin/src/lcd/language/language_en.h @@ -491,6 +491,7 @@ namespace Language_en { LSTR MSG_BLTOUCH_STOW = _UxGT("Stow"); LSTR MSG_BLTOUCH_DEPLOY = _UxGT("Deploy"); LSTR MSG_BLTOUCH_SW_MODE = _UxGT("SW-Mode"); + LSTR MSG_BLTOUCH_SPEED_MODE = _UxGT("High Speed"); LSTR MSG_BLTOUCH_5V_MODE = _UxGT("5V-Mode"); LSTR MSG_BLTOUCH_OD_MODE = _UxGT("OD-Mode"); LSTR MSG_BLTOUCH_MODE_STORE = _UxGT("Mode-Store"); diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 178d466478..8dd737a805 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -221,13 +221,13 @@ static void _lcd_level_bed_corners_get_next_position() { bool _lcd_level_bed_corners_probe(bool verify=false) { if (verify) do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); // do clearance if needed - TERN_(BLTOUCH_SLOW_MODE, bltouch.deploy()); // Deploy in LOW SPEED MODE on every probe action + if(!bltouch.bltouch_high_speed) bltouch.deploy(); // Deploy in LOW SPEED MODE on every probe action do_blocking_move_to_z(last_z - LEVEL_CORNERS_PROBE_TOLERANCE, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW)); // Move down to lower tolerance if (TEST(endstops.trigger_state(), Z_MIN_PROBE)) { // check if probe triggered endstops.hit_on_purpose(); set_current_from_steppers_for_axis(Z_AXIS); sync_plan_position(); - TERN_(BLTOUCH_SLOW_MODE, bltouch.stow()); // Stow in LOW SPEED MODE on every trigger + if(!bltouch.bltouch_high_speed) bltouch.stow(); // Stow in LOW SPEED MODE on every trigger // Triggered outside tolerance range? if (ABS(current_position.z - last_z) > LEVEL_CORNERS_PROBE_TOLERANCE) { last_z = current_position.z; // Above tolerance. Set a new Z for subsequent corners. @@ -253,7 +253,7 @@ static void _lcd_level_bed_corners_get_next_position() { } idle(); } - TERN_(BLTOUCH_SLOW_MODE, bltouch.stow()); + if(!bltouch.bltouch_high_speed) bltouch.stow(); ui.goto_screen(_lcd_draw_probing); return (probe_triggered); } @@ -267,13 +267,14 @@ static void _lcd_level_bed_corners_get_next_position() { do { ui.refresh(LCDVIEW_REDRAW_NOW); _lcd_draw_probing(); // update screen with # of good points - do_blocking_move_to_z(SUM_TERN(BLTOUCH_HS_MODE, current_position.z + LEVEL_CORNERS_Z_HOP, 7)); // clearance + float z_raise_probe = Z_CLEARANCE_BETWEEN_PROBES if(bltouch.bltouch_high_speed) + 7; + do_blocking_move_to_z(SUM_TERN(z_raise_probe, current_position.z + LEVEL_CORNERS_Z_HOP, 7)); // clearance _lcd_level_bed_corners_get_next_position(); // Select next corner coordinates current_position -= probe.offset_xy; // Account for probe offsets do_blocking_move_to_xy(current_position); // Goto corner - TERN_(BLTOUCH_HS_MODE, bltouch.deploy()); // Deploy in HIGH SPEED MODE + if(bltouch.bltouch_high_speed) bltouch.deploy(); // Deploy in HIGH SPEED MODE if (!_lcd_level_bed_corners_probe()) { // Probe down to tolerance if (_lcd_level_bed_corners_raise()) { // Prompt user to raise bed if needed #if ENABLED(LEVEL_CORNERS_VERIFY_RAISED) // Verify @@ -294,11 +295,11 @@ static void _lcd_level_bed_corners_get_next_position() { } while (good_points < nr_edge_points); // loop until all points within tolerance - #if ENABLED(BLTOUCH_HS_MODE) + if (bltouch.bltouch_high_speed) // In HIGH SPEED MODE do clearance and stow at the very end do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); bltouch.stow(); - #endif + } ui.goto_screen(_lcd_draw_level_prompt); // prompt for bed leveling ui.set_selection(true); diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 0e11cd211a..5865d4898c 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -235,6 +235,7 @@ void menu_advanced_settings(); ACTION_ITEM(MSG_BLTOUCH_DEPLOY, bltouch._deploy); ACTION_ITEM(MSG_BLTOUCH_STOW, bltouch._stow); ACTION_ITEM(MSG_BLTOUCH_SW_MODE, bltouch._set_SW_mode); + EDIT_ITEM(bool, MSG_BLTOUCH_SPEED_MODE, &bltouch.bltouch_high_speed); #if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU) CONFIRM_ITEM(MSG_BLTOUCH_5V_MODE, MSG_BLTOUCH_5V_MODE, MSG_BUTTON_CANCEL, bltouch._set_5V_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); CONFIRM_ITEM(MSG_BLTOUCH_OD_MODE, MSG_BLTOUCH_OD_MODE, MSG_BUTTON_CANCEL, bltouch._set_OD_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index 5cdcf75c1e..5109a699ed 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -51,7 +51,8 @@ static int8_t reference_index; // = 0 static bool probe_single_point() { do_blocking_move_to_z(TERN(BLTOUCH, Z_CLEARANCE_DEPLOY_PROBE, Z_CLEARANCE_BETWEEN_PROBES)); // Stow after each point with BLTouch "HIGH SPEED" mode for push-pin safety - const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], TERN(BLTOUCH_HS_MODE, PROBE_PT_STOW, PROBE_PT_RAISE), 0, true); + + const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], if(bltouch.bltouch_high_speed) PROBE_PT_STOW else PROBE_PT_RAISE), 0, true); z_measured[tram_index] = z_probed_height; if (reference_index < 0) reference_index = tram_index; move_to_tramming_wait_pos(); diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 1f13bd22ee..091facc94c 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1799,8 +1799,8 @@ void prepare_line_to_destination() { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home Fast: ", move_length, "mm"); do_homing_move(axis, move_length, 0.0, !use_probe_bump); - #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH_SLOW_MODE) - if (axis == Z_AXIS) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE) + #if ENABLED(HOMING_Z_WITH_PROBE, BLTOUCH) + if (axis == Z_AXIS && !bltouch.bltouch_high_speed) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE) #endif // If a second homing move is configured... @@ -1833,8 +1833,9 @@ void prepare_line_to_destination() { } #endif - #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH_SLOW_MODE) - if (axis == Z_AXIS && bltouch.deploy()) return; // Intermediate DEPLOY (in LOW SPEED MODE) + #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH) + if(!bltouch.bltouch_high_speed) + if (axis == Z_AXIS && bltouch.deploy()) return; // Intermediate DEPLOY (in LOW SPEED MODE) #endif // Slow move towards endstop until triggered diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 4078effe76..f2f5eee520 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -487,8 +487,10 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { #if BOTH(HAS_TEMP_HOTEND, WAIT_FOR_HOTEND) thermalManager.wait_for_hotend_heating(active_extruder); #endif - - if (TERN0(BLTOUCH_SLOW_MODE, bltouch.deploy())) return true; // Deploy in LOW SPEED MODE on every probe action + #if ENABLED(BLTOUCH) + if(!bltouch.bltouch_high_speed) + if (bltouch.deploy()) return true; // Deploy in LOW SPEED MODE on every probe action + #endif // Disable stealthChop if used. Enable diag1 pin on driver. #if ENABLED(SENSORLESS_PROBING) @@ -528,10 +530,11 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { if (probe.test_sensitivity.z) tmc_disable_stallguard(stepperZ, stealth_states.z); set_homing_current(false); #endif - - if (probe_triggered && TERN0(BLTOUCH_SLOW_MODE, bltouch.stow())) // Stow in LOW SPEED MODE on every trigger - return true; - + #if ENABLED(BLTOUCH) + if(!bltouch.bltouch_high_speed) + if (probe_triggered && bltouch.stow()) // Stow in LOW SPEED MODE on every trigger + return true; + #endif // Clear endstop flags endstops.hit_on_purpose(); @@ -760,8 +763,8 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai DEBUG_POS("", current_position); } - #if BOTH(BLTOUCH, BLTOUCH_HS_MODE) - if (bltouch.triggered()) bltouch._reset(); + #if ENABLED(BLTOUCH) + if (bltouch.triggered() && bltouch.bltouch_high_speed) bltouch._reset(); #endif // On delta keep Z below clip height or do_blocking_move_to will abort diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 6b7143e82a..9698348ae3 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -36,7 +36,7 @@ */ // Change EEPROM version if the structure changes -#define EEPROM_VERSION "V85" +#define EEPROM_VERSION "V86" #define EEPROM_OFFSET 100 // Check the integrity of data offsets. @@ -277,6 +277,7 @@ typedef struct SettingsDataStruct { // BLTOUCH // bool bltouch_last_written_mode; + bool bltouch_high_speed;. // // Kinematic Settings @@ -861,6 +862,10 @@ void MarlinSettings::postprocess() { _FIELD_TEST(bltouch_last_written_mode); const bool bltouch_last_written_mode = TERN(BLTOUCH, bltouch.last_written_mode, false); EEPROM_WRITE(bltouch_last_written_mode); + + _FIELD_TEST(bltouch_high_speed); + const bool bltouch_high_speed = TERN(BLTOUCH, bltouch.bltouch_high_speed, false); + EEPROM_WRITE(bltouch_high_speed); } // @@ -1732,6 +1737,14 @@ void MarlinSettings::postprocess() { bool bltouch_last_written_mode; #endif EEPROM_READ(bltouch_last_written_mode); + + _FIELD_TEST(bltouch_high_speed); + #if ENABLED(BLTOUCH) + const bool &bltouch_high_speed = bltouch.bltouch_high_speed; + #else + bool bltouch_high_speed; + #endif + EEPROM_READ(bltouch_last_written_mode); } // @@ -2729,12 +2742,9 @@ void MarlinSettings::reset() { TERN_(EDITABLE_SERVO_ANGLES, COPY(servo_angles, base_servo_angles)); // When not editable only one copy of servo angles exists // - // BLTOUCH + // BLTouch // - //#if ENABLED(BLTOUCH) - // bltouch.last_written_mode; - //#endif - + TERN_(BLTOUCH_HS_MODE, bltouch.bltouch_high_speed = true); // // Kinematic settings // From 4f62ae97640a0888825d615fce4178de42e74fa9 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Sat, 9 Oct 2021 14:07:02 -0400 Subject: [PATCH 02/15] Return on mode change without deploying --- Marlin/src/gcode/probe/M401_M402.cpp | 6 +++++- Marlin/src/module/settings.cpp | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/probe/M401_M402.cpp b/Marlin/src/gcode/probe/M401_M402.cpp index aef34f3a1e..95828c23b1 100644 --- a/Marlin/src/gcode/probe/M401_M402.cpp +++ b/Marlin/src/gcode/probe/M401_M402.cpp @@ -33,16 +33,20 @@ /** * M401: Deploy and activate the Z probe + * BLTouch Only : + * S : Set High Speed Mode */ void GcodeSuite::M401() { #if ENABLED(BLTOUCH) const bool seen_S = parser.seen('S'), to_enable = (seen_S && parser.value_bool()); - if (seen_S) + if (seen_S) { if(to_enable) bltouch.bltouch_high_speed = true; else bltouch.bltouch_high_speed = false; + return; + } #endif probe.deploy(); TERN_(PROBE_TARE, probe.tare()); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 9698348ae3..80b9736478 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -277,7 +277,7 @@ typedef struct SettingsDataStruct { // BLTOUCH // bool bltouch_last_written_mode; - bool bltouch_high_speed;. + bool bltouch_high_speed; // // Kinematic Settings From ec7a4eb69ebea87362e8bbc7bd48c929c0e963d9 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sat, 9 Oct 2021 18:41:47 -0500 Subject: [PATCH 03/15] clean up and fix --- Marlin/src/feature/bltouch.cpp | 4 ++-- Marlin/src/feature/bltouch.h | 7 +++++-- Marlin/src/gcode/bedlevel/G35.cpp | 3 +-- Marlin/src/gcode/calibrate/G34_M422.cpp | 2 +- Marlin/src/gcode/probe/M401_M402.cpp | 9 ++------- Marlin/src/lcd/menu/menu_bed_corners.cpp | 13 ++++++------- Marlin/src/lcd/menu/menu_configuration.cpp | 2 +- Marlin/src/lcd/menu/menu_tramming.cpp | 2 +- Marlin/src/module/motion.cpp | 6 +++--- Marlin/src/module/probe.cpp | 11 +++++------ Marlin/src/module/settings.cpp | 16 ++++++++-------- 11 files changed, 35 insertions(+), 40 deletions(-) diff --git a/Marlin/src/feature/bltouch.cpp b/Marlin/src/feature/bltouch.cpp index fbe6012bbe..9450ae8ee7 100644 --- a/Marlin/src/feature/bltouch.cpp +++ b/Marlin/src/feature/bltouch.cpp @@ -28,8 +28,8 @@ BLTouch bltouch; -bool BLTouch::last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain -bool BLTouch::bltouch_high_speed; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed +bool BLTouch::last_written_mode, // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain + BLTouch::high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed #include "../module/servo.h" #include "../module/probe.h" diff --git a/Marlin/src/feature/bltouch.h b/Marlin/src/feature/bltouch.h index 7d9a0bb126..f1485826b5 100644 --- a/Marlin/src/feature/bltouch.h +++ b/Marlin/src/feature/bltouch.h @@ -66,9 +66,12 @@ typedef unsigned char BLTCommand; class BLTouch { public: + static void init(const bool set_voltage=false); - static bool last_written_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain - static bool bltouch_high_speed; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed + static bool last_written_mode, // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain + high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed + + const float z_extra_clearance() { return high_speed_mode ? 7 : 0; } // DEPLOY and STOW are wrapped for error handling - these are used by homing and by probing static bool deploy() { return deploy_proc(); } diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index 08539f8966..8ce6abfb95 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -102,8 +102,7 @@ void GcodeSuite::G35() { // In BLTOUCH HS mode, the probe travels in a deployed state. // Users of G35 might have a badly misaligned bed, so raise Z by the // length of the deployed pin (BLTOUCH stroke < 7mm) - float z_raise_probe = Z_CLEARANCE_BETWEEN_PROBES if(bltouch.bltouch_high_speed) + 7; - do_blocking_move_to_z(z_raise_probe); + do_blocking_move_to_z(Z_CLEARANCE_BETWEEN_PROBES + TERN0(BLTOUCH, bltouch.z_extra_clearance())); const float z_probed_height = probe.probe_at_point(tramming_points[i], PROBE_PT_RAISE, 0, true); if (isnan(z_probed_height)) { diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 5b70dc588e..11f3eac6fa 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -149,7 +149,7 @@ void GcodeSuite::G34() { // In BLTOUCH HS mode, the probe travels in a deployed state. // Users of G34 might have a badly misaligned bed, so raise Z by the // length of the deployed pin (BLTOUCH stroke < 7mm) - #define Z_BASIC_CLEARANCE (Z_CLEARANCE_BETWEEN_PROBES + 7.0f * bltouch.bltouch_high_speed) + #define Z_BASIC_CLEARANCE (Z_CLEARANCE_BETWEEN_PROBES + TERN0(BLTOUCH, bltouch.z_extra_clearance())) // Compute a worst-case clearance height to probe from. After the first // iteration this will be re-calculated based on the actual bed position diff --git a/Marlin/src/gcode/probe/M401_M402.cpp b/Marlin/src/gcode/probe/M401_M402.cpp index 95828c23b1..390c31b2db 100644 --- a/Marlin/src/gcode/probe/M401_M402.cpp +++ b/Marlin/src/gcode/probe/M401_M402.cpp @@ -38,13 +38,8 @@ */ void GcodeSuite::M401() { #if ENABLED(BLTOUCH) - const bool seen_S = parser.seen('S'), - to_enable = (seen_S && parser.value_bool()); - if (seen_S) { - if(to_enable) - bltouch.bltouch_high_speed = true; - else - bltouch.bltouch_high_speed = false; + if (parser.seen('S')) { + bltouch.high_speed_mode = parser.value_bool(); return; } #endif diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 8dd737a805..b1dfe5a4a4 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -221,13 +221,13 @@ static void _lcd_level_bed_corners_get_next_position() { bool _lcd_level_bed_corners_probe(bool verify=false) { if (verify) do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); // do clearance if needed - if(!bltouch.bltouch_high_speed) bltouch.deploy(); // Deploy in LOW SPEED MODE on every probe action + if (!bltouch.high_speed_mode) bltouch.deploy(); // Deploy in LOW SPEED MODE on every probe action do_blocking_move_to_z(last_z - LEVEL_CORNERS_PROBE_TOLERANCE, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW)); // Move down to lower tolerance if (TEST(endstops.trigger_state(), Z_MIN_PROBE)) { // check if probe triggered endstops.hit_on_purpose(); set_current_from_steppers_for_axis(Z_AXIS); sync_plan_position(); - if(!bltouch.bltouch_high_speed) bltouch.stow(); // Stow in LOW SPEED MODE on every trigger + if (!bltouch.high_speed_mode) bltouch.stow(); // Stow in LOW SPEED MODE on every trigger // Triggered outside tolerance range? if (ABS(current_position.z - last_z) > LEVEL_CORNERS_PROBE_TOLERANCE) { last_z = current_position.z; // Above tolerance. Set a new Z for subsequent corners. @@ -253,7 +253,7 @@ static void _lcd_level_bed_corners_get_next_position() { } idle(); } - if(!bltouch.bltouch_high_speed) bltouch.stow(); + if (!bltouch.high_speed_mode) bltouch.stow(); ui.goto_screen(_lcd_draw_probing); return (probe_triggered); } @@ -267,14 +267,13 @@ static void _lcd_level_bed_corners_get_next_position() { do { ui.refresh(LCDVIEW_REDRAW_NOW); _lcd_draw_probing(); // update screen with # of good points - float z_raise_probe = Z_CLEARANCE_BETWEEN_PROBES if(bltouch.bltouch_high_speed) + 7; - do_blocking_move_to_z(SUM_TERN(z_raise_probe, current_position.z + LEVEL_CORNERS_Z_HOP, 7)); // clearance + do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP + (bltouch.high_speed_mode ? 7, 0)); // clearance _lcd_level_bed_corners_get_next_position(); // Select next corner coordinates current_position -= probe.offset_xy; // Account for probe offsets do_blocking_move_to_xy(current_position); // Goto corner - if(bltouch.bltouch_high_speed) bltouch.deploy(); // Deploy in HIGH SPEED MODE + if (bltouch.high_speed_mode) bltouch.deploy(); // Deploy in HIGH SPEED MODE if (!_lcd_level_bed_corners_probe()) { // Probe down to tolerance if (_lcd_level_bed_corners_raise()) { // Prompt user to raise bed if needed #if ENABLED(LEVEL_CORNERS_VERIFY_RAISED) // Verify @@ -295,7 +294,7 @@ static void _lcd_level_bed_corners_get_next_position() { } while (good_points < nr_edge_points); // loop until all points within tolerance - if (bltouch.bltouch_high_speed) + if (bltouch.high_speed_mode) // In HIGH SPEED MODE do clearance and stow at the very end do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); bltouch.stow(); diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 5865d4898c..6006f86891 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -235,7 +235,7 @@ void menu_advanced_settings(); ACTION_ITEM(MSG_BLTOUCH_DEPLOY, bltouch._deploy); ACTION_ITEM(MSG_BLTOUCH_STOW, bltouch._stow); ACTION_ITEM(MSG_BLTOUCH_SW_MODE, bltouch._set_SW_mode); - EDIT_ITEM(bool, MSG_BLTOUCH_SPEED_MODE, &bltouch.bltouch_high_speed); + EDIT_ITEM(bool, MSG_BLTOUCH_SPEED_MODE, &bltouch.high_speed_mode); #if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU) CONFIRM_ITEM(MSG_BLTOUCH_5V_MODE, MSG_BLTOUCH_5V_MODE, MSG_BUTTON_CANCEL, bltouch._set_5V_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); CONFIRM_ITEM(MSG_BLTOUCH_OD_MODE, MSG_BLTOUCH_OD_MODE, MSG_BUTTON_CANCEL, bltouch._set_OD_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index 5109a699ed..ce9e50b3e7 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -52,7 +52,7 @@ static bool probe_single_point() { do_blocking_move_to_z(TERN(BLTOUCH, Z_CLEARANCE_DEPLOY_PROBE, Z_CLEARANCE_BETWEEN_PROBES)); // Stow after each point with BLTouch "HIGH SPEED" mode for push-pin safety - const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], if(bltouch.bltouch_high_speed) PROBE_PT_STOW else PROBE_PT_RAISE), 0, true); + const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], bltouch.high_speed_mode ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true); z_measured[tram_index] = z_probed_height; if (reference_index < 0) reference_index = tram_index; move_to_tramming_wait_pos(); diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 091facc94c..f05e31a498 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1800,7 +1800,7 @@ void prepare_line_to_destination() { do_homing_move(axis, move_length, 0.0, !use_probe_bump); #if ENABLED(HOMING_Z_WITH_PROBE, BLTOUCH) - if (axis == Z_AXIS && !bltouch.bltouch_high_speed) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE) + if (axis == Z_AXIS && !bltouch.high_speed_mode) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE) #endif // If a second homing move is configured... @@ -1834,8 +1834,8 @@ void prepare_line_to_destination() { #endif #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH) - if(!bltouch.bltouch_high_speed) - if (axis == Z_AXIS && bltouch.deploy()) return; // Intermediate DEPLOY (in LOW SPEED MODE) + if (axis == Z_AXIS && !bltouch.high_speed_mode && bltouch.deploy()) + return; // Intermediate DEPLOY (in LOW SPEED MODE) #endif // Slow move towards endstop until triggered diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index f2f5eee520..02903419aa 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -488,8 +488,8 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { thermalManager.wait_for_hotend_heating(active_extruder); #endif #if ENABLED(BLTOUCH) - if(!bltouch.bltouch_high_speed) - if (bltouch.deploy()) return true; // Deploy in LOW SPEED MODE on every probe action + if (!bltouch.high_speed_mode && bltouch.deploy()) + return true; // Deploy in LOW SPEED MODE on every probe action #endif // Disable stealthChop if used. Enable diag1 pin on driver. @@ -531,9 +531,8 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { set_homing_current(false); #endif #if ENABLED(BLTOUCH) - if(!bltouch.bltouch_high_speed) - if (probe_triggered && bltouch.stow()) // Stow in LOW SPEED MODE on every trigger - return true; + if (!bltouch.high_speed_mode && probe_triggered && bltouch.stow()) + return true; // Stow in LOW SPEED MODE on every trigger #endif // Clear endstop flags endstops.hit_on_purpose(); @@ -764,7 +763,7 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai } #if ENABLED(BLTOUCH) - if (bltouch.triggered() && bltouch.bltouch_high_speed) bltouch._reset(); + if (bltouch.triggered() && bltouch.high_speed_mode) bltouch._reset(); #endif // On delta keep Z below clip height or do_blocking_move_to will abort diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 80b9736478..56b071acd2 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -277,7 +277,7 @@ typedef struct SettingsDataStruct { // BLTOUCH // bool bltouch_last_written_mode; - bool bltouch_high_speed; + bool high_speed_mode; // // Kinematic Settings @@ -863,9 +863,9 @@ void MarlinSettings::postprocess() { const bool bltouch_last_written_mode = TERN(BLTOUCH, bltouch.last_written_mode, false); EEPROM_WRITE(bltouch_last_written_mode); - _FIELD_TEST(bltouch_high_speed); - const bool bltouch_high_speed = TERN(BLTOUCH, bltouch.bltouch_high_speed, false); - EEPROM_WRITE(bltouch_high_speed); + _FIELD_TEST(high_speed_mode); + const bool high_speed_mode = TERN(BLTOUCH, bltouch.high_speed_mode, false); + EEPROM_WRITE(high_speed_mode); } // @@ -1738,11 +1738,11 @@ void MarlinSettings::postprocess() { #endif EEPROM_READ(bltouch_last_written_mode); - _FIELD_TEST(bltouch_high_speed); + _FIELD_TEST(high_speed_mode); #if ENABLED(BLTOUCH) - const bool &bltouch_high_speed = bltouch.bltouch_high_speed; + const bool &high_speed_mode = bltouch.high_speed_mode; #else - bool bltouch_high_speed; + bool high_speed_mode; #endif EEPROM_READ(bltouch_last_written_mode); } @@ -2744,7 +2744,7 @@ void MarlinSettings::reset() { // // BLTouch // - TERN_(BLTOUCH_HS_MODE, bltouch.bltouch_high_speed = true); + TERN_(BLTOUCH_HS_MODE, bltouch.high_speed_mode = true); // // Kinematic settings // From 78c57f2847f88adb0b6fa40f8d8fcfbc6e80f5d8 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 12 Oct 2021 22:21:43 -0500 Subject: [PATCH 04/15] Update menu_tramming.cpp --- Marlin/src/lcd/menu/menu_tramming.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index ce9e50b3e7..e0958392bb 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -51,7 +51,6 @@ static int8_t reference_index; // = 0 static bool probe_single_point() { do_blocking_move_to_z(TERN(BLTOUCH, Z_CLEARANCE_DEPLOY_PROBE, Z_CLEARANCE_BETWEEN_PROBES)); // Stow after each point with BLTouch "HIGH SPEED" mode for push-pin safety - const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], bltouch.high_speed_mode ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true); z_measured[tram_index] = z_probed_height; if (reference_index < 0) reference_index = tram_index; From a6c4c5a3f76419b574e948db7606f3c762959df7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Tue, 12 Oct 2021 22:22:15 -0500 Subject: [PATCH 05/15] Update motion.cpp --- Marlin/src/module/motion.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/motion.cpp b/Marlin/src/module/motion.cpp index 824653da1b..029625efea 100644 --- a/Marlin/src/module/motion.cpp +++ b/Marlin/src/module/motion.cpp @@ -1803,7 +1803,7 @@ void prepare_line_to_destination() { if (DEBUGGING(LEVELING)) DEBUG_ECHOLNPGM("Home Fast: ", move_length, "mm"); do_homing_move(axis, move_length, 0.0, !use_probe_bump); - #if ENABLED(HOMING_Z_WITH_PROBE, BLTOUCH) + #if BOTH(HOMING_Z_WITH_PROBE, BLTOUCH) if (axis == Z_AXIS && !bltouch.high_speed_mode) bltouch.stow(); // Intermediate STOW (in LOW SPEED MODE) #endif From 9aaa7b11004d0a1931e2ecc3c204673f4ce29126 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Thu, 14 Oct 2021 13:34:31 -0400 Subject: [PATCH 06/15] Add missing include --- Marlin/src/gcode/calibrate/G34_M422.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Marlin/src/gcode/calibrate/G34_M422.cpp b/Marlin/src/gcode/calibrate/G34_M422.cpp index 11f3eac6fa..328a40dbb4 100644 --- a/Marlin/src/gcode/calibrate/G34_M422.cpp +++ b/Marlin/src/gcode/calibrate/G34_M422.cpp @@ -45,6 +45,10 @@ #include "../../libs/least_squares_fit.h" #endif +#if ENABLED(BLTOUCH) + #include "../../feature/bltouch.h" +#endif + #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #include "../../core/debug_out.h" From 5284f45c625ddfadaa3a9a909184f87111d70cdc Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Thu, 14 Oct 2021 13:41:31 -0400 Subject: [PATCH 07/15] Update menu_tramming.cpp --- Marlin/src/lcd/menu/menu_tramming.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index e0958392bb..4a09e4347c 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -36,6 +36,10 @@ #include "../../module/probe.h" #include "../../gcode/queue.h" +#if ENABLED(BLTOUCH) + #include "../../feature/bltouch.h" +#endif + //#define DEBUG_OUT 1 #include "../../core/debug_out.h" From 102c43dcd5737a950fe0e670039b047e9ae307e1 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Thu, 14 Oct 2021 13:50:56 -0400 Subject: [PATCH 08/15] Update G35.cpp --- Marlin/src/gcode/bedlevel/G35.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index 8ce6abfb95..1013e080bb 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -33,6 +33,11 @@ #include "../../module/tool_change.h" #endif +#if ENABLED(BLTOUCH) + #include "../../feature/bltouch.h" +#endif + + #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #include "../../core/debug_out.h" From 1fab2ef94f231e70fe28470fb169d990321ca8ac Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Thu, 14 Oct 2021 14:01:42 -0400 Subject: [PATCH 09/15] Update menu_tramming.cpp --- Marlin/src/lcd/menu/menu_tramming.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index 4a09e4347c..8573fb9235 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -55,7 +55,7 @@ static int8_t reference_index; // = 0 static bool probe_single_point() { do_blocking_move_to_z(TERN(BLTOUCH, Z_CLEARANCE_DEPLOY_PROBE, Z_CLEARANCE_BETWEEN_PROBES)); // Stow after each point with BLTouch "HIGH SPEED" mode for push-pin safety - const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], bltouch.high_speed_mode ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true); + const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], TERN(BLTOUCH, bltouch.high_speed_mode ? PROBE_PT_STOW : PROBE_PT_RAISE, PROBE_PT_RAISE), 0, true); z_measured[tram_index] = z_probed_height; if (reference_index < 0) reference_index = tram_index; move_to_tramming_wait_pos(); From 385bab2f36cf3606dd0dab2f4deda2206546de07 Mon Sep 17 00:00:00 2001 From: InsanityAutomation Date: Thu, 14 Oct 2021 18:48:59 -0400 Subject: [PATCH 10/15] Update settings.cpp --- Marlin/src/module/settings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 56b071acd2..f33fe3e7dd 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -1744,7 +1744,7 @@ void MarlinSettings::postprocess() { #else bool high_speed_mode; #endif - EEPROM_READ(bltouch_last_written_mode); + EEPROM_READ(high_speed_mode); } // From 3db4452d281958e87a7f3ba65091ff3358e17fe4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 14 Oct 2021 18:56:32 -0500 Subject: [PATCH 11/15] settings tweak --- Marlin/src/gcode/bedlevel/G35.cpp | 1 - Marlin/src/module/settings.cpp | 17 +++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Marlin/src/gcode/bedlevel/G35.cpp b/Marlin/src/gcode/bedlevel/G35.cpp index 1013e080bb..8cabb92382 100644 --- a/Marlin/src/gcode/bedlevel/G35.cpp +++ b/Marlin/src/gcode/bedlevel/G35.cpp @@ -37,7 +37,6 @@ #include "../../feature/bltouch.h" #endif - #define DEBUG_OUT ENABLED(DEBUG_LEVELING_FEATURE) #include "../../core/debug_out.h" diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index f33fe3e7dd..bde8c2f3bd 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -277,7 +277,7 @@ typedef struct SettingsDataStruct { // BLTOUCH // bool bltouch_last_written_mode; - bool high_speed_mode; + bool bltouch_high_speed_mode; // // Kinematic Settings @@ -863,9 +863,9 @@ void MarlinSettings::postprocess() { const bool bltouch_last_written_mode = TERN(BLTOUCH, bltouch.last_written_mode, false); EEPROM_WRITE(bltouch_last_written_mode); - _FIELD_TEST(high_speed_mode); - const bool high_speed_mode = TERN(BLTOUCH, bltouch.high_speed_mode, false); - EEPROM_WRITE(high_speed_mode); + _FIELD_TEST(bltouch_high_speed_mode); + const bool bltouch_high_speed_mode = TERN(BLTOUCH, bltouch.high_speed_mode, false); + EEPROM_WRITE(bltouch_high_speed_mode); } // @@ -1738,13 +1738,13 @@ void MarlinSettings::postprocess() { #endif EEPROM_READ(bltouch_last_written_mode); - _FIELD_TEST(high_speed_mode); + _FIELD_TEST(bltouch_high_speed_mode); #if ENABLED(BLTOUCH) - const bool &high_speed_mode = bltouch.high_speed_mode; + const bool &bltouch_high_speed_mode = bltouch.high_speed_mode; #else - bool high_speed_mode; + bool bltouch_high_speed_mode; #endif - EEPROM_READ(high_speed_mode); + EEPROM_READ(bltouch_high_speed_mode); } // @@ -2745,6 +2745,7 @@ void MarlinSettings::reset() { // BLTouch // TERN_(BLTOUCH_HS_MODE, bltouch.high_speed_mode = true); + // // Kinematic settings // From 099c329238d267b0454f5a5bf95d30e01e11f4c7 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 14 Oct 2021 19:07:30 -0500 Subject: [PATCH 12/15] Fix LEVEL_CORNERS_USE_PROBE --- Marlin/src/lcd/menu/menu_bed_corners.cpp | 23 +++++++++++++---------- Marlin/src/lcd/menu/menu_tramming.cpp | 2 +- Marlin/src/module/settings.cpp | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Marlin/src/lcd/menu/menu_bed_corners.cpp b/Marlin/src/lcd/menu/menu_bed_corners.cpp index 05550ab082..8b0c467b06 100644 --- a/Marlin/src/lcd/menu/menu_bed_corners.cpp +++ b/Marlin/src/lcd/menu/menu_bed_corners.cpp @@ -221,13 +221,13 @@ static void _lcd_level_bed_corners_get_next_position() { bool _lcd_level_bed_corners_probe(bool verify=false) { if (verify) do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); // do clearance if needed - if (!bltouch.high_speed_mode) bltouch.deploy(); // Deploy in LOW SPEED MODE on every probe action + TERN_(BLTOUCH, if (!bltouch.high_speed_mode) bltouch.deploy()); // Deploy in LOW SPEED MODE on every probe action do_blocking_move_to_z(last_z - LEVEL_CORNERS_PROBE_TOLERANCE, MMM_TO_MMS(Z_PROBE_FEEDRATE_SLOW)); // Move down to lower tolerance if (TEST(endstops.trigger_state(), Z_MIN_PROBE)) { // check if probe triggered endstops.hit_on_purpose(); set_current_from_steppers_for_axis(Z_AXIS); sync_plan_position(); - if (!bltouch.high_speed_mode) bltouch.stow(); // Stow in LOW SPEED MODE on every trigger + TERN_(BLTOUCH, if (!bltouch.high_speed_mode) bltouch.stow()); // Stow in LOW SPEED MODE on every trigger // Triggered outside tolerance range? if (ABS(current_position.z - last_z) > LEVEL_CORNERS_PROBE_TOLERANCE) { last_z = current_position.z; // Above tolerance. Set a new Z for subsequent corners. @@ -253,7 +253,7 @@ static void _lcd_level_bed_corners_get_next_position() { } idle(); } - if (!bltouch.high_speed_mode) bltouch.stow(); + TERN_(BLTOUCH, if (!bltouch.high_speed_mode) bltouch.stow()); ui.goto_screen(_lcd_draw_probing); return (probe_triggered); } @@ -267,13 +267,14 @@ static void _lcd_level_bed_corners_get_next_position() { do { ui.refresh(LCDVIEW_REDRAW_NOW); _lcd_draw_probing(); // update screen with # of good points - do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP + (bltouch.high_speed_mode ? 7, 0)); // clearance + + do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP + TERN0(BLTOUCH, bltouch.z_extra_clearance())); // clearance _lcd_level_bed_corners_get_next_position(); // Select next corner coordinates current_position -= probe.offset_xy; // Account for probe offsets do_blocking_move_to_xy(current_position); // Goto corner - if (bltouch.high_speed_mode) bltouch.deploy(); // Deploy in HIGH SPEED MODE + TERN_(BLTOUCH, if (bltouch.high_speed_mode) bltouch.deploy()); // Deploy in HIGH SPEED MODE if (!_lcd_level_bed_corners_probe()) { // Probe down to tolerance if (_lcd_level_bed_corners_raise()) { // Prompt user to raise bed if needed #if ENABLED(LEVEL_CORNERS_VERIFY_RAISED) // Verify @@ -294,11 +295,13 @@ static void _lcd_level_bed_corners_get_next_position() { } while (good_points < nr_edge_points); // loop until all points within tolerance - if (bltouch.high_speed_mode) - // In HIGH SPEED MODE do clearance and stow at the very end - do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); - bltouch.stow(); - } + #if ENABLED(BLTOUCH) + if (bltouch.high_speed_mode) + // In HIGH SPEED MODE do clearance and stow at the very end + do_blocking_move_to_z(current_position.z + LEVEL_CORNERS_Z_HOP); + bltouch.stow(); + } + #endif ui.goto_screen(_lcd_draw_level_prompt); // prompt for bed leveling ui.set_selection(true); diff --git a/Marlin/src/lcd/menu/menu_tramming.cpp b/Marlin/src/lcd/menu/menu_tramming.cpp index 8573fb9235..109ec852f9 100644 --- a/Marlin/src/lcd/menu/menu_tramming.cpp +++ b/Marlin/src/lcd/menu/menu_tramming.cpp @@ -55,7 +55,7 @@ static int8_t reference_index; // = 0 static bool probe_single_point() { do_blocking_move_to_z(TERN(BLTOUCH, Z_CLEARANCE_DEPLOY_PROBE, Z_CLEARANCE_BETWEEN_PROBES)); // Stow after each point with BLTouch "HIGH SPEED" mode for push-pin safety - const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], TERN(BLTOUCH, bltouch.high_speed_mode ? PROBE_PT_STOW : PROBE_PT_RAISE, PROBE_PT_RAISE), 0, true); + const float z_probed_height = probe.probe_at_point(tramming_points[tram_index], TERN0(BLTOUCH, bltouch.high_speed_mode) ? PROBE_PT_STOW : PROBE_PT_RAISE, 0, true); z_measured[tram_index] = z_probed_height; if (reference_index < 0) reference_index = tram_index; move_to_tramming_wait_pos(); diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index bde8c2f3bd..25f404d2ec 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -2744,7 +2744,7 @@ void MarlinSettings::reset() { // // BLTouch // - TERN_(BLTOUCH_HS_MODE, bltouch.high_speed_mode = true); + TERN_(BLTOUCH, bltouch.high_speed_mode = ENABLED(BLTOUCH_HS_MODE)); // // Kinematic settings From bd426d40cd72bad9935a00914b007a0318365646 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 14 Oct 2021 19:10:22 -0500 Subject: [PATCH 13/15] Tweak M401 --- Marlin/src/gcode/probe/M401_M402.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Marlin/src/gcode/probe/M401_M402.cpp b/Marlin/src/gcode/probe/M401_M402.cpp index 390c31b2db..4854f33783 100644 --- a/Marlin/src/gcode/probe/M401_M402.cpp +++ b/Marlin/src/gcode/probe/M401_M402.cpp @@ -33,8 +33,9 @@ /** * M401: Deploy and activate the Z probe - * BLTouch Only : - * S : Set High Speed Mode + * + * With BLTOUCH: + * S Set High Speed (HS) Mode and exit without deploy */ void GcodeSuite::M401() { #if ENABLED(BLTOUCH) From 43f996d68ad59e7cc010b6401d82558ef020a346 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 14 Oct 2021 20:04:42 -0500 Subject: [PATCH 14/15] Rename bltouch_last_written_mode --- Marlin/Configuration_adv.h | 2 +- Marlin/src/feature/bltouch.cpp | 21 +++++++++------------ Marlin/src/feature/bltouch.h | 4 ++-- Marlin/src/lcd/menu/menu_configuration.cpp | 11 +++++++---- Marlin/src/module/settings.cpp | 20 ++++++++++---------- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index 0b01ec0d61..cdb1feda75 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -858,7 +858,7 @@ * This feature was designed for Deltabots with very fast Z moves; however, higher speed Cartesians * might be able to use it. If the machine can't raise Z fast enough the BLTouch may go into ALARM. * - * This sets the default state. Can be changed through the SCD + * This only sets the default state. Changed with 'M401 S' or UI, saved with M500. */ //#define BLTOUCH_HS_MODE diff --git a/Marlin/src/feature/bltouch.cpp b/Marlin/src/feature/bltouch.cpp index 9450ae8ee7..9bb71669c7 100644 --- a/Marlin/src/feature/bltouch.cpp +++ b/Marlin/src/feature/bltouch.cpp @@ -28,8 +28,8 @@ BLTouch bltouch; -bool BLTouch::last_written_mode, // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain - BLTouch::high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed +bool BLTouch::od_5v_mode, // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain + BLTouch::high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed #include "../module/servo.h" #include "../module/probe.h" @@ -65,17 +65,14 @@ void BLTouch::init(const bool set_voltage/*=false*/) { #else if (DEBUGGING(LEVELING)) { - DEBUG_ECHOLNPGM("last_written_mode - ", last_written_mode); - DEBUG_ECHOLNPGM("config mode - " - #if ENABLED(BLTOUCH_SET_5V_MODE) - "BLTOUCH_SET_5V_MODE" - #else - "OD" - #endif - ); + PGMSTR(mode0, "OD"); + PGMSTR(mode1, "5V"); + DEBUG_ECHOPGM("BLTouch Mode: "); + DEBUG_ECHOPGM_P(bltouch.od_5v_mode ? mode1 : mode0); + DEBUG_ECHOLNPGM(" (Default " TERN(BLTOUCH_SET_5V_MODE, "5V", "OD") ")"); } - const bool should_set = last_written_mode != ENABLED(BLTOUCH_SET_5V_MODE); + const bool should_set = od_5v_mode != ENABLED(BLTOUCH_SET_5V_MODE); #endif @@ -194,7 +191,7 @@ void BLTouch::mode_conv_proc(const bool M5V) { _mode_store(); if (M5V) _set_5V_mode(); else _set_OD_mode(); _stow(); - last_written_mode = M5V; + od_5v_mode = M5V; } #endif // BLTOUCH diff --git a/Marlin/src/feature/bltouch.h b/Marlin/src/feature/bltouch.h index f1485826b5..fbb8267296 100644 --- a/Marlin/src/feature/bltouch.h +++ b/Marlin/src/feature/bltouch.h @@ -68,8 +68,8 @@ class BLTouch { public: static void init(const bool set_voltage=false); - static bool last_written_mode, // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain - high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed + static bool od_5v_mode, // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain + high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed const float z_extra_clearance() { return high_speed_mode ? 7 : 0; } diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 6006f86891..4519990a3b 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -217,11 +217,14 @@ void menu_advanced_settings(); #if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU) void bltouch_report() { - SERIAL_ECHOLNPGM("EEPROM Last BLTouch Mode - ", bltouch.last_written_mode); - SERIAL_ECHOLNPGM("Configuration BLTouch Mode - " TERN(BLTOUCH_SET_5V_MODE, "5V", "OD")); + PGMSTR(mode0, "OD"); + PGMSTR(mode1, "5V"); + SERIAL_ECHOPGM("BLTouch Mode: "); + SERIAL_ECHOPGM_P(bltouch.od_5v_mode ? mode1 : mode0); + SERIAL_ECHOLNPGM(" (Default " TERN(BLTOUCH_SET_5V_MODE, "5V", "OD") ")"); char mess[21]; - strcpy_P(mess, PSTR("BLTouch Mode - ")); - strcpy_P(&mess[15], bltouch.last_written_mode ? PSTR("5V") : PSTR("OD")); + strcpy_P(mess, PSTR("BLTouch Mode: ")); + strcpy_P(&mess[15], bltouch.od_5v_mode ? mode1 : mode0); ui.set_status(mess); ui.return_to_status(); } diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 25f404d2ec..337a376ce8 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -276,8 +276,8 @@ typedef struct SettingsDataStruct { // // BLTOUCH // - bool bltouch_last_written_mode; - bool bltouch_high_speed_mode; + bool bltouch_od_5v_mode; + bool bltouch_high_speed_mode; // M401 S // // Kinematic Settings @@ -859,12 +859,12 @@ void MarlinSettings::postprocess() { // BLTOUCH // { - _FIELD_TEST(bltouch_last_written_mode); - const bool bltouch_last_written_mode = TERN(BLTOUCH, bltouch.last_written_mode, false); - EEPROM_WRITE(bltouch_last_written_mode); + _FIELD_TEST(bltouch_od_5v_mode); + const bool bltouch_od_5v_mode = TERN0(BLTOUCH, bltouch.od_5v_mode); + EEPROM_WRITE(bltouch_od_5v_mode); _FIELD_TEST(bltouch_high_speed_mode); - const bool bltouch_high_speed_mode = TERN(BLTOUCH, bltouch.high_speed_mode, false); + const bool bltouch_high_speed_mode = TERN0(BLTOUCH, bltouch.high_speed_mode); EEPROM_WRITE(bltouch_high_speed_mode); } @@ -1730,13 +1730,13 @@ void MarlinSettings::postprocess() { // BLTOUCH // { - _FIELD_TEST(bltouch_last_written_mode); + _FIELD_TEST(bltouch_od_5v_mode); #if ENABLED(BLTOUCH) - const bool &bltouch_last_written_mode = bltouch.last_written_mode; + const bool &bltouch_od_5v_mode = bltouch.od_5v_mode; #else - bool bltouch_last_written_mode; + bool bltouch_od_5v_mode; #endif - EEPROM_READ(bltouch_last_written_mode); + EEPROM_READ(bltouch_od_5v_mode); _FIELD_TEST(bltouch_high_speed_mode); #if ENABLED(BLTOUCH) From cede5b22c9c2d574f374036150b05a7dea177c87 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 14 Oct 2021 20:23:01 -0500 Subject: [PATCH 15/15] Use BLTOUCH_HS_MODE for default + editable --- Marlin/Configuration_adv.h | 6 ++--- Marlin/src/feature/bltouch.cpp | 8 ++++-- Marlin/src/feature/bltouch.h | 11 +++++--- Marlin/src/gcode/probe/M401_M402.cpp | 12 ++++----- Marlin/src/lcd/menu/menu_configuration.cpp | 4 ++- Marlin/src/module/probe.cpp | 8 +++--- Marlin/src/module/settings.cpp | 30 ++++++++++++++-------- 7 files changed, 48 insertions(+), 31 deletions(-) diff --git a/Marlin/Configuration_adv.h b/Marlin/Configuration_adv.h index cdb1feda75..7ab8ac0fe9 100644 --- a/Marlin/Configuration_adv.h +++ b/Marlin/Configuration_adv.h @@ -853,14 +853,14 @@ //#define BLTOUCH_FORCE_MODE_SET /** - * Use "HIGH SPEED" mode for probing. + * Enable "HIGH SPEED" option for probing. * Danger: Disable if your probe sometimes fails. Only suitable for stable well-adjusted systems. * This feature was designed for Deltabots with very fast Z moves; however, higher speed Cartesians * might be able to use it. If the machine can't raise Z fast enough the BLTouch may go into ALARM. * - * This only sets the default state. Changed with 'M401 S' or UI, saved with M500. + * Set the default state here, change with 'M401 S' or UI, use M500 to save, M502 to reset. */ - //#define BLTOUCH_HS_MODE + //#define BLTOUCH_HS_MODE true // Safety: Enable voltage mode settings in the LCD menu. //#define BLTOUCH_LCD_VOLTAGE_MENU diff --git a/Marlin/src/feature/bltouch.cpp b/Marlin/src/feature/bltouch.cpp index 9bb71669c7..d3348e79f0 100644 --- a/Marlin/src/feature/bltouch.cpp +++ b/Marlin/src/feature/bltouch.cpp @@ -28,8 +28,12 @@ BLTouch bltouch; -bool BLTouch::od_5v_mode, // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain - BLTouch::high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed +bool BLTouch::od_5v_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain +#ifdef BLTOUCH_HS_MODE + bool BLTouch::high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed +#else + constexpr bool BLTouch::high_speed_mode; +#endif #include "../module/servo.h" #include "../module/probe.h" diff --git a/Marlin/src/feature/bltouch.h b/Marlin/src/feature/bltouch.h index fbb8267296..ae3ab66300 100644 --- a/Marlin/src/feature/bltouch.h +++ b/Marlin/src/feature/bltouch.h @@ -68,10 +68,15 @@ class BLTouch { public: static void init(const bool set_voltage=false); - static bool od_5v_mode, // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain - high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed + static bool od_5v_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain - const float z_extra_clearance() { return high_speed_mode ? 7 : 0; } + #ifdef BLTOUCH_HS_MODE + static bool high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed + #else + static constexpr bool high_speed_mode = false; + #endif + + static inline float z_extra_clearance() { return high_speed_mode ? 7 : 0; } // DEPLOY and STOW are wrapped for error handling - these are used by homing and by probing static bool deploy() { return deploy_proc(); } diff --git a/Marlin/src/gcode/probe/M401_M402.cpp b/Marlin/src/gcode/probe/M401_M402.cpp index 4854f33783..940cffe984 100644 --- a/Marlin/src/gcode/probe/M401_M402.cpp +++ b/Marlin/src/gcode/probe/M401_M402.cpp @@ -27,22 +27,20 @@ #include "../gcode.h" #include "../../module/motion.h" #include "../../module/probe.h" -#if ENABLED(BLTOUCH) + +#ifdef BLTOUCH_HS_MODE #include "../../feature/bltouch.h" #endif /** * M401: Deploy and activate the Z probe * - * With BLTOUCH: + * With BLTOUCH_HS_MODE: * S Set High Speed (HS) Mode and exit without deploy */ void GcodeSuite::M401() { - #if ENABLED(BLTOUCH) - if (parser.seen('S')) { - bltouch.high_speed_mode = parser.value_bool(); - return; - } + #ifdef BLTOUCH_HS_MODE + if (parser.seen('S')) { bltouch.high_speed_mode = parser.value_bool(); return; } #endif probe.deploy(); TERN_(PROBE_TARE, probe.tare()); diff --git a/Marlin/src/lcd/menu/menu_configuration.cpp b/Marlin/src/lcd/menu/menu_configuration.cpp index 4519990a3b..28de15b12b 100644 --- a/Marlin/src/lcd/menu/menu_configuration.cpp +++ b/Marlin/src/lcd/menu/menu_configuration.cpp @@ -238,7 +238,9 @@ void menu_advanced_settings(); ACTION_ITEM(MSG_BLTOUCH_DEPLOY, bltouch._deploy); ACTION_ITEM(MSG_BLTOUCH_STOW, bltouch._stow); ACTION_ITEM(MSG_BLTOUCH_SW_MODE, bltouch._set_SW_mode); - EDIT_ITEM(bool, MSG_BLTOUCH_SPEED_MODE, &bltouch.high_speed_mode); + #ifdef BLTOUCH_HS_MODE + EDIT_ITEM(bool, MSG_BLTOUCH_SPEED_MODE, &bltouch.high_speed_mode); + #endif #if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU) CONFIRM_ITEM(MSG_BLTOUCH_5V_MODE, MSG_BLTOUCH_5V_MODE, MSG_BUTTON_CANCEL, bltouch._set_5V_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); CONFIRM_ITEM(MSG_BLTOUCH_OD_MODE, MSG_BLTOUCH_OD_MODE, MSG_BUTTON_CANCEL, bltouch._set_OD_mode, nullptr, GET_TEXT(MSG_BLTOUCH_MODE_CHANGE)); diff --git a/Marlin/src/module/probe.cpp b/Marlin/src/module/probe.cpp index 02903419aa..930a99585c 100644 --- a/Marlin/src/module/probe.cpp +++ b/Marlin/src/module/probe.cpp @@ -530,10 +530,12 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) { if (probe.test_sensitivity.z) tmc_disable_stallguard(stepperZ, stealth_states.z); set_homing_current(false); #endif + #if ENABLED(BLTOUCH) - if (!bltouch.high_speed_mode && probe_triggered && bltouch.stow()) + if (probe_triggered && !bltouch.high_speed_mode && bltouch.stow()) return true; // Stow in LOW SPEED MODE on every trigger #endif + // Clear endstop flags endstops.hit_on_purpose(); @@ -762,9 +764,7 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai DEBUG_POS("", current_position); } - #if ENABLED(BLTOUCH) - if (bltouch.triggered() && bltouch.high_speed_mode) bltouch._reset(); - #endif + TERN_(BLTOUCH, if (bltouch.high_speed_mode && bltouch.triggered()) bltouch._reset()); // On delta keep Z below clip height or do_blocking_move_to will abort xyz_pos_t npos = { rx, ry, TERN(DELTA, _MIN(delta_clip_start_height, current_position.z), current_position.z) }; diff --git a/Marlin/src/module/settings.cpp b/Marlin/src/module/settings.cpp index 337a376ce8..d945ba5b4f 100644 --- a/Marlin/src/module/settings.cpp +++ b/Marlin/src/module/settings.cpp @@ -277,7 +277,9 @@ typedef struct SettingsDataStruct { // BLTOUCH // bool bltouch_od_5v_mode; - bool bltouch_high_speed_mode; // M401 S + #ifdef BLTOUCH_HS_MODE + bool bltouch_high_speed_mode; // M401 S + #endif // // Kinematic Settings @@ -863,9 +865,11 @@ void MarlinSettings::postprocess() { const bool bltouch_od_5v_mode = TERN0(BLTOUCH, bltouch.od_5v_mode); EEPROM_WRITE(bltouch_od_5v_mode); - _FIELD_TEST(bltouch_high_speed_mode); - const bool bltouch_high_speed_mode = TERN0(BLTOUCH, bltouch.high_speed_mode); - EEPROM_WRITE(bltouch_high_speed_mode); + #ifdef BLTOUCH_HS_MODE + _FIELD_TEST(bltouch_high_speed_mode); + const bool bltouch_high_speed_mode = TERN0(BLTOUCH, bltouch.high_speed_mode); + EEPROM_WRITE(bltouch_high_speed_mode); + #endif } // @@ -1738,13 +1742,15 @@ void MarlinSettings::postprocess() { #endif EEPROM_READ(bltouch_od_5v_mode); - _FIELD_TEST(bltouch_high_speed_mode); - #if ENABLED(BLTOUCH) - const bool &bltouch_high_speed_mode = bltouch.high_speed_mode; - #else - bool bltouch_high_speed_mode; + #ifdef BLTOUCH_HS_MODE + _FIELD_TEST(bltouch_high_speed_mode); + #if ENABLED(BLTOUCH) + const bool &bltouch_high_speed_mode = bltouch.high_speed_mode; + #else + bool bltouch_high_speed_mode; + #endif + EEPROM_READ(bltouch_high_speed_mode); #endif - EEPROM_READ(bltouch_high_speed_mode); } // @@ -2744,7 +2750,9 @@ void MarlinSettings::reset() { // // BLTouch // - TERN_(BLTOUCH, bltouch.high_speed_mode = ENABLED(BLTOUCH_HS_MODE)); + #ifdef BLTOUCH_HS_MODE + bltouch.high_speed_mode = ENABLED(BLTOUCH_HS_MODE); + #endif // // Kinematic settings