Skip to content

Commit

Permalink
🐛 Fix BLTOUCH_HS_MODE config
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Apr 12, 2023
1 parent 7369a6a commit f5c7b19
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,7 @@
*/
//#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.
// This must be large enough to keep the probe pin off the bed and prevent
// it from snagging on the bed clips.
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/feature/bltouch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
BLTouch bltouch;

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
#else
constexpr bool BLTouch::high_speed_mode;
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/feature/bltouch.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,13 @@ class BLTouch {
static void init(const bool set_voltage=false);
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
#else
static constexpr bool high_speed_mode = false;
#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
static bool deploy() { return deploy_proc(); }
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/gcode/probe/M401_M402.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include "../../module/motion.h"
#include "../../module/probe.h"

#ifdef BLTOUCH_HS_MODE
#if HAS_BLTOUCH_HS_MODE
#include "../../feature/bltouch.h"
#endif

Expand All @@ -42,7 +42,7 @@
* R<bool> Remain in place after deploying (and before activating) the probe
*/
void GcodeSuite::M401() {
#ifdef BLTOUCH_HS_MODE
#if HAS_BLTOUCH_HS_MODE
const bool seenH = parser.seen_test('H'),
seenS = parser.seen('S');
if (seenH || seenS) {
Expand Down
11 changes: 8 additions & 3 deletions Marlin/src/inc/Conditionals_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,14 @@
#endif // !defined(NUM_SERVOS)

// Convenience override for a BLTouch alone
#if ENABLED(BLTOUCH) && NUM_SERVOS == 1
#undef SERVO_DELAY
#define SERVO_DELAY { 50 }
#if ENABLED(BLTOUCH)
#ifdef BLTOUCH_HS_MODE
#define HAS_BLTOUCH_HS_MODE 1
#endif
#if NUM_SERVOS == 1
#undef SERVO_DELAY
#define SERVO_DELAY { 50 }
#endif
#endif

#if !HAS_BED_PROBE
Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -1895,10 +1895,10 @@ static_assert(X_MAX_LENGTH >= X_BED_SIZE, "Movement bounds (X_MIN_POS, X_MAX_POS
#endif
#endif

#if ENABLED(BLTOUCH_HS_MODE)
#if BLTOUCH_HS_MODE == 0
#error "BLTOUCH_HS_MODE must now be defined as true or false, indicating the default state."
#endif
#if HAS_BLTOUCH_HS_MODE
constexpr char hs[] = STRINGIFY(BLTOUCH_HS_MODE);
static_assert(!(strcmp(hs, "1") && strcmp(hs, "true") && strcmp(hs, "0") && strcmp(hs, "false")), \
"BLTOUCH_HS_MODE must now be defined as true or false, indicating the default state.");
#ifdef BLTOUCH_HS_EXTRA_CLEARANCE
static_assert(BLTOUCH_HS_EXTRA_CLEARANCE > 0, "BLTOUCH_HS_MODE requires a positive BLTOUCH_HS_EXTRA_CLEARANCE.");
#endif
Expand Down
8 changes: 3 additions & 5 deletions Marlin/src/lcd/e3v2/proui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2211,10 +2211,8 @@ void SetMoveZ() { HMI_value.axis = Z_AXIS; SetPFloatOnClick(Z_MIN_POS, Z_MAX_POS
void ProbeStow() { probe.stow(); }
void ProbeDeploy() { probe.deploy(); }

#if ENABLED(BLTOUCH_HS_MODE)
void SetHSMode() {
Toggle_Chkb_Line(bltouch.high_speed_mode);
}
#if HAS_BLTOUCH_HS_MODE
void SetHSMode() { Toggle_Chkb_Line(bltouch.high_speed_mode); }
#endif

#endif
Expand Down Expand Up @@ -3184,7 +3182,7 @@ void Draw_Move_Menu() {
MENU_ITEM(ICON_ProbeStow, MSG_MANUAL_STOW, onDrawMenuItem, ProbeStow);
MENU_ITEM(ICON_ProbeDeploy, MSG_MANUAL_DEPLOY, onDrawMenuItem, ProbeDeploy);
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);
#endif
#endif
Expand Down
2 changes: 1 addition & 1 deletion Marlin/src/lcd/menu/menu_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,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);
#ifdef BLTOUCH_HS_MODE
#if HAS_BLTOUCH_HS_MODE
EDIT_ITEM(bool, MSG_BLTOUCH_SPEED_MODE, &bltouch.high_speed_mode);
#endif
#if ENABLED(BLTOUCH_LCD_VOLTAGE_MENU)
Expand Down
10 changes: 4 additions & 6 deletions Marlin/src/module/settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ typedef struct SettingsDataStruct {
// BLTOUCH
//
bool bltouch_od_5v_mode;
#ifdef BLTOUCH_HS_MODE
#if HAS_BLTOUCH_HS_MODE
bool bltouch_high_speed_mode; // M401 S
#endif

Expand Down Expand Up @@ -1016,7 +1016,7 @@ void MarlinSettings::postprocess() {
const bool bltouch_od_5v_mode = TERN0(BLTOUCH, 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);
const bool bltouch_high_speed_mode = TERN0(BLTOUCH, bltouch.high_speed_mode);
EEPROM_WRITE(bltouch_high_speed_mode);
Expand Down Expand Up @@ -1976,7 +1976,7 @@ void MarlinSettings::postprocess() {
#endif
EEPROM_READ(bltouch_od_5v_mode);

#ifdef BLTOUCH_HS_MODE
#if HAS_BLTOUCH_HS_MODE
_FIELD_TEST(bltouch_high_speed_mode);
#if ENABLED(BLTOUCH)
const bool &bltouch_high_speed_mode = bltouch.high_speed_mode;
Expand Down Expand Up @@ -3075,9 +3075,7 @@ void MarlinSettings::reset() {
//
// BLTouch
//
#ifdef BLTOUCH_HS_MODE
bltouch.high_speed_mode = ENABLED(BLTOUCH_HS_MODE);
#endif
TERN_(HAS_BLTOUCH_HS_MODE, bltouch.high_speed_mode = BLTOUCH_HS_MODE);

//
// Kinematic Settings (Delta, SCARA, TPARA, Polargraph...)
Expand Down

0 comments on commit f5c7b19

Please sign in to comment.