From 94120740d8ba0f8338c13dc898bc2f30b78ba371 Mon Sep 17 00:00:00 2001 From: wurstnase Date: Sat, 23 May 2015 07:55:15 +0200 Subject: [PATCH 1/2] faster compare !(~(ab)&0x3) and ab == 0x3 are equal --- Marlin/stepper.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 438120c21..2b5d9c9fc 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -566,8 +566,8 @@ ISR(TIMER1_COMPA_vect) { if (z_test && current_block->steps[Z_AXIS] > 0) { // z_test = Z_MIN || Z2_MIN endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS]; endstop_hit_bits |= BIT(Z_MIN); - if (!performing_homing || (performing_homing && !((~z_test) & 0x3))) //if not performing home or if both endstops were trigged during homing... - step_events_completed = current_block->step_event_count; //!((~z_test) & 0x3) = Z_MIN && Z2_MIN + if (!performing_homing || (performing_homing && z_test == & 0x3))) //if not performing home or if both endstops were trigged during homing... + step_events_completed = current_block->step_event_count; } #else // !Z_DUAL_ENDSTOPS @@ -577,7 +577,6 @@ ISR(TIMER1_COMPA_vect) { #ifdef Z_PROBE_ENDSTOP UPDATE_ENDSTOP(Z, PROBE); - SET_ENDSTOP_BIT(Z, PROBE); if (TEST_ENDSTOP(Z_PROBE)) { @@ -603,8 +602,8 @@ ISR(TIMER1_COMPA_vect) { if (z_test && current_block->steps[Z_AXIS] > 0) { // t_test = Z_MAX || Z2_MAX endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS]; endstop_hit_bits |= BIT(Z_MIN); - if (!performing_homing || (performing_homing && !((~z_test) & 0x3))) //if not performing home or if both endstops were trigged during homing... - step_events_completed = current_block->step_event_count; //!((~z_test) & 0x3) = Z_MAX && Z2_MAX + if (!performing_homing || (performing_homing && z_test == 0x3))) //if not performing home or if both endstops were trigged during homing... + step_events_completed = current_block->step_event_count; } #else // !Z_DUAL_ENDSTOPS From 0f3f7d6835156b5dd4876c619bca685ec0878285 Mon Sep 17 00:00:00 2001 From: wurstnase Date: Sun, 31 May 2015 14:06:13 +0200 Subject: [PATCH 2/2] clean up double endstops --- Marlin/stepper.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Marlin/stepper.cpp b/Marlin/stepper.cpp index 2b5d9c9fc..82c40a369 100644 --- a/Marlin/stepper.cpp +++ b/Marlin/stepper.cpp @@ -566,7 +566,7 @@ ISR(TIMER1_COMPA_vect) { if (z_test && current_block->steps[Z_AXIS] > 0) { // z_test = Z_MIN || Z2_MIN endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS]; endstop_hit_bits |= BIT(Z_MIN); - if (!performing_homing || (performing_homing && z_test == & 0x3))) //if not performing home or if both endstops were trigged during homing... + if (!performing_homing || (z_test == 0x3)) //if not performing home or if both endstops were trigged during homing... step_events_completed = current_block->step_event_count; } #else // !Z_DUAL_ENDSTOPS @@ -602,7 +602,7 @@ ISR(TIMER1_COMPA_vect) { if (z_test && current_block->steps[Z_AXIS] > 0) { // t_test = Z_MAX || Z2_MAX endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS]; endstop_hit_bits |= BIT(Z_MIN); - if (!performing_homing || (performing_homing && z_test == 0x3))) //if not performing home or if both endstops were trigged during homing... + if (!performing_homing || (z_test == 0x3)) //if not performing home or if both endstops were trigged during homing... step_events_completed = current_block->step_event_count; } @@ -615,7 +615,7 @@ ISR(TIMER1_COMPA_vect) { #ifdef Z_PROBE_ENDSTOP UPDATE_ENDSTOP(Z, PROBE); - SET_ENDSTOP_BIT(Z, PROBE); + if (TEST_ENDSTOP(Z_PROBE)) { endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];