Skip to content

Commit

Permalink
Fix TERN typo, EXTRA_PROBING
Browse files Browse the repository at this point in the history
Co-Authored-By: Matthew Kennedy <mattkenn4545@gmail.com>
  • Loading branch information
thinkyhead and mattkenn4545 committed May 10, 2020
1 parent 32dc874 commit e5b0892
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@
#define PROBE_TRIGGERED_WHEN_STOWED_TEST 1 // Extra test for Allen Key Probe
#endif
#if MULTIPLE_PROBING > 1
#if EXTRA_PROBING
#if EXTRA_PROBING > 0
#define TOTAL_PROBING (MULTIPLE_PROBING + EXTRA_PROBING)
#else
#define TOTAL_PROBING MULTIPLE_PROBING
Expand Down
4 changes: 2 additions & 2 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -1285,8 +1285,8 @@ static_assert(Y_MAX_LENGTH >= Y_BED_SIZE, "Movement bounds (Y_MIN_POS, Y_MAX_POS
#error "Probes need Z_AFTER_PROBING >= 0."
#endif

#if MULTIPLE_PROBING || EXTRA_PROBING
#if !MULTIPLE_PROBING
#if MULTIPLE_PROBING > 0 || EXTRA_PROBING > 0
#if MULTIPLE_PROBING == 0
#error "EXTRA_PROBING requires MULTIPLE_PROBING."
#elif MULTIPLE_PROBING < 2
#error "MULTIPLE_PROBING must be 2 or more."
Expand Down
15 changes: 9 additions & 6 deletions Marlin/src/module/probe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,14 +565,14 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {
}
#endif

#ifdef EXTRA_PROBING
#if EXTRA_PROBING > 0
float probes[TOTAL_PROBING];
#endif

#if TOTAL_PROBING > 2
float probes_z_sum = 0;
for (
#if EXTRA_PROBING
#if EXTRA_PROBING > 0
uint8_t p = 0; p < TOTAL_PROBING; p++
#else
uint8_t p = TOTAL_PROBING; p--;
Expand All @@ -588,7 +588,7 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {

const float z = current_position.z;

#if EXTRA_PROBING
#if EXTRA_PROBING > 0
// Insert Z measurement into probes[]. Keep it sorted ascending.
LOOP_LE_N(i, p) { // Iterate the saved Zs to insert the new Z
if (i == p || probes[i] > z) { // Last index or new Z is smaller than this Z
Expand All @@ -605,14 +605,17 @@ float Probe::run_z_probe(const bool sanity_check/*=true*/) {

#if TOTAL_PROBING > 2
// Small Z raise after all but the last probe
if (TERN(EXTRA_PROBING, p < TOTAL_PROBING - 1, p))
do_blocking_move_to_z(z + Z_CLEARANCE_MULTI_PROBE, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
if (p
#if EXTRA_PROBING > 0
< TOTAL_PROBING - 1
#endif
) do_blocking_move_to_z(z + Z_CLEARANCE_MULTI_PROBE, MMM_TO_MMS(Z_PROBE_SPEED_FAST));
#endif
}

#if TOTAL_PROBING > 2

#if EXTRA_PROBING
#if EXTRA_PROBING > 0
// Take the center value (or average the two middle values) as the median
static constexpr int PHALF = (TOTAL_PROBING - 1) / 2;
const float middle = probes[PHALF],
Expand Down

0 comments on commit e5b0892

Please sign in to comment.