|
@@ -79,6 +79,8 @@ static bool old_y_max_endstop=false;
|
79
|
79
|
static bool old_z_min_endstop=false;
|
80
|
80
|
static bool old_z_max_endstop=false;
|
81
|
81
|
|
|
82
|
+static bool check_endstops = true;
|
|
83
|
+
|
82
|
84
|
volatile long count_position[NUM_AXIS] = { 0, 0, 0, 0};
|
83
|
85
|
volatile char count_direction[NUM_AXIS] = { 1, 1, 1, 1};
|
84
|
86
|
|
|
@@ -191,6 +193,11 @@ void endstops_hit_on_purpose()
|
191
|
193
|
endstop_z_hit=false;
|
192
|
194
|
}
|
193
|
195
|
|
|
196
|
+void enable_endstops(bool check)
|
|
197
|
+{
|
|
198
|
+ check_endstops = check;
|
|
199
|
+}
|
|
200
|
+
|
194
|
201
|
// __________________________
|
195
|
202
|
// /| |\ _________________ ^
|
196
|
203
|
// / | | \ /| |\ |
|
|
@@ -309,82 +316,94 @@ ISR(TIMER1_COMPA_vect)
|
309
|
316
|
if ((out_bits & (1<<X_AXIS)) != 0) { // -direction
|
310
|
317
|
WRITE(X_DIR_PIN, INVERT_X_DIR);
|
311
|
318
|
count_direction[X_AXIS]=-1;
|
312
|
|
- #if X_MIN_PIN > -1
|
313
|
|
- bool x_min_endstop=(READ(X_MIN_PIN) != X_ENDSTOPS_INVERTING);
|
314
|
|
- if(x_min_endstop && old_x_min_endstop && (current_block->steps_x > 0)) {
|
315
|
|
- endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
316
|
|
- endstop_x_hit=true;
|
317
|
|
- step_events_completed = current_block->step_event_count;
|
318
|
|
- }
|
319
|
|
- old_x_min_endstop = x_min_endstop;
|
320
|
|
- #endif
|
|
319
|
+ if(check_endstops) {
|
|
320
|
+ #if X_MIN_PIN > -1
|
|
321
|
+ bool x_min_endstop=(READ(X_MIN_PIN) != X_ENDSTOPS_INVERTING);
|
|
322
|
+ if(x_min_endstop && old_x_min_endstop && (current_block->steps_x > 0)) {
|
|
323
|
+ endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
|
324
|
+ endstop_x_hit=true;
|
|
325
|
+ step_events_completed = current_block->step_event_count;
|
|
326
|
+ }
|
|
327
|
+ old_x_min_endstop = x_min_endstop;
|
|
328
|
+ #endif
|
|
329
|
+ }
|
321
|
330
|
}
|
322
|
331
|
else { // +direction
|
323
|
332
|
WRITE(X_DIR_PIN,!INVERT_X_DIR);
|
324
|
333
|
count_direction[X_AXIS]=1;
|
325
|
|
- #if X_MAX_PIN > -1
|
326
|
|
- bool x_max_endstop=(READ(X_MAX_PIN) != X_ENDSTOPS_INVERTING);
|
327
|
|
- if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0)){
|
328
|
|
- endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
329
|
|
- endstop_x_hit=true;
|
330
|
|
- step_events_completed = current_block->step_event_count;
|
331
|
|
- }
|
332
|
|
- old_x_max_endstop = x_max_endstop;
|
333
|
|
- #endif
|
|
334
|
+ if(check_endstops) {
|
|
335
|
+ #if X_MAX_PIN > -1
|
|
336
|
+ bool x_max_endstop=(READ(X_MAX_PIN) != X_ENDSTOPS_INVERTING);
|
|
337
|
+ if(x_max_endstop && old_x_max_endstop && (current_block->steps_x > 0)){
|
|
338
|
+ endstops_trigsteps[X_AXIS] = count_position[X_AXIS];
|
|
339
|
+ endstop_x_hit=true;
|
|
340
|
+ step_events_completed = current_block->step_event_count;
|
|
341
|
+ }
|
|
342
|
+ old_x_max_endstop = x_max_endstop;
|
|
343
|
+ #endif
|
|
344
|
+ }
|
334
|
345
|
}
|
335
|
346
|
|
336
|
347
|
if ((out_bits & (1<<Y_AXIS)) != 0) { // -direction
|
337
|
348
|
WRITE(Y_DIR_PIN,INVERT_Y_DIR);
|
338
|
349
|
count_direction[Y_AXIS]=-1;
|
339
|
|
- #if Y_MIN_PIN > -1
|
340
|
|
- bool y_min_endstop=(READ(Y_MIN_PIN) != Y_ENDSTOPS_INVERTING);
|
341
|
|
- if(y_min_endstop && old_y_min_endstop && (current_block->steps_y > 0)) {
|
342
|
|
- endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
|
343
|
|
- endstop_y_hit=true;
|
344
|
|
- step_events_completed = current_block->step_event_count;
|
345
|
|
- }
|
346
|
|
- old_y_min_endstop = y_min_endstop;
|
347
|
|
- #endif
|
|
350
|
+ if(check_endstops) {
|
|
351
|
+ #if Y_MIN_PIN > -1
|
|
352
|
+ bool y_min_endstop=(READ(Y_MIN_PIN) != Y_ENDSTOPS_INVERTING);
|
|
353
|
+ if(y_min_endstop && old_y_min_endstop && (current_block->steps_y > 0)) {
|
|
354
|
+ endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
|
|
355
|
+ endstop_y_hit=true;
|
|
356
|
+ step_events_completed = current_block->step_event_count;
|
|
357
|
+ }
|
|
358
|
+ old_y_min_endstop = y_min_endstop;
|
|
359
|
+ #endif
|
|
360
|
+ }
|
348
|
361
|
}
|
349
|
362
|
else { // +direction
|
350
|
363
|
WRITE(Y_DIR_PIN,!INVERT_Y_DIR);
|
351
|
364
|
count_direction[Y_AXIS]=1;
|
352
|
|
- #if Y_MAX_PIN > -1
|
353
|
|
- bool y_max_endstop=(READ(Y_MAX_PIN) != Y_ENDSTOPS_INVERTING);
|
354
|
|
- if(y_max_endstop && old_y_max_endstop && (current_block->steps_y > 0)){
|
355
|
|
- endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
|
356
|
|
- endstop_y_hit=true;
|
357
|
|
- step_events_completed = current_block->step_event_count;
|
358
|
|
- }
|
359
|
|
- old_y_max_endstop = y_max_endstop;
|
360
|
|
- #endif
|
|
365
|
+ if(check_endstops) {
|
|
366
|
+ #if Y_MAX_PIN > -1
|
|
367
|
+ bool y_max_endstop=(READ(Y_MAX_PIN) != Y_ENDSTOPS_INVERTING);
|
|
368
|
+ if(y_max_endstop && old_y_max_endstop && (current_block->steps_y > 0)){
|
|
369
|
+ endstops_trigsteps[Y_AXIS] = count_position[Y_AXIS];
|
|
370
|
+ endstop_y_hit=true;
|
|
371
|
+ step_events_completed = current_block->step_event_count;
|
|
372
|
+ }
|
|
373
|
+ old_y_max_endstop = y_max_endstop;
|
|
374
|
+ #endif
|
|
375
|
+ }
|
361
|
376
|
}
|
362
|
377
|
|
363
|
378
|
if ((out_bits & (1<<Z_AXIS)) != 0) { // -direction
|
364
|
379
|
WRITE(Z_DIR_PIN,INVERT_Z_DIR);
|
365
|
380
|
count_direction[Z_AXIS]=-1;
|
366
|
|
- #if Z_MIN_PIN > -1
|
367
|
|
- bool z_min_endstop=(READ(Z_MIN_PIN) != Z_ENDSTOPS_INVERTING);
|
368
|
|
- if(z_min_endstop && old_z_min_endstop && (current_block->steps_z > 0)) {
|
369
|
|
- endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
370
|
|
- endstop_z_hit=true;
|
371
|
|
- step_events_completed = current_block->step_event_count;
|
372
|
|
- }
|
373
|
|
- old_z_min_endstop = z_min_endstop;
|
374
|
|
- #endif
|
|
381
|
+ if(check_endstops) {
|
|
382
|
+ #if Z_MIN_PIN > -1
|
|
383
|
+ bool z_min_endstop=(READ(Z_MIN_PIN) != Z_ENDSTOPS_INVERTING);
|
|
384
|
+ if(z_min_endstop && old_z_min_endstop && (current_block->steps_z > 0)) {
|
|
385
|
+ endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
|
386
|
+ endstop_z_hit=true;
|
|
387
|
+ step_events_completed = current_block->step_event_count;
|
|
388
|
+ }
|
|
389
|
+ old_z_min_endstop = z_min_endstop;
|
|
390
|
+ #endif
|
|
391
|
+ }
|
375
|
392
|
}
|
376
|
393
|
else { // +direction
|
377
|
394
|
WRITE(Z_DIR_PIN,!INVERT_Z_DIR);
|
378
|
|
- count_direction[Z_AXIS]=1;
|
379
|
|
- #if Z_MAX_PIN > -1
|
380
|
|
- bool z_max_endstop=(READ(Z_MAX_PIN) != Z_ENDSTOPS_INVERTING);
|
381
|
|
- if(z_max_endstop && old_z_max_endstop && (current_block->steps_z > 0)) {
|
382
|
|
- endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
383
|
|
- endstop_z_hit=true;
|
384
|
|
- step_events_completed = current_block->step_event_count;
|
385
|
|
- }
|
386
|
|
- old_z_max_endstop = z_max_endstop;
|
387
|
|
- #endif
|
|
395
|
+ count_direction[Z_AXIS]=1;
|
|
396
|
+ if(check_endstops) {
|
|
397
|
+ #if Z_MAX_PIN > -1
|
|
398
|
+ bool z_max_endstop=(READ(Z_MAX_PIN) != Z_ENDSTOPS_INVERTING);
|
|
399
|
+ if(z_max_endstop && old_z_max_endstop && (current_block->steps_z > 0)) {
|
|
400
|
+ endstops_trigsteps[Z_AXIS] = count_position[Z_AXIS];
|
|
401
|
+ endstop_z_hit=true;
|
|
402
|
+ step_events_completed = current_block->step_event_count;
|
|
403
|
+ }
|
|
404
|
+ old_z_max_endstop = z_max_endstop;
|
|
405
|
+ #endif
|
|
406
|
+ }
|
388
|
407
|
}
|
389
|
408
|
|
390
|
409
|
#ifndef ADVANCE
|
|
@@ -666,6 +685,13 @@ void st_init()
|
666
|
685
|
e_steps = 0;
|
667
|
686
|
TIMSK0 |= (1<<OCIE0A);
|
668
|
687
|
#endif //ADVANCE
|
|
688
|
+
|
|
689
|
+ #ifdef ENDSTOPS_ONLY_FOR_HOMING
|
|
690
|
+ enable_endstops(false);
|
|
691
|
+ #else
|
|
692
|
+ enable_endstops(true);
|
|
693
|
+ #endif
|
|
694
|
+
|
669
|
695
|
sei();
|
670
|
696
|
}
|
671
|
697
|
|