✨ Bed Distance Sensor (#24554)
This commit is contained in:
@ -63,6 +63,13 @@ bool Endstops::enabled, Endstops::enabled_globally; // Initialized by settings.l
|
||||
volatile Endstops::endstop_mask_t Endstops::hit_state;
|
||||
Endstops::endstop_mask_t Endstops::live_state = 0;
|
||||
|
||||
#if ENABLED(BD_SENSOR)
|
||||
bool Endstops::bdp_state; // = false
|
||||
#define READ_ENDSTOP(P) ((P == Z_MIN_PIN) ? bdp_state : READ(P))
|
||||
#else
|
||||
#define READ_ENDSTOP(P) READ(P)
|
||||
#endif
|
||||
|
||||
#if ENDSTOP_NOISE_THRESHOLD
|
||||
Endstops::endstop_mask_t Endstops::validated_live_state;
|
||||
uint8_t Endstops::endstop_poll_count;
|
||||
@ -566,7 +573,7 @@ static void print_es_state(const bool is_hit, FSTR_P const flabel=nullptr) {
|
||||
void __O2 Endstops::report_states() {
|
||||
TERN_(BLTOUCH, bltouch._set_SW_mode());
|
||||
SERIAL_ECHOLNPGM(STR_M119_REPORT);
|
||||
#define ES_REPORT(S) print_es_state(READ(S##_PIN) != S##_ENDSTOP_INVERTING, F(STR_##S))
|
||||
#define ES_REPORT(S) print_es_state(READ_ENDSTOP(S##_PIN) != S##_ENDSTOP_INVERTING, F(STR_##S))
|
||||
#if HAS_X_MIN
|
||||
ES_REPORT(X_MIN);
|
||||
#endif
|
||||
@ -703,7 +710,7 @@ void Endstops::update() {
|
||||
#endif
|
||||
|
||||
// Macros to update / copy the live_state
|
||||
#define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT_TO(live_state, _ENDSTOP(AXIS, MINMAX), (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)))
|
||||
#define UPDATE_ENDSTOP_BIT(AXIS, MINMAX) SET_BIT_TO(live_state, _ENDSTOP(AXIS, MINMAX), (READ_ENDSTOP(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)))
|
||||
#define COPY_LIVE_STATE(SRC_BIT, DST_BIT) SET_BIT_TO(live_state, DST_BIT, TEST(live_state, SRC_BIT))
|
||||
|
||||
#if ENABLED(G38_PROBE_TARGET) && NONE(CORE_IS_XY, CORE_IS_XZ, MARKFORGED_XY, MARKFORGED_YX)
|
||||
@ -1434,7 +1441,7 @@ void Endstops::update() {
|
||||
static uint8_t local_LED_status = 0;
|
||||
uint16_t live_state_local = 0;
|
||||
|
||||
#define ES_GET_STATE(S) if (READ(S##_PIN)) SBI(live_state_local, S)
|
||||
#define ES_GET_STATE(S) if (READ_ENDSTOP(S##_PIN)) SBI(live_state_local, S)
|
||||
|
||||
#if HAS_X_MIN
|
||||
ES_GET_STATE(X_MIN);
|
||||
|
@ -166,6 +166,11 @@ class Endstops {
|
||||
*/
|
||||
static void update();
|
||||
|
||||
#if ENABLED(BD_SENSOR)
|
||||
static bool bdp_state;
|
||||
static void bdp_state_update(const bool z_state) { bdp_state = z_state; }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Get Endstop hit state.
|
||||
*/
|
||||
|
@ -44,6 +44,10 @@
|
||||
#include "../feature/bedlevel/bedlevel.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(BD_SENSOR)
|
||||
#include "../feature/bedlevel/bdl/bdl.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(DELTA)
|
||||
#include "delta.h"
|
||||
#endif
|
||||
@ -878,6 +882,8 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai
|
||||
// Move the probe to the starting XYZ
|
||||
do_blocking_move_to(npos, feedRate_t(XY_PROBE_FEEDRATE_MM_S));
|
||||
|
||||
TERN_(BD_SENSOR, return bdl.read());
|
||||
|
||||
float measured_z = NAN;
|
||||
if (!deploy()) {
|
||||
measured_z = run_z_probe(sanity_check) + offset.z;
|
||||
|
@ -97,6 +97,10 @@ Stepper stepper; // Singleton
|
||||
#include "../MarlinCore.h"
|
||||
#include "../HAL/shared/Delay.h"
|
||||
|
||||
#if ENABLED(BD_SENSOR)
|
||||
#include "../feature/bedlevel/bdl/bdl.h"
|
||||
#endif
|
||||
|
||||
#if ENABLED(INTEGRATED_BABYSTEPPING)
|
||||
#include "../feature/babystep.h"
|
||||
#endif
|
||||
|
@ -981,7 +981,7 @@ void reset_stepper_drivers(); // Called by settings.load / settings.reset
|
||||
|
||||
#if HAS_Z_AXIS
|
||||
#define ENABLE_AXIS_Z() if (SHOULD_ENABLE(z)) { ENABLE_STEPPER_Z(); ENABLE_STEPPER_Z2(); ENABLE_STEPPER_Z3(); ENABLE_STEPPER_Z4(); AFTER_CHANGE(z, true); }
|
||||
#define DISABLE_AXIS_Z() if (SHOULD_DISABLE(z)) { DISABLE_STEPPER_Z(); DISABLE_STEPPER_Z2(); DISABLE_STEPPER_Z3(); DISABLE_STEPPER_Z4(); AFTER_CHANGE(z, false); set_axis_untrusted(Z_AXIS); Z_RESET(); }
|
||||
#define DISABLE_AXIS_Z() if (SHOULD_DISABLE(z)) { DISABLE_STEPPER_Z(); DISABLE_STEPPER_Z2(); DISABLE_STEPPER_Z3(); DISABLE_STEPPER_Z4(); AFTER_CHANGE(z, false); set_axis_untrusted(Z_AXIS); Z_RESET(); TERN_(BD_SENSOR, bdl.config_state = 0); }
|
||||
#else
|
||||
#define ENABLE_AXIS_Z() NOOP
|
||||
#define DISABLE_AXIS_Z() NOOP
|
||||
|
Reference in New Issue
Block a user