🐛 Fix BLTOUCH_HS_MODE config

This commit is contained in:
Scott Lahteine
2023-04-11 23:22:36 -05:00
parent 7369a6a37b
commit f5c7b190f6
9 changed files with 26 additions and 25 deletions

View File

@@ -987,7 +987,7 @@
*/ */
//#define BLTOUCH_HS_MODE true //#define BLTOUCH_HS_MODE true
#if ENABLED(BLTOUCH_HS_MODE) #ifdef BLTOUCH_HS_MODE
// The probe Z offset (M851 Z) is the height at which the probe triggers. // The probe Z offset (M851 Z) is the height at which the probe triggers.
// This must be large enough to keep the probe pin off the bed and prevent // This must be large enough to keep the probe pin off the bed and prevent
// it from snagging on the bed clips. // it from snagging on the bed clips.

View File

@@ -29,7 +29,7 @@
BLTouch bltouch; BLTouch bltouch;
bool BLTouch::od_5v_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain bool BLTouch::od_5v_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain
#ifdef BLTOUCH_HS_MODE #if HAS_BLTOUCH_HS_MODE
bool BLTouch::high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed bool BLTouch::high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed
#else #else
constexpr bool BLTouch::high_speed_mode; constexpr bool BLTouch::high_speed_mode;

View File

@@ -70,13 +70,13 @@ public:
static void init(const bool set_voltage=false); static void init(const bool set_voltage=false);
static bool od_5v_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain static bool od_5v_mode; // Initialized by settings.load, 0 = Open Drain; 1 = 5V Drain
#ifdef BLTOUCH_HS_MODE #if HAS_BLTOUCH_HS_MODE
static bool high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed static bool high_speed_mode; // Initialized by settings.load, 0 = Low Speed; 1 = High Speed
#else #else
static constexpr bool high_speed_mode = false; static constexpr bool high_speed_mode = false;
#endif #endif
static float z_extra_clearance() { return high_speed_mode ? TERN0(BLTOUCH_HS_MODE, BLTOUCH_HS_EXTRA_CLEARANCE) : 0; } static float z_extra_clearance() { return TERN0(HAS_BLTOUCH_HS_MODE, high_speed_mode ? BLTOUCH_HS_EXTRA_CLEARANCE : 0); }
// DEPLOY and STOW are wrapped for error handling - these are used by homing and by probing // DEPLOY and STOW are wrapped for error handling - these are used by homing and by probing
static bool deploy() { return deploy_proc(); } static bool deploy() { return deploy_proc(); }

View File

@@ -28,7 +28,7 @@
#include "../../module/motion.h" #include "../../module/motion.h"
#include "../../module/probe.h" #include "../../module/probe.h"
#ifdef BLTOUCH_HS_MODE #if HAS_BLTOUCH_HS_MODE
#include "../../feature/bltouch.h" #include "../../feature/bltouch.h"
#endif #endif
@@ -42,7 +42,7 @@
* R<bool> Remain in place after deploying (and before activating) the probe * R<bool> Remain in place after deploying (and before activating) the probe
*/ */
void GcodeSuite::M401() { void GcodeSuite::M401() {
#ifdef BLTOUCH_HS_MODE #if HAS_BLTOUCH_HS_MODE
const bool seenH = parser.seen_test('H'), const bool seenH = parser.seen_test('H'),
seenS = parser.seen('S'); seenS = parser.seen('S');
if (seenH || seenS) { if (seenH || seenS) {

View File

@@ -76,10 +76,15 @@
#endif // !defined(NUM_SERVOS) #endif // !defined(NUM_SERVOS)
// Convenience override for a BLTouch alone // Convenience override for a BLTouch alone
#if ENABLED(BLTOUCH) && NUM_SERVOS == 1 #if ENABLED(BLTOUCH)
#ifdef BLTOUCH_HS_MODE
#define HAS_BLTOUCH_HS_MODE 1
#endif
#if NUM_SERVOS == 1
#undef SERVO_DELAY #undef SERVO_DELAY
#define SERVO_DELAY { 50 } #define SERVO_DELAY { 50 }
#endif #endif
#endif
#if !HAS_BED_PROBE #if !HAS_BED_PROBE
#undef BABYSTEP_ZPROBE_OFFSET #undef BABYSTEP_ZPROBE_OFFSET

View File

@@ -1895,10 +1895,10 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS
#endif #endif
#endif #endif
#if ENABLED(BLTOUCH_HS_MODE) #if HAS_BLTOUCH_HS_MODE
#if BLTOUCH_HS_MODE == 0 constexpr char hs[] = STRINGIFY(BLTOUCH_HS_MODE);
#error "BLTOUCH_HS_MODE must now be defined as true or false, indicating the default state." static_assert(!(strcmp(hs, "1") && strcmp(hs, "true") && strcmp(hs, "0") && strcmp(hs, "false")), \
#endif "BLTOUCH_HS_MODE must now be defined as true or false, indicating the default state.");
#ifdef BLTOUCH_HS_EXTRA_CLEARANCE #ifdef BLTOUCH_HS_EXTRA_CLEARANCE
static_assert(BLTOUCH_HS_EXTRA_CLEARANCE > 0, "BLTOUCH_HS_MODE requires a positive BLTOUCH_HS_EXTRA_CLEARANCE."); static_assert(BLTOUCH_HS_EXTRA_CLEARANCE > 0, "BLTOUCH_HS_MODE requires a positive BLTOUCH_HS_EXTRA_CLEARANCE.");
#endif #endif

View File

@@ -2211,10 +2211,8 @@ void SetMoveZ() { HMI_value.axis = Z_AXIS; SetPFloatOnClick(Z_MIN_POS, Z_MAX_POS
void ProbeStow() { probe.stow(); } void ProbeStow() { probe.stow(); }
void ProbeDeploy() { probe.deploy(); } void ProbeDeploy() { probe.deploy(); }
#if ENABLED(BLTOUCH_HS_MODE) #if HAS_BLTOUCH_HS_MODE
void SetHSMode() { void SetHSMode() { Toggle_Chkb_Line(bltouch.high_speed_mode); }
Toggle_Chkb_Line(bltouch.high_speed_mode);
}
#endif #endif
#endif #endif
@@ -3184,7 +3182,7 @@ void Draw_Move_Menu() {
MENU_ITEM(ICON_ProbeStow, MSG_MANUAL_STOW, onDrawMenuItem, ProbeStow); MENU_ITEM(ICON_ProbeStow, MSG_MANUAL_STOW, onDrawMenuItem, ProbeStow);
MENU_ITEM(ICON_ProbeDeploy, MSG_MANUAL_DEPLOY, onDrawMenuItem, ProbeDeploy); MENU_ITEM(ICON_ProbeDeploy, MSG_MANUAL_DEPLOY, onDrawMenuItem, ProbeDeploy);
MENU_ITEM(ICON_BltouchReset, MSG_BLTOUCH_RESET, onDrawMenuItem, bltouch._reset); MENU_ITEM(ICON_BltouchReset, MSG_BLTOUCH_RESET, onDrawMenuItem, bltouch._reset);
#if ENABLED(BLTOUCH_HS_MODE) #if HAS_BLTOUCH_HS_MODE
EDIT_ITEM(ICON_HSMode, MSG_ENABLE_HS_MODE, onDrawChkbMenu, SetHSMode, &bltouch.high_speed_mode); EDIT_ITEM(ICON_HSMode, MSG_ENABLE_HS_MODE, onDrawChkbMenu, SetHSMode, &bltouch.high_speed_mode);
#endif #endif
#endif #endif

View File

@@ -243,7 +243,7 @@ void menu_advanced_settings();
ACTION_ITEM(MSG_BLTOUCH_DEPLOY, bltouch._deploy); ACTION_ITEM(MSG_BLTOUCH_DEPLOY, bltouch._deploy);
ACTION_ITEM(MSG_BLTOUCH_STOW, bltouch._stow); ACTION_ITEM(MSG_BLTOUCH_STOW, bltouch._stow);
ACTION_ITEM(MSG_BLTOUCH_SW_MODE, bltouch._set_SW_mode); ACTION_ITEM(MSG_BLTOUCH_SW_MODE, bltouch._set_SW_mode);
#ifdef BLTOUCH_HS_MODE #if HAS_BLTOUCH_HS_MODE
EDIT_ITEM(bool, MSG_BLTOUCH_SPEED_MODE, &bltouch.high_speed_mode); EDIT_ITEM(bool, MSG_BLTOUCH_SPEED_MODE, &bltouch.high_speed_mode);
#endif #endif
#if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU) #if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU)

View File

@@ -322,7 +322,7 @@ typedef struct SettingsDataStruct {
// BLTOUCH // BLTOUCH
// //
bool bltouch_od_5v_mode; bool bltouch_od_5v_mode;
#ifdef BLTOUCH_HS_MODE #if HAS_BLTOUCH_HS_MODE
bool bltouch_high_speed_mode; // M401 S bool bltouch_high_speed_mode; // M401 S
#endif #endif
@@ -1016,7 +1016,7 @@ void MarlinSettings::postprocess() {
const bool bltouch_od_5v_mode = TERN0(BLTOUCH, bltouch.od_5v_mode); const bool bltouch_od_5v_mode = TERN0(BLTOUCH, bltouch.od_5v_mode);
EEPROM_WRITE(bltouch_od_5v_mode); EEPROM_WRITE(bltouch_od_5v_mode);
#ifdef BLTOUCH_HS_MODE #if HAS_BLTOUCH_HS_MODE
_FIELD_TEST(bltouch_high_speed_mode); _FIELD_TEST(bltouch_high_speed_mode);
const bool bltouch_high_speed_mode = TERN0(BLTOUCH, bltouch.high_speed_mode); const bool bltouch_high_speed_mode = TERN0(BLTOUCH, bltouch.high_speed_mode);
EEPROM_WRITE(bltouch_high_speed_mode); EEPROM_WRITE(bltouch_high_speed_mode);
@@ -1976,7 +1976,7 @@ void MarlinSettings::postprocess() {
#endif #endif
EEPROM_READ(bltouch_od_5v_mode); EEPROM_READ(bltouch_od_5v_mode);
#ifdef BLTOUCH_HS_MODE #if HAS_BLTOUCH_HS_MODE
_FIELD_TEST(bltouch_high_speed_mode); _FIELD_TEST(bltouch_high_speed_mode);
#if ENABLED(BLTOUCH) #if ENABLED(BLTOUCH)
const bool &bltouch_high_speed_mode = bltouch.high_speed_mode; const bool &bltouch_high_speed_mode = bltouch.high_speed_mode;
@@ -3075,9 +3075,7 @@ void MarlinSettings::reset() {
// //
// BLTouch // BLTouch
// //
#ifdef BLTOUCH_HS_MODE TERN_(HAS_BLTOUCH_HS_MODE, bltouch.high_speed_mode = BLTOUCH_HS_MODE);
bltouch.high_speed_mode = ENABLED(BLTOUCH_HS_MODE);
#endif
// //
// Kinematic Settings (Delta, SCARA, TPARA, Polargraph...) // Kinematic Settings (Delta, SCARA, TPARA, Polargraph...)