Skip to content

Commit dba521a

Browse files
committed
πŸ§‘β€πŸ’» M43 updates
1 parent 50ad323 commit dba521a

File tree

2 files changed

+15
-11
lines changed

2 files changed

+15
-11
lines changed

β€ŽMarlin/src/gcode/config/M43.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ void GcodeSuite::M43() {
380380

381381
for (;;) {
382382
LOOP_S_LE_N(i, first_pin, last_pin) {
383-
pin_t pin = GET_PIN_MAP_PIN_M43(i);
383+
const pin_t pin = GET_PIN_MAP_PIN_M43(i);
384384
if (!VALID_PIN(pin)) continue;
385385
if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue;
386386
const byte val =
@@ -391,7 +391,7 @@ void GcodeSuite::M43() {
391391
//*/
392392
extDigitalRead(pin);
393393
if (val != pin_state[i - first_pin]) {
394-
report_pin_state_extended(pin, ignore_protection, false);
394+
report_pin_state_extended(pin, ignore_protection, true);
395395
pin_state[i - first_pin] = val;
396396
}
397397
}
@@ -409,7 +409,7 @@ void GcodeSuite::M43() {
409409
else {
410410
// Report current state of selected pin(s)
411411
LOOP_S_LE_N(i, first_pin, last_pin) {
412-
pin_t pin = GET_PIN_MAP_PIN_M43(i);
412+
const pin_t pin = GET_PIN_MAP_PIN_M43(i);
413413
if (VALID_PIN(pin)) report_pin_state_extended(pin, ignore_protection, true);
414414
}
415415
}

β€ŽMarlin/src/pins/pinsDebug.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,15 @@ const PinInfo pin_array[] PROGMEM = {
175175
#endif
176176

177177
static void print_input_or_output(const bool isout) {
178-
SERIAL_ECHOPGM_P(isout ? PSTR("Output = ") : PSTR("Input = "));
178+
SERIAL_ECHOF(isout ? F("Output ") : F("Input "));
179+
}
180+
181+
static void print_pin_state(const bool state) {
182+
SERIAL_ECHOF(state ? F("HIGH") : F("LOW"));
179183
}
180184

181185
// pretty report with PWM info
182-
inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool extended=false, FSTR_P const start_string=nullptr) {
186+
inline void report_pin_state_extended(const pin_t pin, const bool ignore, const bool extended=false, FSTR_P const start_string=nullptr) {
183187
char buffer[MAX_NAME_LENGTH + 1]; // for the sprintf statements
184188
bool found = false, multi_name_pin = false;
185189

@@ -188,12 +192,12 @@ inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool e
188192
// Use FastIO for pins Teensy doesn't expose
189193
if (pin == 46) {
190194
print_input_or_output(IS_OUTPUT(46));
191-
SERIAL_CHAR('0' + READ(46));
195+
print_pin_state(READ(46));
192196
return false;
193197
}
194198
else if (pin == 47) {
195199
print_input_or_output(IS_OUTPUT(47));
196-
SERIAL_CHAR('0' + READ(47));
200+
print_pin_state(READ(47));
197201
return false;
198202
}
199203
#endif
@@ -230,14 +234,14 @@ inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool e
230234
// because this could interfere with inductive/capacitive
231235
// sensors (high impedance voltage divider) and with Pt100 amplifier
232236
print_input_or_output(false);
233-
SERIAL_ECHO(digitalRead_mod(pin));
237+
print_pin_state(digitalRead_mod(pin));
234238
}
235239
else if (pwm_status(pin)) {
236240
// do nothing
237241
}
238242
else {
239243
print_input_or_output(true);
240-
SERIAL_ECHO(digitalRead_mod(pin));
244+
print_pin_state(digitalRead_mod(pin));
241245
}
242246
}
243247
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
267271
else if (GET_PINMODE(pin)) {
268272
SERIAL_ECHO_SP(MAX_NAME_LENGTH - 16);
269273
print_input_or_output(true);
270-
SERIAL_ECHO(digitalRead_mod(pin));
274+
print_pin_state(digitalRead_mod(pin));
271275
}
272276
else {
273277
if (IS_ANALOG(pin)) {
@@ -279,7 +283,7 @@ inline void report_pin_state_extended(pin_t pin, const bool ignore, const bool e
279283
SERIAL_ECHO_SP(MAX_NAME_LENGTH - 16); // add padding if not an analog pin
280284

281285
print_input_or_output(false);
282-
SERIAL_ECHO(digitalRead_mod(pin));
286+
print_pin_state(digitalRead_mod(pin));
283287
}
284288
//if (!pwm_status(pin)) SERIAL_CHAR(' '); // add padding if it's not a PWM pin
285289
if (extended) {

0 commit comments

Comments
Β (0)