🧑💻 M43 updates
This commit is contained in:
@ -380,7 +380,7 @@ void GcodeSuite::M43() {
|
|||||||
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
LOOP_S_LE_N(i, first_pin, last_pin) {
|
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 (!VALID_PIN(pin)) continue;
|
||||||
if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue;
|
if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue;
|
||||||
const byte val =
|
const byte val =
|
||||||
@ -391,7 +391,7 @@ void GcodeSuite::M43() {
|
|||||||
//*/
|
//*/
|
||||||
extDigitalRead(pin);
|
extDigitalRead(pin);
|
||||||
if (val != pin_state[i - first_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;
|
pin_state[i - first_pin] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -409,7 +409,7 @@ void GcodeSuite::M43() {
|
|||||||
else {
|
else {
|
||||||
// Report current state of selected pin(s)
|
// Report current state of selected pin(s)
|
||||||
LOOP_S_LE_N(i, first_pin, last_pin) {
|
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);
|
if (VALID_PIN(pin)) report_pin_state_extended(pin, ignore_protection, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -175,11 +175,15 @@ const PinInfo pin_array[] PROGMEM = {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void print_input_or_output(const bool isout) {
|
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
|
// 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
|
char buffer[MAX_NAME_LENGTH + 1]; // for the sprintf statements
|
||||||
bool found = false, multi_name_pin = false;
|
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
|
// Use FastIO for pins Teensy doesn't expose
|
||||||
if (pin == 46) {
|
if (pin == 46) {
|
||||||
print_input_or_output(IS_OUTPUT(46));
|
print_input_or_output(IS_OUTPUT(46));
|
||||||
SERIAL_CHAR('0' + READ(46));
|
print_pin_state(READ(46));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (pin == 47) {
|
else if (pin == 47) {
|
||||||
print_input_or_output(IS_OUTPUT(47));
|
print_input_or_output(IS_OUTPUT(47));
|
||||||
SERIAL_CHAR('0' + READ(47));
|
print_pin_state(READ(47));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#endif
|
#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
|
// because this could interfere with inductive/capacitive
|
||||||
// sensors (high impedance voltage divider) and with Pt100 amplifier
|
// sensors (high impedance voltage divider) and with Pt100 amplifier
|
||||||
print_input_or_output(false);
|
print_input_or_output(false);
|
||||||
SERIAL_ECHO(digitalRead_mod(pin));
|
print_pin_state(digitalRead_mod(pin));
|
||||||
}
|
}
|
||||||
else if (pwm_status(pin)) {
|
else if (pwm_status(pin)) {
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
print_input_or_output(true);
|
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
|
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)) {
|
else if (GET_PINMODE(pin)) {
|
||||||
SERIAL_ECHO_SP(MAX_NAME_LENGTH - 16);
|
SERIAL_ECHO_SP(MAX_NAME_LENGTH - 16);
|
||||||
print_input_or_output(true);
|
print_input_or_output(true);
|
||||||
SERIAL_ECHO(digitalRead_mod(pin));
|
print_pin_state(digitalRead_mod(pin));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (IS_ANALOG(pin)) {
|
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
|
SERIAL_ECHO_SP(MAX_NAME_LENGTH - 16); // add padding if not an analog pin
|
||||||
|
|
||||||
print_input_or_output(false);
|
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 (!pwm_status(pin)) SERIAL_CHAR(' '); // add padding if it's not a PWM pin
|
||||||
if (extended) {
|
if (extended) {
|
||||||
|
Reference in New Issue
Block a user