Merge pull request #5118 from thinkyhead/rc_expanded_M43
Enhancements to M43 pins debugging
This commit is contained in:
commit
fa6bf12697
|
@ -148,6 +148,7 @@
|
|||
* The '#' is necessary when calling from within sd files, as it stops buffer prereading
|
||||
* M33 - Get the longname version of a path. (Requires LONG_FILENAME_HOST_SUPPORT)
|
||||
* M42 - Change pin status via gcode: M42 P<pin> S<value>. LED pin assumed if P is omitted.
|
||||
* M43 - Monitor pins & report changes - report active pins
|
||||
* M48 - Measure Z Probe repeatability: M48 P<points> X<pos> Y<pos> V<level> E<engage> L<legs>. (Requires Z_MIN_PROBE_REPEATABILITY_TEST)
|
||||
* M75 - Start the print job timer.
|
||||
* M76 - Pause the print job timer.
|
||||
|
@ -4675,20 +4676,43 @@ inline void gcode_M42() {
|
|||
/**
|
||||
* M43: Pin report and debug
|
||||
*
|
||||
* P<pin> Will read/watch a single pin
|
||||
* W Watch pins for changes until reboot
|
||||
* E<bool> Enable / disable background endstop monitoring
|
||||
* - Machine continues to operate
|
||||
* - Reports changes to endstops
|
||||
* - Toggles LED when an endstop changes
|
||||
*
|
||||
* or
|
||||
*
|
||||
* P<pin> Pin to read or watch. If omitted, read/watch all pins.
|
||||
* W<bool> Watch pins -reporting changes- until reset, click, or M108.
|
||||
* I<bool> Flag to ignore Marlin's pin protection.
|
||||
*
|
||||
*/
|
||||
inline void gcode_M43() {
|
||||
int first_pin = 0, last_pin = DIO_COUNT - 1;
|
||||
if (code_seen('P')) {
|
||||
first_pin = last_pin = code_value_byte();
|
||||
if (first_pin > DIO_COUNT - 1) return;
|
||||
|
||||
// Enable or disable endstop monitoring
|
||||
if (code_seen('E')) {
|
||||
endstop_monitor_flag = code_value_bool();
|
||||
SERIAL_PROTOCOLPGM("endstop monitor ");
|
||||
SERIAL_PROTOCOL(endstop_monitor_flag ? "en" : "dis");
|
||||
SERIAL_PROTOCOLLNPGM("abled");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get the range of pins to test or watch
|
||||
int first_pin = 0, last_pin = NUM_DIGITAL_PINS - 1;
|
||||
if (code_seen('P')) {
|
||||
first_pin = last_pin = code_value_byte();
|
||||
if (first_pin > NUM_DIGITAL_PINS - 1) return;
|
||||
}
|
||||
|
||||
bool ignore_protection = code_seen('I') ? code_value_bool() : false;
|
||||
|
||||
// Watch until click, M108, or reset
|
||||
if (code_seen('W') && code_value_bool()) { // watch digital pins
|
||||
byte pin_state[last_pin - first_pin + 1];
|
||||
for (int8_t pin = first_pin; pin <= last_pin; pin++) {
|
||||
if (pin_is_protected(pin)) continue;
|
||||
if (pin_is_protected(pin) && !ignore_protection) continue;
|
||||
pinMode(pin, INPUT_PULLUP);
|
||||
// if (IS_ANALOG(pin))
|
||||
// pin_state[pin - first_pin] = analogRead(pin - analogInputToDigitalPin(0)); // int16_t pin_state[...]
|
||||
|
@ -4720,10 +4744,12 @@ inline void gcode_M42() {
|
|||
|
||||
safe_delay(500);
|
||||
}
|
||||
return;
|
||||
}
|
||||
else // single pins report
|
||||
for (int8_t pin = first_pin; pin <= last_pin; pin++)
|
||||
report_pin_state(pin);
|
||||
|
||||
// Report current state of selected pin(s)
|
||||
for (uint8_t pin = first_pin; pin <= last_pin; pin++)
|
||||
report_pin_state_extended(pin, ignore_protection);
|
||||
}
|
||||
|
||||
#endif // PINS_DEBUGGING
|
||||
|
|
1125
Marlin/pinsDebug.h
1125
Marlin/pinsDebug.h
File diff suppressed because it is too large
Load diff
|
@ -115,8 +115,8 @@
|
|||
#define HEATER_BED_PIN 3
|
||||
|
||||
#define FAN_PIN 8
|
||||
#define FAN0_PIN 6
|
||||
#define FAN1_PIN 2
|
||||
#define FAN1_PIN 6
|
||||
#define FAN2_PIN 2
|
||||
|
||||
//
|
||||
// Misc. Functions
|
||||
|
|
|
@ -1393,6 +1393,87 @@ void Temperature::set_current_temp_raw() {
|
|||
temp_meas_ready = true;
|
||||
}
|
||||
|
||||
#if ENABLED(PINS_DEBUGGING)
|
||||
/**
|
||||
* monitors endstops & Z probe for changes
|
||||
*
|
||||
* If a change is detected then the LED is toggled and
|
||||
* a message is sent out the serial port
|
||||
*
|
||||
* Yes, we could miss a rapid back & forth change but
|
||||
* that won't matter because this is all manual.
|
||||
*
|
||||
*/
|
||||
void endstop_monitor() {
|
||||
static uint16_t old_endstop_bits_local = 0;
|
||||
static uint8_t local_LED_status = 0;
|
||||
uint16_t current_endstop_bits_local = 0;
|
||||
#if HAS_X_MIN
|
||||
if (READ(X_MIN_PIN)) SBI(current_endstop_bits_local, X_MIN);
|
||||
#endif
|
||||
#if HAS_X_MAX
|
||||
if (READ(X_MAX_PIN)) SBI(current_endstop_bits_local, X_MAX);
|
||||
#endif
|
||||
#if HAS_Y_MIN
|
||||
if (READ(Y_MIN_PIN)) SBI(current_endstop_bits_local, Y_MIN);
|
||||
#endif
|
||||
#if HAS_Y_MAX
|
||||
if (READ(Y_MAX_PIN)) SBI(current_endstop_bits_local, Y_MAX);
|
||||
#endif
|
||||
#if HAS_Z_MIN
|
||||
if (READ(Z_MIN_PIN)) SBI(current_endstop_bits_local, Z_MIN);
|
||||
#endif
|
||||
#if HAS_Z_MAX
|
||||
if (READ(Z_MAX_PIN)) SBI(current_endstop_bits_local, Z_MAX);
|
||||
#endif
|
||||
#if HAS_Z_MIN_PROBE_PIN
|
||||
if (READ(Z_MIN_PROBE_PIN)) SBI(current_endstop_bits_local, Z_MIN_PROBE);
|
||||
#endif
|
||||
#if HAS_Z2_MIN
|
||||
if (READ(Z2_MIN_PIN)) SBI(current_endstop_bits_local, Z2_MIN);
|
||||
#endif
|
||||
#if HAS_Z2_MAX
|
||||
if (READ(Z2_MAX_PIN)) SBI(current_endstop_bits_local, Z2_MAX);
|
||||
#endif
|
||||
|
||||
uint16_t endstop_change = current_endstop_bits_local ^ old_endstop_bits_local;
|
||||
|
||||
if (endstop_change) {
|
||||
#if HAS_X_MIN
|
||||
if (TEST(endstop_change, X_MIN)) SERIAL_PROTOCOLPAIR("X_MIN:", !!TEST(current_endstop_bits_local, X_MIN));
|
||||
#endif
|
||||
#if HAS_X_MAX
|
||||
if (TEST(endstop_change, X_MAX)) SERIAL_PROTOCOLPAIR(" X_MAX:", !!TEST(current_endstop_bits_local, X_MAX));
|
||||
#endif
|
||||
#if HAS_Y_MIN
|
||||
if (TEST(endstop_change, Y_MIN)) SERIAL_PROTOCOLPAIR(" Y_MIN:", !!TEST(current_endstop_bits_local, Y_MIN));
|
||||
#endif
|
||||
#if HAS_Y_MAX
|
||||
if (TEST(endstop_change, Y_MAX)) SERIAL_PROTOCOLPAIR(" Y_MAX:", !!TEST(current_endstop_bits_local, Y_MAX));
|
||||
#endif
|
||||
#if HAS_Z_MIN
|
||||
if (TEST(endstop_change, Z_MIN)) SERIAL_PROTOCOLPAIR(" Z_MIN:", !!TEST(current_endstop_bits_local, Z_MIN));
|
||||
#endif
|
||||
#if HAS_Z_MAX
|
||||
if (TEST(endstop_change, Z_MAX)) SERIAL_PROTOCOLPAIR(" Z_MAX:", !!TEST(current_endstop_bits_local, Z_MAX));
|
||||
#endif
|
||||
#if HAS_Z_MIN_PROBE_PIN
|
||||
if (TEST(endstop_change, Z_MIN_PROBE)) SERIAL_PROTOCOLPAIR(" PROBE:", !!TEST(current_endstop_bits_local, Z_MIN_PROBE));
|
||||
#endif
|
||||
#if HAS_Z2_MIN
|
||||
if (TEST(endstop_change, Z2_MIN)) SERIAL_PROTOCOLPAIR(" Z2_MIN:", !!TEST(current_endstop_bits_local, Z2_MIN));
|
||||
#endif
|
||||
#if HAS_Z2_MAX
|
||||
if (TEST(endstop_change, Z2_MAX)) SERIAL_PROTOCOLPAIR(" Z2_MAX:", !!TEST(current_endstop_bits_local, Z2_MAX));
|
||||
#endif
|
||||
SERIAL_PROTOCOLPGM("\n\n");
|
||||
analogWrite(LED_PIN, local_LED_status);
|
||||
local_LED_status ^= 255;
|
||||
old_endstop_bits_local = current_endstop_bits_local;
|
||||
}
|
||||
}
|
||||
#endif // PINS_DEBUGGING
|
||||
|
||||
/**
|
||||
* Timer 0 is shared with millies so don't change the prescaler.
|
||||
*
|
||||
|
@ -1848,4 +1929,15 @@ void Temperature::isr() {
|
|||
}
|
||||
}
|
||||
#endif //BABYSTEPPING
|
||||
|
||||
#if ENABLED(PINS_DEBUGGING)
|
||||
extern bool endstop_monitor_flag;
|
||||
// run the endstop monitor at 15Hz
|
||||
static uint8_t endstop_monitor_count = 16; // offset this check from the others
|
||||
if (endstop_monitor_flag) {
|
||||
endstop_monitor_count += _BV(1); // 15 Hz
|
||||
endstop_monitor_count &= 0x7F;
|
||||
if (!endstop_monitor_count) endstop_monitor(); // report changes in endstop status
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue