From dba521a9fbf19138ded3edcd4f8cab0e3b2ff50a Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Sun, 14 May 2023 18:32:59 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=91=E2=80=8D=F0=9F=92=BB=20M43=20updat?= =?UTF-8?q?es?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Marlin/src/gcode/config/M43.cpp | 6 +++--- Marlin/src/pins/pinsDebug.h | 20 ++++++++++++-------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/Marlin/src/gcode/config/M43.cpp b/Marlin/src/gcode/config/M43.cpp index b19fe715f6e8..460e25dde272 100644 --- a/Marlin/src/gcode/config/M43.cpp +++ b/Marlin/src/gcode/config/M43.cpp @@ -380,7 +380,7 @@ void GcodeSuite::M43() { for (;;) { LOOP_S_LE_N(i, first_pin, last_pin) { - pin_t pin = GET_PIN_MAP_PIN_M43(i); + const pin_t pin = GET_PIN_MAP_PIN_M43(i); if (!VALID_PIN(pin)) continue; if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue; const byte val = @@ -391,7 +391,7 @@ void GcodeSuite::M43() { //*/ extDigitalRead(pin); if (val != pin_state[i - first_pin]) { - report_pin_state_extended(pin, ignore_protection, false); + report_pin_state_extended(pin, ignore_protection, true); pin_state[i - first_pin] = val; } } @@ -409,7 +409,7 @@ void GcodeSuite::M43() { else { // Report current state of selected pin(s) LOOP_S_LE_N(i, first_pin, last_pin) { - pin_t pin = GET_PIN_MAP_PIN_M43(i); + const pin_t pin = GET_PIN_MAP_PIN_M43(i); if (VALID_PIN(pin)) report_pin_state_extended(pin, ignore_protection, true); } } diff --git a/Marlin/src/pins/pinsDebug.h b/Marlin/src/pins/pinsDebug.h index 25b883eee67c..56e1039c4eed 100644 --- a/Marlin/src/pins/pinsDebug.h +++ b/Marlin/src/pins/pinsDebug.h @@ -175,11 +175,15 @@ const PinInfo pin_array[] PROGMEM = { #endif static void print_input_or_output(const bool isout) { - SERIAL_ECHOPGM_P(isout ? PSTR("Output = ") : PSTR("Input = ")); + SERIAL_ECHOF(isout ? F("Output ") : F("Input ")); +} + +static void print_pin_state(const bool state) { + SERIAL_ECHOF(state ? F("HIGH") : F("LOW")); } // pretty report with PWM info -inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool extended=false, FSTR_P const start_string=nullptr) { +inline void report_pin_state_extended(const pin_t pin, const bool ignore, const bool extended=false, FSTR_P const start_string=nullptr) { char buffer[MAX_NAME_LENGTH + 1]; // for the sprintf statements bool found = false, multi_name_pin = false; @@ -188,12 +192,12 @@ inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool e // Use FastIO for pins Teensy doesn't expose if (pin == 46) { print_input_or_output(IS_OUTPUT(46)); - SERIAL_CHAR('0' + READ(46)); + print_pin_state(READ(46)); return false; } else if (pin == 47) { print_input_or_output(IS_OUTPUT(47)); - SERIAL_CHAR('0' + READ(47)); + print_pin_state(READ(47)); return false; } #endif @@ -230,14 +234,14 @@ inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool e // because this could interfere with inductive/capacitive // sensors (high impedance voltage divider) and with Pt100 amplifier print_input_or_output(false); - SERIAL_ECHO(digitalRead_mod(pin)); + print_pin_state(digitalRead_mod(pin)); } else if (pwm_status(pin)) { // do nothing } else { print_input_or_output(true); - SERIAL_ECHO(digitalRead_mod(pin)); + print_pin_state(digitalRead_mod(pin)); } } if (!multi_name_pin && extended) pwm_details(pin); // report PWM capabilities only on the first pass & only if doing an extended report @@ -267,7 +271,7 @@ inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool e else if (GET_PINMODE(pin)) { SERIAL_ECHO_SP(MAX_NAME_LENGTH - 16); print_input_or_output(true); - SERIAL_ECHO(digitalRead_mod(pin)); + print_pin_state(digitalRead_mod(pin)); } else { if (IS_ANALOG(pin)) { @@ -279,7 +283,7 @@ inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool e SERIAL_ECHO_SP(MAX_NAME_LENGTH - 16); // add padding if not an analog pin print_input_or_output(false); - SERIAL_ECHO(digitalRead_mod(pin)); + print_pin_state(digitalRead_mod(pin)); } //if (!pwm_status(pin)) SERIAL_CHAR(' '); // add padding if it's not a PWM pin if (extended) {