Skip to content

Commit

Permalink
Use bitfields for test_sensitivity
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Jul 12, 2021
1 parent 6ccff86 commit 1eea57b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
16 changes: 9 additions & 7 deletions Marlin/src/gcode/calibrate/G33.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,9 +387,11 @@ static float auto_tune_a() {
*
* E Engage the probe for each point
*
* X It will not activate stallguard for the X axis. Use with SENSORLESS_PROBING, to calibrate the sensitivity individually on each axis. Fe. G33 P1 Y Z --> To calibrate only X.
* Y It will not activate stallguard for the Y axis. Use with SENSORLESS_PROBING, to calibrate the sensitivity individually on each axis. Fe. G33 P1 X Z --> To calibrate only Y.
* Z It will not activate stallguard for the Z axis. Use with SENSORLESS_PROBING, to calibrate the sensitivity individually on each axis. Fe. G33 P1 X Y --> To calibrate only Z.
* With SENSORLESS_PROBING:
* Use these flags to calibrate stall sensitivity: (e.g., `G33 P1 Y Z` to calibrate X only.)
* X Don't activate stallguard on X.
* Y Don't activate stallguard on Y.
* Z Don't activate stallguard on Z.
*/
void GcodeSuite::G33() {

Expand Down Expand Up @@ -423,10 +425,10 @@ void GcodeSuite::G33() {

const bool stow_after_each = parser.seen_test('E');

#if ENABLED(HAS_BED_PROBE)
probe.test_sensitivity_X = !parser.seen_test('X');
probe.test_sensitivity_Y = !parser.seen_test('Y');
probe.test_sensitivity_Z = !parser.seen_test('Z');
#if ENABLED(SENSORLESS_PROBING)
probe.test_sensitivity.x = !parser.seen_test('X');
TERN_(HAS_Y_AXIS, probe.test_sensitivity.y = !parser.seen_test('Y'));
TERN_(HAS_Z_AXIS, probe.test_sensitivity.z = !parser.seen_test('Z'));
#endif

const bool _0p_calibration = probe_points == 0,
Expand Down
21 changes: 13 additions & 8 deletions Marlin/src/module/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ xyz_pos_t Probe::offset; // Initialized by settings.load()
const xy_pos_t &Probe::offset_xy = Probe::offset;
#endif

#if ENABLED(SENSORLESS_PROBING)
struct { bool x:1, y:1, z:1; } Probe::test_sensitivity;
#endif

#if ENABLED(Z_PROBE_SLED)

#ifndef SLED_DOCKING_OFFSET
Expand Down Expand Up @@ -493,10 +497,10 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) {
#if ENABLED(SENSORLESS_PROBING)
sensorless_t stealth_states { false };
#if ENABLED(DELTA)
if (probe.test_sensitivity_X) stealth_states.x = tmc_enable_stallguard(stepperX); // Delta watches all DIAG pins for a stall
if (probe.test_sensitivity_Y) stealth_states.y = tmc_enable_stallguard(stepperY);
if (probe.test_sensitivity.x) stealth_states.x = tmc_enable_stallguard(stepperX); // Delta watches all DIAG pins for a stall
if (probe.test_sensitivity.y) stealth_states.y = tmc_enable_stallguard(stepperY);
#endif
if (probe.test_sensitivity_Z) stealth_states.z = tmc_enable_stallguard(stepperZ); // All machines will check Z-DIAG for stall
if (probe.test_sensitivity.z) stealth_states.z = tmc_enable_stallguard(stepperZ); // All machines will check Z-DIAG for stall
endstops.enable(true);
set_homing_current(true); // The "homing" current also applies to probing
#endif
Expand All @@ -521,10 +525,10 @@ bool Probe::probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s) {
#if ENABLED(SENSORLESS_PROBING)
endstops.not_homing();
#if ENABLED(DELTA)
if (probe.test_sensitivity_X) tmc_disable_stallguard(stepperX, stealth_states.x);
if (probe.test_sensitivity_Y) tmc_disable_stallguard(stepperY, stealth_states.y);
if (probe.test_sensitivity.x) tmc_disable_stallguard(stepperX, stealth_states.x);
if (probe.test_sensitivity.y) tmc_disable_stallguard(stepperY, stealth_states.y);
#endif
if (probe.test_sensitivity_Z) tmc_disable_stallguard(stepperZ, stealth_states.z);
if (probe.test_sensitivity.z) tmc_disable_stallguard(stepperZ, stealth_states.z);
set_homing_current(false);
#endif

Expand Down Expand Up @@ -820,6 +824,7 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai
#if EITHER(SENSORLESS_PROBING, SENSORLESS_HOMING)

sensorless_t stealth_states { false };

/**
* Disable stealthChop if used. Enable diag1 pin on driver.
*/
Expand All @@ -833,7 +838,8 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai
endstops.enable(true);
#endif
}
/**

/**
* Re-enable stealthChop if used. Disable diag1 pin on driver.
*/
void Probe::disable_stallguard_diag1() {
Expand All @@ -845,7 +851,6 @@ float Probe::probe_at_point(const_float_t rx, const_float_t ry, const ProbePtRai
#endif
tmc_disable_stallguard(stepperZ, stealth_states.z);
#endif

}

/**
Expand Down
9 changes: 4 additions & 5 deletions Marlin/src/module/probe.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@
class Probe {
public:

#if ENABLED(SENSORLESS_PROBING)
static struct { bool x:1, y:1, z:1; } test_sensitivity;
#endif

#if HAS_BED_PROBE

static xyz_pos_t offset;
Expand Down Expand Up @@ -263,11 +267,6 @@ class Probe {
static void set_homing_current(const bool onoff);
#endif

public:
bool test_sensitivity_X;
bool test_sensitivity_Y;
bool test_sensitivity_Z;

private:
static bool probe_down_to_z(const_float_t z, const_feedRate_t fr_mm_s);
static void do_z_raise(const float z_raise);
Expand Down

0 comments on commit 1eea57b

Please sign in to comment.