🧑💻 M43 updates
This commit is contained in:
parent
50ad323567
commit
dba521a9fb
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user