diff --git a/Marlin/Conditionals_post.h b/Marlin/Conditionals_post.h index 91b26ef1db..3f7730753f 100644 --- a/Marlin/Conditionals_post.h +++ b/Marlin/Conditionals_post.h @@ -118,9 +118,13 @@ * The BLTouch Probe emulates a servo probe */ #if ENABLED(BLTOUCH) - #undef Z_ENDSTOP_SERVO_NR + #ifndef Z_ENDSTOP_SERVO_NR + #define Z_ENDSTOP_SERVO_NR 0 + #endif + #ifndef NUM_SERVOS + #define NUM_SERVOS (Z_ENDSTOP_SERVO_NR + 1) + #endif #undef Z_SERVO_ANGLES - #define Z_ENDSTOP_SERVO_NR 0 #define Z_SERVO_ANGLES {10,90} // For BLTouch 10=deploy, 90=retract #undef DEACTIVATE_SERVOS_AFTER_MOVE #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN) diff --git a/Marlin/Configuration.h b/Marlin/Configuration.h index 7a938ea4e7..87b4d58a5d 100644 --- a/Marlin/Configuration.h +++ b/Marlin/Configuration.h @@ -528,6 +528,7 @@ //#define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/Marlin_main.cpp b/Marlin/Marlin_main.cpp index 0a4e9b8fbf..1f86f88dcc 100644 --- a/Marlin/Marlin_main.cpp +++ b/Marlin/Marlin_main.cpp @@ -1881,6 +1881,11 @@ static void clean_up_after_endstop_or_probe_move() { // Make room for probe do_probe_raise(_Z_PROBE_DEPLOY_HEIGHT); + // Check BLTOUCH probe status for an error + #if ENABLED(BLTOUCH) + if (servo[Z_ENDSTOP_SERVO_NR].read() == BLTouchState_Error) { stop(); return true; } + #endif + #if ENABLED(Z_PROBE_SLED) if (axis_unhomed_error(true, false, false)) { stop(); return true; } #elif ENABLED(Z_PROBE_ALLEN_KEY) diff --git a/Marlin/SanityCheck.h b/Marlin/SanityCheck.h index 41e5f063b1..6ed5bfe21e 100644 --- a/Marlin/SanityCheck.h +++ b/Marlin/SanityCheck.h @@ -306,12 +306,8 @@ /** * Limited number of servos */ -#if defined(NUM_SERVOS) && NUM_SERVOS > 0 - #if NUM_SERVOS > 4 - #error "The maximum number of SERVOS in Marlin is 4." - #elif HAS_Z_SERVO_ENDSTOP && Z_ENDSTOP_SERVO_NR >= NUM_SERVOS - #error "Z_ENDSTOP_SERVO_NR must be smaller than NUM_SERVOS." - #endif +#if NUM_SERVOS > 4 + #error "The maximum number of SERVOS in Marlin is 4." #endif /** @@ -367,7 +363,7 @@ #ifndef NUM_SERVOS #error "You must set NUM_SERVOS for a Z servo probe (Z_ENDSTOP_SERVO_NR)." #elif Z_ENDSTOP_SERVO_NR >= NUM_SERVOS - #error "Z_ENDSTOP_SERVO_NR must be less than NUM_SERVOS." + #error "Z_ENDSTOP_SERVO_NR must be smaller than NUM_SERVOS." #endif #endif @@ -404,7 +400,7 @@ #if (ENABLED(FIX_MOUNTED_PROBE) && (ENABLED(Z_PROBE_ALLEN_KEY) || HAS_Z_SERVO_ENDSTOP || ENABLED(Z_PROBE_SLED))) \ || (ENABLED(Z_PROBE_ALLEN_KEY) && (HAS_Z_SERVO_ENDSTOP || ENABLED(Z_PROBE_SLED))) \ || (HAS_Z_SERVO_ENDSTOP && ENABLED(Z_PROBE_SLED)) - #error "Please define only one type of probe: Z Servo, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, or FIX_MOUNTED_PROBE." + #error "Please define only one type of probe: Z Servo/BLTOUCH, Z_PROBE_ALLEN_KEY, Z_PROBE_SLED, or FIX_MOUNTED_PROBE." #endif /** diff --git a/Marlin/enum.h b/Marlin/enum.h index 18db5a6f5f..34e02234a8 100644 --- a/Marlin/enum.h +++ b/Marlin/enum.h @@ -124,6 +124,15 @@ enum TempState { }; #endif +#if ENABLED(BLTOUCH) + enum BLTouchState { + BLTouchState_Deploy = 10, + BLTouchState_Stow = 90, + BLTouchState_Selftest = 120, + BLTouchState_Error = 160 + }; +#endif + #if ENABLED(FILAMENT_CHANGE_FEATURE) enum FilamentChangeMenuResponse { FILAMENT_CHANGE_RESPONSE_WAIT_FOR, diff --git a/Marlin/example_configurations/Cartesio/Configuration.h b/Marlin/example_configurations/Cartesio/Configuration.h index 9d0f8ae9e9..452ec3276d 100644 --- a/Marlin/example_configurations/Cartesio/Configuration.h +++ b/Marlin/example_configurations/Cartesio/Configuration.h @@ -511,6 +511,7 @@ //#define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/example_configurations/Felix/Configuration.h b/Marlin/example_configurations/Felix/Configuration.h index f5f8ae289d..8ae7eff30e 100644 --- a/Marlin/example_configurations/Felix/Configuration.h +++ b/Marlin/example_configurations/Felix/Configuration.h @@ -494,6 +494,7 @@ //#define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/example_configurations/Felix/DUAL/Configuration.h b/Marlin/example_configurations/Felix/DUAL/Configuration.h index 3e680f668f..44581c6f19 100644 --- a/Marlin/example_configurations/Felix/DUAL/Configuration.h +++ b/Marlin/example_configurations/Felix/DUAL/Configuration.h @@ -492,6 +492,7 @@ //#define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/example_configurations/Hephestos/Configuration.h b/Marlin/example_configurations/Hephestos/Configuration.h index 8e1c8ca820..c642467b53 100644 --- a/Marlin/example_configurations/Hephestos/Configuration.h +++ b/Marlin/example_configurations/Hephestos/Configuration.h @@ -503,6 +503,7 @@ //#define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/example_configurations/Hephestos_2/Configuration.h b/Marlin/example_configurations/Hephestos_2/Configuration.h index 2ec53a4207..a7094c0f3a 100644 --- a/Marlin/example_configurations/Hephestos_2/Configuration.h +++ b/Marlin/example_configurations/Hephestos_2/Configuration.h @@ -505,6 +505,7 @@ #define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/example_configurations/K8200/Configuration.h b/Marlin/example_configurations/K8200/Configuration.h index 206540d3fb..efc72e13f9 100644 --- a/Marlin/example_configurations/K8200/Configuration.h +++ b/Marlin/example_configurations/K8200/Configuration.h @@ -528,6 +528,7 @@ //#define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/example_configurations/K8400/Configuration.h b/Marlin/example_configurations/K8400/Configuration.h index d718d1a16a..ad21151afe 100644 --- a/Marlin/example_configurations/K8400/Configuration.h +++ b/Marlin/example_configurations/K8400/Configuration.h @@ -511,6 +511,7 @@ //#define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/example_configurations/K8400/Dual-head/Configuration.h b/Marlin/example_configurations/K8400/Dual-head/Configuration.h index 3bad2fd375..fddbb12c52 100644 --- a/Marlin/example_configurations/K8400/Dual-head/Configuration.h +++ b/Marlin/example_configurations/K8400/Dual-head/Configuration.h @@ -511,6 +511,7 @@ //#define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h index db8119e716..794ec71dd7 100644 --- a/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h +++ b/Marlin/example_configurations/RepRapWorld/Megatronics/Configuration.h @@ -511,6 +511,7 @@ //#define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/example_configurations/RigidBot/Configuration.h b/Marlin/example_configurations/RigidBot/Configuration.h index 25d918cd2b..c2d8ed6b7c 100644 --- a/Marlin/example_configurations/RigidBot/Configuration.h +++ b/Marlin/example_configurations/RigidBot/Configuration.h @@ -509,6 +509,7 @@ //#define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/example_configurations/SCARA/Configuration.h b/Marlin/example_configurations/SCARA/Configuration.h index 808490fc12..5ca4706622 100644 --- a/Marlin/example_configurations/SCARA/Configuration.h +++ b/Marlin/example_configurations/SCARA/Configuration.h @@ -521,6 +521,7 @@ //#define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/example_configurations/TAZ4/Configuration.h b/Marlin/example_configurations/TAZ4/Configuration.h index 0d9185b40c..54a4ace02c 100644 --- a/Marlin/example_configurations/TAZ4/Configuration.h +++ b/Marlin/example_configurations/TAZ4/Configuration.h @@ -532,6 +532,7 @@ //#define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/example_configurations/WITBOX/Configuration.h b/Marlin/example_configurations/WITBOX/Configuration.h index 28d374b371..8b10193dce 100644 --- a/Marlin/example_configurations/WITBOX/Configuration.h +++ b/Marlin/example_configurations/WITBOX/Configuration.h @@ -503,6 +503,7 @@ //#define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/example_configurations/adafruit/ST7565/Configuration.h b/Marlin/example_configurations/adafruit/ST7565/Configuration.h index c2ec1bf803..056e603ae9 100644 --- a/Marlin/example_configurations/adafruit/ST7565/Configuration.h +++ b/Marlin/example_configurations/adafruit/ST7565/Configuration.h @@ -511,6 +511,7 @@ //#define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/example_configurations/delta/biv2.5/Configuration.h b/Marlin/example_configurations/delta/biv2.5/Configuration.h index 4596253c9e..f196ba96d9 100644 --- a/Marlin/example_configurations/delta/biv2.5/Configuration.h +++ b/Marlin/example_configurations/delta/biv2.5/Configuration.h @@ -554,6 +554,7 @@ //#define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/example_configurations/delta/generic/Configuration.h b/Marlin/example_configurations/delta/generic/Configuration.h index c66410c2e3..06ad8e129f 100644 --- a/Marlin/example_configurations/delta/generic/Configuration.h +++ b/Marlin/example_configurations/delta/generic/Configuration.h @@ -554,6 +554,7 @@ //#define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/example_configurations/delta/kossel_mini/Configuration.h b/Marlin/example_configurations/delta/kossel_mini/Configuration.h index 4159567c75..83d70a54ca 100644 --- a/Marlin/example_configurations/delta/kossel_mini/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_mini/Configuration.h @@ -554,6 +554,7 @@ //#define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/example_configurations/delta/kossel_pro/Configuration.h b/Marlin/example_configurations/delta/kossel_pro/Configuration.h index f5ff185114..ef820d42bd 100644 --- a/Marlin/example_configurations/delta/kossel_pro/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_pro/Configuration.h @@ -550,6 +550,7 @@ //#define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/example_configurations/delta/kossel_xl/Configuration.h b/Marlin/example_configurations/delta/kossel_xl/Configuration.h index f644a04759..4b25bf171b 100644 --- a/Marlin/example_configurations/delta/kossel_xl/Configuration.h +++ b/Marlin/example_configurations/delta/kossel_xl/Configuration.h @@ -560,6 +560,7 @@ #define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/example_configurations/makibox/Configuration.h b/Marlin/example_configurations/makibox/Configuration.h index 6cfb9d5c38..d194a1d337 100644 --- a/Marlin/example_configurations/makibox/Configuration.h +++ b/Marlin/example_configurations/makibox/Configuration.h @@ -514,6 +514,7 @@ //#define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/example_configurations/tvrrug/Round2/Configuration.h b/Marlin/example_configurations/tvrrug/Round2/Configuration.h index b7d939c20b..9168a026a3 100644 --- a/Marlin/example_configurations/tvrrug/Round2/Configuration.h +++ b/Marlin/example_configurations/tvrrug/Round2/Configuration.h @@ -507,6 +507,7 @@ //#define FIX_MOUNTED_PROBE // The BLTouch probe emulates a servo probe. +// The default connector is SERVO 0. Set Z_ENDSTOP_SERVO_NR below to override. //#define BLTOUCH // Z Servo Probe, such as an endstop switch on a rotating arm. diff --git a/Marlin/language_en.h b/Marlin/language_en.h index b1b8e0af75..a84d1acfdb 100644 --- a/Marlin/language_en.h +++ b/Marlin/language_en.h @@ -366,6 +366,9 @@ #ifndef MSG_ZPROBE_OUT #define MSG_ZPROBE_OUT "Z probe out. bed" #endif +#ifndef MSG_RESET_BLTOUCH + #define MSG_RESET_BLTOUCH "Reset BLTouch" +#endif #ifndef MSG_HOME #define MSG_HOME "Home" // Used as MSG_HOME " " MSG_X MSG_Y MSG_Z " " MSG_FIRST #endif diff --git a/Marlin/ultralcd.cpp b/Marlin/ultralcd.cpp index a1deff0326..5240c30fab 100755 --- a/Marlin/ultralcd.cpp +++ b/Marlin/ultralcd.cpp @@ -30,6 +30,11 @@ #include "configuration_store.h" #include "utility.h" +#if ENABLED(BLTOUCH) + #include "servo.h" + extern Servo servo[NUM_SERVOS]; +#endif + #if ENABLED(PRINTCOUNTER) #include "printcounter.h" #include "duration_t.h" @@ -586,6 +591,12 @@ void kill_screen(const char* lcd_msg) { static void lcd_main_menu() { START_MENU(); MENU_ITEM(back, MSG_WATCH); + + #if ENABLED(BLTOUCH) + if (servo[Z_ENDSTOP_SERVO_NR].read() == BLTouchState_Error) + MENU_ITEM(gcode, MSG_RESET_BLTOUCH, "M280 S90 P" STRINGIFY(Z_ENDSTOP_SERVO_NR)); + #endif + if (planner.movesplanned() || IS_SD_PRINTING) { MENU_ITEM(submenu, MSG_TUNE, lcd_tune_menu); }