|
@@ -90,7 +90,7 @@
|
90
|
90
|
* M33 - Get the longname version of a path. (Requires LONG_FILENAME_HOST_SUPPORT)
|
91
|
91
|
* M34 - Set SD Card sorting options. (Requires SDCARD_SORT_ALPHA)
|
92
|
92
|
* M42 - Change pin status via gcode: M42 P<pin> S<value>. LED pin assumed if P is omitted.
|
93
|
|
- * M43 - Monitor pins & report changes - report active pins
|
|
93
|
+ * M43 - Display pin status, watch pins for changes, watch endstops & toggle LED, Z servo probe test, toggle pins
|
94
|
94
|
* M48 - Measure Z Probe repeatability: M48 P<points> X<pos> Y<pos> V<level> E<engage> L<legs>. (Requires Z_MIN_PROBE_REPEATABILITY_TEST)
|
95
|
95
|
* M75 - Start the print job timer.
|
96
|
96
|
* M76 - Pause the print job timer.
|
|
@@ -5308,23 +5308,176 @@ inline void gcode_M42() {
|
5308
|
5308
|
|
5309
|
5309
|
#include "pinsDebug.h"
|
5310
|
5310
|
|
|
5311
|
+
|
|
5312
|
+ inline void toggle_pins() {
|
|
5313
|
+ int pin, j, start = 0, I_flag = 0, end = NUM_DIGITAL_PINS - 1, wait = 500, repeat = 1;
|
|
5314
|
+
|
|
5315
|
+ if (code_seen('R'))
|
|
5316
|
+ repeat = code_value_int();
|
|
5317
|
+
|
|
5318
|
+ if (code_seen('S'))
|
|
5319
|
+ start = code_value_int();
|
|
5320
|
+
|
|
5321
|
+ if (code_seen('E'))
|
|
5322
|
+ end = code_value_int();
|
|
5323
|
+
|
|
5324
|
+ if (code_seen('I') )
|
|
5325
|
+ I_flag++;
|
|
5326
|
+
|
|
5327
|
+ if (code_seen('W'))
|
|
5328
|
+ wait = code_value_int();
|
|
5329
|
+
|
|
5330
|
+ for(pin = start; pin <= end; pin++) {
|
|
5331
|
+ if ( I_flag == 0 && pin_is_protected(pin)) {
|
|
5332
|
+ SERIAL_ECHOPAIR("Sensitive Pin: ", pin);
|
|
5333
|
+ SERIAL_ECHOPGM(" untouched.\n");
|
|
5334
|
+ }
|
|
5335
|
+ else {
|
|
5336
|
+ SERIAL_ECHOPAIR("Pulsing Pin: ", pin);
|
|
5337
|
+ pinMode(pin, OUTPUT);
|
|
5338
|
+ for(j = 0; j < repeat; j++) {
|
|
5339
|
+ digitalWrite(pin, 0);
|
|
5340
|
+ idle();
|
|
5341
|
+ delay(wait);
|
|
5342
|
+ digitalWrite(pin, 1);
|
|
5343
|
+ idle();
|
|
5344
|
+ delay(wait);
|
|
5345
|
+ digitalWrite(pin, 0);
|
|
5346
|
+ idle();
|
|
5347
|
+ delay(wait);
|
|
5348
|
+ }
|
|
5349
|
+ }
|
|
5350
|
+ SERIAL_ECHOPGM("\n");
|
|
5351
|
+ }
|
|
5352
|
+ SERIAL_ECHOPGM("Done\n");
|
|
5353
|
+ return;
|
|
5354
|
+ } // toggle pin(s)
|
|
5355
|
+
|
|
5356
|
+
|
|
5357
|
+ inline void servo_probe_test(){
|
|
5358
|
+ #if !(NUM_SERVOS >= 1 && HAS_SERVO_0)
|
|
5359
|
+ SERIAL_ERROR_START;
|
|
5360
|
+ SERIAL_ERRORLNPGM("SERVO not setup");
|
|
5361
|
+ #else
|
|
5362
|
+
|
|
5363
|
+ #if !defined(z_servo_angle)
|
|
5364
|
+ const int z_servo_angle[2] = Z_SERVO_ANGLES;
|
|
5365
|
+ #endif
|
|
5366
|
+ uint8_t probe_index = code_seen('P') ? code_value_byte() : 0;
|
|
5367
|
+ SERIAL_PROTOCOLLNPGM("Servo probe test");
|
|
5368
|
+ SERIAL_PROTOCOLLNPAIR(". using index: ", probe_index);
|
|
5369
|
+ SERIAL_PROTOCOLLNPAIR(". deploy angle: ", z_servo_angle[0]);
|
|
5370
|
+ SERIAL_PROTOCOLLNPAIR(". stow angle: ", z_servo_angle[1]);
|
|
5371
|
+ bool probe_inverting;
|
|
5372
|
+ #if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
|
|
5373
|
+ #define PROBE_TEST_PIN Z_MIN_PIN
|
|
5374
|
+ SERIAL_PROTOCOLLNPAIR(". probe uses Z_MIN pin: ", PROBE_TEST_PIN);
|
|
5375
|
+ SERIAL_PROTOCOLLNPGM(". uses Z_MIN_ENDSTOP_INVERTING (ignores Z_MIN_PROBE_ENDSTOP_INVERTING)");
|
|
5376
|
+ SERIAL_PROTOCOLPGM(". Z_MIN_ENDSTOP_INVERTING: ");
|
|
5377
|
+ if (Z_MIN_ENDSTOP_INVERTING) SERIAL_PROTOCOLLNPGM("true");
|
|
5378
|
+ else SERIAL_PROTOCOLLNPGM("false");
|
|
5379
|
+ probe_inverting = Z_MIN_ENDSTOP_INVERTING;
|
|
5380
|
+ #elif ENABLED(Z_MIN_PROBE_ENDSTOP)
|
|
5381
|
+ #define PROBE_TEST_PIN Z_MIN_PROBE_PIN
|
|
5382
|
+
|
|
5383
|
+ SERIAL_PROTOCOLLNPAIR(". probe uses Z_MIN_PROBE_PIN: ", PROBE_TEST_PIN);
|
|
5384
|
+ SERIAL_PROTOCOLLNPGM(". uses Z_MIN_PROBE_ENDSTOP_INVERTING (ignores Z_MIN_ENDSTOP_INVERTING)");
|
|
5385
|
+ SERIAL_PROTOCOLPGM(". Z_MIN_PROBE_ENDSTOP_INVERTING: ");
|
|
5386
|
+ if (Z_MIN_PROBE_ENDSTOP_INVERTING) SERIAL_PROTOCOLLNPGM("true");
|
|
5387
|
+ else SERIAL_PROTOCOLLNPGM("false");
|
|
5388
|
+ probe_inverting = Z_MIN_PROBE_ENDSTOP_INVERTING;
|
|
5389
|
+ #else
|
|
5390
|
+ #error "ERROR - probe pin not defined - strange, SANITY_CHECK should have caught this"
|
|
5391
|
+ #endif
|
|
5392
|
+ SERIAL_PROTOCOLLNPGM(". deploy & stow 4 times");
|
|
5393
|
+ pinMode(PROBE_TEST_PIN, INPUT_PULLUP);
|
|
5394
|
+ bool deploy_state;
|
|
5395
|
+ bool stow_state;
|
|
5396
|
+ for (uint8_t i = 0; i < 4; i++) {
|
|
5397
|
+ servo[probe_index].move(z_servo_angle[0]); //deploy
|
|
5398
|
+ safe_delay(500);
|
|
5399
|
+ deploy_state = digitalRead(PROBE_TEST_PIN);
|
|
5400
|
+ servo[probe_index].move(z_servo_angle[1]); //stow
|
|
5401
|
+ safe_delay(500);
|
|
5402
|
+ stow_state = digitalRead(PROBE_TEST_PIN);
|
|
5403
|
+ }
|
|
5404
|
+ if (probe_inverting != deploy_state) SERIAL_PROTOCOLLNPGM("WARNING - INVERTING setting probably backwards");
|
|
5405
|
+ refresh_cmd_timeout();
|
|
5406
|
+ if (deploy_state != stow_state) {
|
|
5407
|
+ SERIAL_PROTOCOLLNPGM("TLTouch detected"); // BLTouch clone?
|
|
5408
|
+ if (deploy_state) {
|
|
5409
|
+ SERIAL_PROTOCOLLNPGM(". DEPLOYED state: HIGH (logic 1)");
|
|
5410
|
+ SERIAL_PROTOCOLLNPGM(". STOWED (triggered) state: LOW (logic 0)");
|
|
5411
|
+ }
|
|
5412
|
+ else {
|
|
5413
|
+ SERIAL_PROTOCOLLNPGM(". DEPLOYED state: LOW (logic 0)");
|
|
5414
|
+ SERIAL_PROTOCOLLNPGM(". STOWED (triggered) state: HIGH (logic 1)");
|
|
5415
|
+ }
|
|
5416
|
+ }
|
|
5417
|
+ else { // measure active signal length
|
|
5418
|
+ servo[probe_index].move(z_servo_angle[0]); //deploy
|
|
5419
|
+ safe_delay(500);
|
|
5420
|
+ SERIAL_PROTOCOLLNPGM("please trigger probe");
|
|
5421
|
+ uint16_t probe_counter = 0;
|
|
5422
|
+ for (uint16_t j = 0; j < 500*30 && probe_counter == 0 ; j++) { // allow 30 seconds max for operator to trigger probe
|
|
5423
|
+ safe_delay(2);
|
|
5424
|
+ if ( 0 == j%(500*1)) {refresh_cmd_timeout(); watchdog_reset();} // beat the dog every 45 seconds
|
|
5425
|
+ if (deploy_state != digitalRead(PROBE_TEST_PIN)) { // probe triggered
|
|
5426
|
+ for (probe_counter = 1; probe_counter < 50 && (deploy_state != digitalRead(PROBE_TEST_PIN)); probe_counter ++) {
|
|
5427
|
+ safe_delay(2);
|
|
5428
|
+ }
|
|
5429
|
+ if (probe_counter == 50) {
|
|
5430
|
+ SERIAL_PROTOCOLLNPGM("Z Servo Probe detected"); // >= 100mS active time
|
|
5431
|
+ }
|
|
5432
|
+ else if (probe_counter >= 2 ) {
|
|
5433
|
+ SERIAL_PROTOCOLLNPAIR("BLTouch compatible probe detected - pulse width (+/- 4mS): ", probe_counter * 2 ); // allow 4 - 100mS pulse
|
|
5434
|
+ }
|
|
5435
|
+ else {
|
|
5436
|
+ SERIAL_PROTOCOLLNPGM("noise detected - please re-run test"); // less than 2mS pulse
|
|
5437
|
+ }
|
|
5438
|
+ servo[probe_index].move(z_servo_angle[1]); //stow
|
|
5439
|
+ } // pulse detected
|
|
5440
|
+ } // for loop waiting for trigger
|
|
5441
|
+ if (probe_counter == 0) SERIAL_PROTOCOLLNPGM("trigger not detected");
|
|
5442
|
+ } // measure active signal length
|
|
5443
|
+ #endif
|
|
5444
|
+ } // servo_probe_test
|
|
5445
|
+
|
5311
|
5446
|
/**
|
5312
|
|
- * M43: Pin report and debug
|
|
5447
|
+ * M43: Pin debug - report pin state, watch pins, toggle pins and servo probe test/report
|
|
5448
|
+ *
|
|
5449
|
+ * M43 - report name and state of pin(s)
|
|
5450
|
+ * P<pin> Pin to read or watch. If omitted, reads all pins.
|
|
5451
|
+ * I Flag to ignore Marlin's pin protection.
|
5313
|
5452
|
*
|
5314
|
|
- * E<bool> Enable / disable background endstop monitoring
|
5315
|
|
- * - Machine continues to operate
|
5316
|
|
- * - Reports changes to endstops
|
5317
|
|
- * - Toggles LED when an endstop changes
|
|
5453
|
+ * M43 W - Watch pins -reporting changes- until reset, click, or M108.
|
|
5454
|
+ * P<pin> Pin to read or watch. If omitted, read/watch all pins.
|
|
5455
|
+ * I Flag to ignore Marlin's pin protection.
|
5318
|
5456
|
*
|
5319
|
|
- * or
|
|
5457
|
+ * M43 E<bool> - Enable / disable background endstop monitoring
|
|
5458
|
+ * - Machine continues to operate
|
|
5459
|
+ * - Reports changes to endstops
|
|
5460
|
+ * - Toggles LED when an endstop changes
|
|
5461
|
+ * - Can not reliably catch the 5mS pulse from BLTouch type probes
|
5320
|
5462
|
*
|
5321
|
|
- * P<pin> Pin to read or watch. If omitted, read/watch all pins.
|
5322
|
|
- * W<bool> Watch pins -reporting changes- until reset, click, or M108.
|
5323
|
|
- * I<bool> Flag to ignore Marlin's pin protection.
|
|
5463
|
+ * M43 T - Toggle pin(s) and report which pin is being toggled
|
|
5464
|
+ * S<pin> - Start Pin number. If not given, will default to 0
|
|
5465
|
+ * L<pin> - End Pin number. If not given, will default to last pin defined for this board
|
|
5466
|
+ * I - Flag to ignore Marlin's pin protection. Use with caution!!!!
|
|
5467
|
+ * R - Repeat pulses on each pin this number of times before continueing to next pin
|
|
5468
|
+ * W - Wait time (in miliseconds) between pulses. If not given will default to 500
|
5324
|
5469
|
*
|
|
5470
|
+ * M43 S - Servo probe test
|
|
5471
|
+ * P<index> - Probe index (optional - defaults to 0
|
5325
|
5472
|
*/
|
|
5473
|
+
|
5326
|
5474
|
inline void gcode_M43() {
|
5327
|
5475
|
|
|
5476
|
+ if (code_seen('T')) { // must be first ot else it's "S" and "E" parameters will execute endstop or servo test
|
|
5477
|
+ toggle_pins();
|
|
5478
|
+ return;
|
|
5479
|
+ }
|
|
5480
|
+
|
5328
|
5481
|
// Enable or disable endstop monitoring
|
5329
|
5482
|
if (code_seen('E')) {
|
5330
|
5483
|
endstop_monitor_flag = code_value_bool();
|
|
@@ -5334,6 +5487,12 @@ inline void gcode_M42() {
|
5334
|
5487
|
return;
|
5335
|
5488
|
}
|
5336
|
5489
|
|
|
5490
|
+ if (code_seen('S')) {
|
|
5491
|
+ servo_probe_test();
|
|
5492
|
+ return;
|
|
5493
|
+ }
|
|
5494
|
+
|
|
5495
|
+
|
5337
|
5496
|
// Get the range of pins to test or watch
|
5338
|
5497
|
int first_pin = 0, last_pin = NUM_DIGITAL_PINS - 1;
|
5339
|
5498
|
if (code_seen('P')) {
|
|
@@ -5341,10 +5500,11 @@ inline void gcode_M42() {
|
5341
|
5500
|
if (first_pin > NUM_DIGITAL_PINS - 1) return;
|
5342
|
5501
|
}
|
5343
|
5502
|
|
5344
|
|
- const bool ignore_protection = code_seen('I') ? code_value_bool() : false;
|
|
5503
|
+ bool ignore_protection = code_seen('I');
|
5345
|
5504
|
|
5346
|
5505
|
// Watch until click, M108, or reset
|
5347
|
|
- if (code_seen('W') && code_value_bool()) { // watch digital pins
|
|
5506
|
+ if (code_seen('W')) { // watch digital pins
|
|
5507
|
+ SERIAL_PROTOCOLLNPGM("Watching pins");
|
5348
|
5508
|
byte pin_state[last_pin - first_pin + 1];
|
5349
|
5509
|
for (int8_t pin = first_pin; pin <= last_pin; pin++) {
|
5350
|
5510
|
if (pin_is_protected(pin) && !ignore_protection) continue;
|
|
@@ -5387,6 +5547,7 @@ inline void gcode_M42() {
|
5387
|
5547
|
report_pin_state_extended(pin, ignore_protection);
|
5388
|
5548
|
}
|
5389
|
5549
|
|
|
5550
|
+
|
5390
|
5551
|
#endif // PINS_DEBUGGING
|
5391
|
5552
|
|
5392
|
5553
|
#if ENABLED(Z_MIN_PROBE_REPEATABILITY_TEST)
|