Add Endstop Noise Filter
Co-Authored-By: ejtagle <ejtagle@hotmail.com>
This commit is contained in:
parent
e63113e6ad
commit
a971cacb06
6 changed files with 233 additions and 122 deletions
|
|
@ -1695,71 +1695,71 @@ void Temperature::set_current_temp_raw() {
|
|||
*
|
||||
*/
|
||||
void endstop_monitor() {
|
||||
static uint16_t old_endstop_bits_local = 0;
|
||||
static uint16_t old_live_state_local = 0;
|
||||
static uint8_t local_LED_status = 0;
|
||||
uint16_t current_endstop_bits_local = 0;
|
||||
uint16_t live_state_local = 0;
|
||||
#if HAS_X_MIN
|
||||
if (READ(X_MIN_PIN)) SBI(current_endstop_bits_local, X_MIN);
|
||||
if (READ(X_MIN_PIN)) SBI(live_state_local, X_MIN);
|
||||
#endif
|
||||
#if HAS_X_MAX
|
||||
if (READ(X_MAX_PIN)) SBI(current_endstop_bits_local, X_MAX);
|
||||
if (READ(X_MAX_PIN)) SBI(live_state_local, X_MAX);
|
||||
#endif
|
||||
#if HAS_Y_MIN
|
||||
if (READ(Y_MIN_PIN)) SBI(current_endstop_bits_local, Y_MIN);
|
||||
if (READ(Y_MIN_PIN)) SBI(live_state_local, Y_MIN);
|
||||
#endif
|
||||
#if HAS_Y_MAX
|
||||
if (READ(Y_MAX_PIN)) SBI(current_endstop_bits_local, Y_MAX);
|
||||
if (READ(Y_MAX_PIN)) SBI(live_state_local, Y_MAX);
|
||||
#endif
|
||||
#if HAS_Z_MIN
|
||||
if (READ(Z_MIN_PIN)) SBI(current_endstop_bits_local, Z_MIN);
|
||||
if (READ(Z_MIN_PIN)) SBI(live_state_local, Z_MIN);
|
||||
#endif
|
||||
#if HAS_Z_MAX
|
||||
if (READ(Z_MAX_PIN)) SBI(current_endstop_bits_local, Z_MAX);
|
||||
if (READ(Z_MAX_PIN)) SBI(live_state_local, Z_MAX);
|
||||
#endif
|
||||
#if HAS_Z_MIN_PROBE_PIN
|
||||
if (READ(Z_MIN_PROBE_PIN)) SBI(current_endstop_bits_local, Z_MIN_PROBE);
|
||||
if (READ(Z_MIN_PROBE_PIN)) SBI(live_state_local, Z_MIN_PROBE);
|
||||
#endif
|
||||
#if HAS_Z2_MIN
|
||||
if (READ(Z2_MIN_PIN)) SBI(current_endstop_bits_local, Z2_MIN);
|
||||
if (READ(Z2_MIN_PIN)) SBI(live_state_local, Z2_MIN);
|
||||
#endif
|
||||
#if HAS_Z2_MAX
|
||||
if (READ(Z2_MAX_PIN)) SBI(current_endstop_bits_local, Z2_MAX);
|
||||
if (READ(Z2_MAX_PIN)) SBI(live_state_local, Z2_MAX);
|
||||
#endif
|
||||
|
||||
uint16_t endstop_change = current_endstop_bits_local ^ old_endstop_bits_local;
|
||||
uint16_t endstop_change = live_state_local ^ old_live_state_local;
|
||||
|
||||
if (endstop_change) {
|
||||
#if HAS_X_MIN
|
||||
if (TEST(endstop_change, X_MIN)) SERIAL_PROTOCOLPAIR(" X_MIN:", !!TEST(current_endstop_bits_local, X_MIN));
|
||||
if (TEST(endstop_change, X_MIN)) SERIAL_PROTOCOLPAIR(" X_MIN:", !!TEST(live_state_local, X_MIN));
|
||||
#endif
|
||||
#if HAS_X_MAX
|
||||
if (TEST(endstop_change, X_MAX)) SERIAL_PROTOCOLPAIR(" X_MAX:", !!TEST(current_endstop_bits_local, X_MAX));
|
||||
if (TEST(endstop_change, X_MAX)) SERIAL_PROTOCOLPAIR(" X_MAX:", !!TEST(live_state_local, X_MAX));
|
||||
#endif
|
||||
#if HAS_Y_MIN
|
||||
if (TEST(endstop_change, Y_MIN)) SERIAL_PROTOCOLPAIR(" Y_MIN:", !!TEST(current_endstop_bits_local, Y_MIN));
|
||||
if (TEST(endstop_change, Y_MIN)) SERIAL_PROTOCOLPAIR(" Y_MIN:", !!TEST(live_state_local, Y_MIN));
|
||||
#endif
|
||||
#if HAS_Y_MAX
|
||||
if (TEST(endstop_change, Y_MAX)) SERIAL_PROTOCOLPAIR(" Y_MAX:", !!TEST(current_endstop_bits_local, Y_MAX));
|
||||
if (TEST(endstop_change, Y_MAX)) SERIAL_PROTOCOLPAIR(" Y_MAX:", !!TEST(live_state_local, Y_MAX));
|
||||
#endif
|
||||
#if HAS_Z_MIN
|
||||
if (TEST(endstop_change, Z_MIN)) SERIAL_PROTOCOLPAIR(" Z_MIN:", !!TEST(current_endstop_bits_local, Z_MIN));
|
||||
if (TEST(endstop_change, Z_MIN)) SERIAL_PROTOCOLPAIR(" Z_MIN:", !!TEST(live_state_local, Z_MIN));
|
||||
#endif
|
||||
#if HAS_Z_MAX
|
||||
if (TEST(endstop_change, Z_MAX)) SERIAL_PROTOCOLPAIR(" Z_MAX:", !!TEST(current_endstop_bits_local, Z_MAX));
|
||||
if (TEST(endstop_change, Z_MAX)) SERIAL_PROTOCOLPAIR(" Z_MAX:", !!TEST(live_state_local, Z_MAX));
|
||||
#endif
|
||||
#if HAS_Z_MIN_PROBE_PIN
|
||||
if (TEST(endstop_change, Z_MIN_PROBE)) SERIAL_PROTOCOLPAIR(" PROBE:", !!TEST(current_endstop_bits_local, Z_MIN_PROBE));
|
||||
if (TEST(endstop_change, Z_MIN_PROBE)) SERIAL_PROTOCOLPAIR(" PROBE:", !!TEST(live_state_local, Z_MIN_PROBE));
|
||||
#endif
|
||||
#if HAS_Z2_MIN
|
||||
if (TEST(endstop_change, Z2_MIN)) SERIAL_PROTOCOLPAIR(" Z2_MIN:", !!TEST(current_endstop_bits_local, Z2_MIN));
|
||||
if (TEST(endstop_change, Z2_MIN)) SERIAL_PROTOCOLPAIR(" Z2_MIN:", !!TEST(live_state_local, Z2_MIN));
|
||||
#endif
|
||||
#if HAS_Z2_MAX
|
||||
if (TEST(endstop_change, Z2_MAX)) SERIAL_PROTOCOLPAIR(" Z2_MAX:", !!TEST(current_endstop_bits_local, Z2_MAX));
|
||||
if (TEST(endstop_change, Z2_MAX)) SERIAL_PROTOCOLPAIR(" Z2_MAX:", !!TEST(live_state_local, Z2_MAX));
|
||||
#endif
|
||||
SERIAL_PROTOCOLPGM("\n\n");
|
||||
analogWrite(LED_PIN, local_LED_status);
|
||||
local_LED_status ^= 255;
|
||||
old_endstop_bits_local = current_endstop_bits_local;
|
||||
old_live_state_local = live_state_local;
|
||||
}
|
||||
}
|
||||
#endif // PINS_DEBUGGING
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue