|
@@ -73,10 +73,7 @@ static unsigned short step_loops_nominal;
|
73
|
73
|
|
74
|
74
|
volatile long endstops_trigsteps[3] = { 0 };
|
75
|
75
|
volatile long endstops_stepsTotal, endstops_stepsDone;
|
76
|
|
-static volatile bool endstop_x_hit = false;
|
77
|
|
-static volatile bool endstop_y_hit = false;
|
78
|
|
-static volatile bool endstop_z_hit = false;
|
79
|
|
-static volatile bool endstop_z_probe_hit = false; // Leaving this in even if Z_PROBE_ENDSTOP isn't defined, keeps code below cleaner. #ifdef it and usage below to save space.
|
|
76
|
+static volatile char endstop_hit_bits = 0; // use X_MIN, Y_MIN, Z_MIN and Z_PROBE as BIT value
|
80
|
77
|
|
81
|
78
|
#ifdef ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED
|
82
|
79
|
bool abort_on_endstop_hit = false;
|
|
@@ -264,27 +261,27 @@ volatile signed char count_direction[NUM_AXIS] = { 1, 1, 1, 1 };
|
264
|
261
|
#define DISABLE_STEPPER_DRIVER_INTERRUPT() TIMSK1 &= ~BIT(OCIE1A)
|
265
|
262
|
|
266
|
263
|
void endstops_hit_on_purpose() {
|
267
|
|
- endstop_x_hit = endstop_y_hit = endstop_z_hit = endstop_z_probe_hit = false; // #ifdef endstop_z_probe_hit = to save space if needed.
|
|
264
|
+ endstop_hit_bits = 0;
|
268
|
265
|
}
|
269
|
266
|
|
270
|
267
|
void checkHitEndstops() {
|
271
|
|
- if (endstop_x_hit || endstop_y_hit || endstop_z_hit || endstop_z_probe_hit) { // #ifdef || endstop_z_probe_hit to save space if needed.
|
|
268
|
+ if (endstop_hit_bits) { // #ifdef || endstop_z_probe_hit to save space if needed.
|
272
|
269
|
SERIAL_ECHO_START;
|
273
|
270
|
SERIAL_ECHOPGM(MSG_ENDSTOPS_HIT);
|
274
|
|
- if (endstop_x_hit) {
|
|
271
|
+ if (endstop_hit_bits & BIT(X_MIN)) {
|
275
|
272
|
SERIAL_ECHOPAIR(" X:", (float)endstops_trigsteps[X_AXIS] / axis_steps_per_unit[X_AXIS]);
|
276
|
273
|
LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "X");
|
277
|
274
|
}
|
278
|
|
- if (endstop_y_hit) {
|
|
275
|
+ if (endstop_hit_bits & BIT(Y_MIN)) {
|
279
|
276
|
SERIAL_ECHOPAIR(" Y:", (float)endstops_trigsteps[Y_AXIS] / axis_steps_per_unit[Y_AXIS]);
|
280
|
277
|
LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Y");
|
281
|
278
|
}
|
282
|
|
- if (endstop_z_hit) {
|
|
279
|
+ if (endstop_hit_bits & BIT(Z_MIN)) {
|
283
|
280
|
SERIAL_ECHOPAIR(" Z:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
|
284
|
281
|
LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "Z");
|
285
|
282
|
}
|
286
|
283
|
#ifdef Z_PROBE_ENDSTOP
|
287
|
|
- if (endstop_z_probe_hit) {
|
|
284
|
+ if (endstop_hit_bits & BIT(Z_PROBE)) {
|
288
|
285
|
SERIAL_ECHOPAIR(" Z_PROBE:", (float)endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]);
|
289
|
286
|
LCD_MESSAGEPGM(MSG_ENDSTOPS_HIT "ZP");
|
290
|
287
|
}
|
|
@@ -468,13 +465,14 @@ ISR(TIMER1_COMPA_vect) {
|
468
|
465
|
#define _ENDSTOP_INVERTING(AXIS, MINMAX) AXIS ##_## MINMAX ##_ENDSTOP_INVERTING
|
469
|
466
|
#define _OLD_ENDSTOP(axis, minmax) old_## axis ##_## minmax ##_endstop
|
470
|
467
|
#define _AXIS(AXIS) AXIS ##_AXIS
|
471
|
|
- #define _ENDSTOP_HIT(axis) endstop_## axis ##_hit
|
|
468
|
+ #define _HIT_BIT(AXIS) AXIS ##_MIN
|
|
469
|
+ #define _ENDSTOP_HIT(AXIS) endstop_hit_bits |= BIT(_HIT_BIT(AXIS))
|
472
|
470
|
|
473
|
471
|
#define UPDATE_ENDSTOP(axis,AXIS,minmax,MINMAX) \
|
474
|
472
|
bool _ENDSTOP(axis, minmax) = (READ(_ENDSTOP_PIN(AXIS, MINMAX)) != _ENDSTOP_INVERTING(AXIS, MINMAX)); \
|
475
|
473
|
if (_ENDSTOP(axis, minmax) && _OLD_ENDSTOP(axis, minmax) && (current_block->steps[_AXIS(AXIS)] > 0)) { \
|
476
|
474
|
endstops_trigsteps[_AXIS(AXIS)] = count_position[_AXIS(AXIS)]; \
|
477
|
|
- _ENDSTOP_HIT(axis) = true; \
|
|
475
|
+ _ENDSTOP_HIT(AXIS); \
|
478
|
476
|
step_events_completed = current_block->step_event_count; \
|
479
|
477
|
} \
|
480
|
478
|
_OLD_ENDSTOP(axis, minmax) = _ENDSTOP(axis, minmax);
|