|
@@ -1407,69 +1407,69 @@ void Temperature::set_current_temp_raw() {
|
1407
|
1407
|
void endstop_monitor() {
|
1408
|
1408
|
static uint16_t old_endstop_bits_local = 0;
|
1409
|
1409
|
static uint8_t local_LED_status = 0;
|
1410
|
|
- if (endstop_monitor_flag) {
|
1411
|
|
- uint16_t current_endstop_bits_local = 0;
|
|
1410
|
+ uint16_t current_endstop_bits_local = 0;
|
|
1411
|
+ #if HAS_X_MIN
|
|
1412
|
+ if (READ(X_MIN_PIN)) SBI(current_endstop_bits_local, X_MIN);
|
|
1413
|
+ #endif
|
|
1414
|
+ #if HAS_X_MAX
|
|
1415
|
+ if (READ(X_MAX_PIN)) SBI(current_endstop_bits_local, X_MAX);
|
|
1416
|
+ #endif
|
|
1417
|
+ #if HAS_Y_MIN
|
|
1418
|
+ if (READ(Y_MIN_PIN)) SBI(current_endstop_bits_local, Y_MIN);
|
|
1419
|
+ #endif
|
|
1420
|
+ #if HAS_Y_MAX
|
|
1421
|
+ if (READ(Y_MAX_PIN)) SBI(current_endstop_bits_local, Y_MAX);
|
|
1422
|
+ #endif
|
|
1423
|
+ #if HAS_Z_MIN
|
|
1424
|
+ if (READ(Z_MIN_PIN)) SBI(current_endstop_bits_local, Z_MIN);
|
|
1425
|
+ #endif
|
|
1426
|
+ #if HAS_Z_MAX
|
|
1427
|
+ if (READ(Z_MAX_PIN)) SBI(current_endstop_bits_local, Z_MAX);
|
|
1428
|
+ #endif
|
|
1429
|
+ #if HAS_Z_MIN_PROBE_PIN
|
|
1430
|
+ if (READ(Z_MIN_PROBE_PIN)) SBI(current_endstop_bits_local, Z_MIN_PROBE);
|
|
1431
|
+ #endif
|
|
1432
|
+ #if HAS_Z2_MIN
|
|
1433
|
+ if (READ(Z2_MIN_PIN)) SBI(current_endstop_bits_local, Z2_MIN);
|
|
1434
|
+ #endif
|
|
1435
|
+ #if HAS_Z2_MAX
|
|
1436
|
+ if (READ(Z2_MAX_PIN)) SBI(current_endstop_bits_local, Z2_MAX);
|
|
1437
|
+ #endif
|
|
1438
|
+
|
|
1439
|
+ uint16_t endstop_change = current_endstop_bits_local ^ old_endstop_bits_local;
|
|
1440
|
+
|
|
1441
|
+ if (endstop_change) {
|
1412
|
1442
|
#if HAS_X_MIN
|
1413
|
|
- if (READ(X_MIN_PIN)) current_endstop_bits_local |= _BV(X_MIN);
|
1414
|
|
- if ((current_endstop_bits_local ^ old_endstop_bits_local) & _BV(X_MIN)) {
|
1415
|
|
- SERIAL_PROTOCOLPAIR("X_MIN: ", (current_endstop_bits_local & _BV(X_MIN)) ? 1 : 0);
|
1416
|
|
- }
|
|
1443
|
+ if (TEST(endstop_change, X_MIN)) SERIAL_PROTOCOLPAIR("X_MIN:", !!TEST(current_endstop_bits_local, X_MIN));
|
1417
|
1444
|
#endif
|
1418
|
1445
|
#if HAS_X_MAX
|
1419
|
|
- if (READ(X_MAX_PIN)) current_endstop_bits_local |= _BV(X_MAX);
|
1420
|
|
- if ((current_endstop_bits_local ^ old_endstop_bits_local) & _BV(X_MAX)) {
|
1421
|
|
- SERIAL_PROTOCOLPAIR(" X_MAX: ", (current_endstop_bits_local & _BV(X_MAX)) ? 1 : 0);
|
1422
|
|
- }
|
|
1446
|
+ if (TEST(endstop_change, X_MAX)) SERIAL_PROTOCOLPAIR(" X_MAX:", !!TEST(current_endstop_bits_local, X_MAX));
|
1423
|
1447
|
#endif
|
1424
|
1448
|
#if HAS_Y_MIN
|
1425
|
|
- if (READ(Y_MIN_PIN)) current_endstop_bits_local |= _BV(Y_MIN);
|
1426
|
|
- if ((current_endstop_bits_local ^ old_endstop_bits_local) & _BV(Y_MIN)) {
|
1427
|
|
- SERIAL_PROTOCOLPAIR(" Y_MIN: ", (current_endstop_bits_local & _BV(Y_MIN)) ? 1 : 0);
|
1428
|
|
- }
|
|
1449
|
+ if (TEST(endstop_change, Y_MIN)) SERIAL_PROTOCOLPAIR(" Y_MIN:", !!TEST(current_endstop_bits_local, Y_MIN));
|
1429
|
1450
|
#endif
|
1430
|
1451
|
#if HAS_Y_MAX
|
1431
|
|
- if (READ(Y_MAX_PIN)) current_endstop_bits_local |= _BV(Y_MAX);
|
1432
|
|
- if ((current_endstop_bits_local ^ old_endstop_bits_local) & _BV(Y_MAX)) {
|
1433
|
|
- SERIAL_PROTOCOLPAIR(" Y_MAX: ", (current_endstop_bits_local & _BV(Y_MAX)) ? 1 : 0);
|
1434
|
|
- }
|
|
1452
|
+ if (TEST(endstop_change, Y_MAX)) SERIAL_PROTOCOLPAIR(" Y_MAX:", !!TEST(current_endstop_bits_local, Y_MAX));
|
1435
|
1453
|
#endif
|
1436
|
1454
|
#if HAS_Z_MIN
|
1437
|
|
- if (READ(Z_MIN_PIN)) current_endstop_bits_local |= _BV(Z_MIN);
|
1438
|
|
- if ((current_endstop_bits_local ^ old_endstop_bits_local) & _BV(Z_MIN)) {
|
1439
|
|
- SERIAL_PROTOCOLPAIR(" Z_MIN: ", (current_endstop_bits_local & _BV(Z_MIN)) ? 1 : 0);
|
1440
|
|
- }
|
|
1455
|
+ if (TEST(endstop_change, Z_MIN)) SERIAL_PROTOCOLPAIR(" Z_MIN:", !!TEST(current_endstop_bits_local, Z_MIN));
|
1441
|
1456
|
#endif
|
1442
|
1457
|
#if HAS_Z_MAX
|
1443
|
|
- if (READ(Z_MAX_PIN)) current_endstop_bits_local |= _BV(Z_MAX);
|
1444
|
|
- if ((current_endstop_bits_local ^ old_endstop_bits_local) & _BV(Z_MAX)) {
|
1445
|
|
- SERIAL_PROTOCOLPAIR(" Z_MAX: ", (current_endstop_bits_local & _BV(Z_MAX)) ? 1 : 0);
|
1446
|
|
- }
|
|
1458
|
+ if (TEST(endstop_change, Z_MAX)) SERIAL_PROTOCOLPAIR(" Z_MAX:", !!TEST(current_endstop_bits_local, Z_MAX));
|
1447
|
1459
|
#endif
|
1448
|
1460
|
#if HAS_Z_MIN_PROBE_PIN
|
1449
|
|
- if (READ(Z_MIN_PROBE_PIN)) current_endstop_bits_local |= _BV(Z_MIN_PROBE);
|
1450
|
|
- if ((current_endstop_bits_local ^ old_endstop_bits_local) & _BV(Z_MIN_PROBE)) {
|
1451
|
|
- SERIAL_PROTOCOLPAIR(" PROBE: ", (current_endstop_bits_local & _BV(Z_MIN_PROBE)) ? 1 : 0);
|
1452
|
|
- }
|
|
1461
|
+ if (TEST(endstop_change, Z_MIN_PROBE)) SERIAL_PROTOCOLPAIR(" PROBE:", !!TEST(current_endstop_bits_local, Z_MIN_PROBE));
|
1453
|
1462
|
#endif
|
1454
|
1463
|
#if HAS_Z2_MIN
|
1455
|
|
- if (READ(Z2_MIN_PIN)) current_endstop_bits_local |= _BV(Z2_MIN);
|
1456
|
|
- if ((current_endstop_bits_local ^ old_endstop_bits_local) & _BV(Z2_MIN)) {
|
1457
|
|
- SERIAL_PROTOCOLPAIR(" Z2_MIN: ", (current_endstop_bits_local & _BV(Z2_MIN)) ? 1 : 0);
|
1458
|
|
- }
|
|
1464
|
+ if (TEST(endstop_change, Z2_MIN)) SERIAL_PROTOCOLPAIR(" Z2_MIN:", !!TEST(current_endstop_bits_local, Z2_MIN));
|
1459
|
1465
|
#endif
|
1460
|
1466
|
#if HAS_Z2_MAX
|
1461
|
|
- if (READ(Z2_MAX_PIN)) current_endstop_bits_local |= _BV(Z2_MAX);
|
1462
|
|
- if ((current_endstop_bits_local ^ old_endstop_bits_local) & _BV(Z2_MAX)) {
|
1463
|
|
- SERIAL_PROTOCOLPAIR(" Z2_MAX: ", (current_endstop_bits_local & _BV(Z2_MAX)) ? 1 : 0);
|
1464
|
|
- }
|
|
1467
|
+ if (TEST(endstop_change, Z2_MAX)) SERIAL_PROTOCOLPAIR(" Z2_MAX:", !!TEST(current_endstop_bits_local, Z2_MAX));
|
1465
|
1468
|
#endif
|
1466
|
|
-
|
1467
|
|
- if (current_endstop_bits_local != old_endstop_bits_local) {
|
1468
|
|
- analogWrite(LED_PIN, local_LED_status ); // toggle LED
|
1469
|
|
- SERIAL_PROTOCOLPGM("\n\n"); // make it easy to see the message
|
1470
|
|
- old_endstop_bits_local = current_endstop_bits_local ; // get ready for next change
|
1471
|
|
- local_LED_status = local_LED_status ? 0 : 255;
|
1472
|
|
- }
|
|
1469
|
+ SERIAL_PROTOCOLPGM("\n\n");
|
|
1470
|
+ analogWrite(LED_PIN, local_LED_status);
|
|
1471
|
+ local_LED_status ^= 255;
|
|
1472
|
+ old_endstop_bits_local = current_endstop_bits_local;
|
1473
|
1473
|
}
|
1474
|
1474
|
}
|
1475
|
1475
|
#endif // PINS_DEBUGGING
|
|
@@ -1929,12 +1929,15 @@ void Temperature::isr() {
|
1929
|
1929
|
}
|
1930
|
1930
|
}
|
1931
|
1931
|
#endif //BABYSTEPPING
|
|
1932
|
+
|
1932
|
1933
|
#if ENABLED(PINS_DEBUGGING)
|
1933
|
1934
|
extern bool endstop_monitor_flag;
|
1934
|
1935
|
// run the endstop monitor at 15Hz
|
1935
|
1936
|
static uint8_t endstop_monitor_count = 16; // offset this check from the others
|
1936
|
|
- endstop_monitor_count += _BV(1); // 15 Hz
|
1937
|
|
- endstop_monitor_count &= 0x7F;
|
1938
|
|
- if (endstop_monitor_count == 0) endstop_monitor(); // report changes in endstop status
|
|
1937
|
+ if (endstop_monitor_flag) {
|
|
1938
|
+ endstop_monitor_count += _BV(1); // 15 Hz
|
|
1939
|
+ endstop_monitor_count &= 0x7F;
|
|
1940
|
+ if (!endstop_monitor_count) endstop_monitor(); // report changes in endstop status
|
|
1941
|
+ }
|
1939
|
1942
|
#endif
|
1940
|
1943
|
}
|