Merge upstream changes from Marlin 2.1.2.1

This commit is contained in:
Stefan Kalscheuer
2023-05-26 18:48:34 +02:00
parent 22dedaeb81
commit f92a587638
620 changed files with 41015 additions and 28889 deletions

View File

@@ -313,7 +313,7 @@ void GcodeSuite::M43() {
// 'P' Get the range of pins to test or watch
uint8_t first_pin = PARSED_PIN_INDEX('P', 0),
last_pin = parser.seenval('L') ? PARSED_PIN_INDEX('L', 0) : parser.seenval('P') ? first_pin : (NUMBER_PINS_TOTAL) - 1;
last_pin = parser.seenval('L') ? PARSED_PIN_INDEX('L', 0) : (parser.seenval('P') ? first_pin : (NUMBER_PINS_TOTAL) - 1);
NOMORE(first_pin, (NUMBER_PINS_TOTAL) - 1);
NOMORE(last_pin, (NUMBER_PINS_TOTAL) - 1);
@@ -329,15 +329,18 @@ void GcodeSuite::M43() {
// 'W' Watch until click, M108, or reset
if (parser.boolval('W')) {
SERIAL_ECHOLNPGM("Watching pins");
#ifdef ARDUINO_ARCH_SAM
NOLESS(first_pin, 2); // Don't hijack the UART pins
#endif
uint8_t pin_state[last_pin - first_pin + 1];
const uint8_t pin_count = last_pin - first_pin + 1;
uint8_t pin_state[pin_count];
bool can_watch = false;
LOOP_S_LE_N(i, first_pin, last_pin) {
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;
can_watch = true;
pinMode(pin, INPUT_PULLUP);
delay(1);
/*
@@ -348,16 +351,36 @@ void GcodeSuite::M43() {
pin_state[i - first_pin] = extDigitalRead(pin);
}
const bool multipin = (pin_count > 1);
if (!can_watch) {
SERIAL_ECHOPGM("Specified pin");
SERIAL_ECHOPGM_P(multipin ? PSTR("s are") : PSTR(" is"));
SERIAL_ECHOLNPGM(" protected. Use 'I' to override.");
return;
}
// "Watching pin(s) # - #"
SERIAL_ECHOPGM("Watching pin");
if (multipin) SERIAL_CHAR('s');
SERIAL_CHAR(' '); SERIAL_ECHO(first_pin);
if (multipin) SERIAL_ECHOPGM(" - ", last_pin);
SERIAL_EOL();
#if HAS_RESUME_CONTINUE
KEEPALIVE_STATE(PAUSED_FOR_USER);
wait_for_user = true;
TERN_(HOST_PROMPT_SUPPORT, hostui.prompt_do(PROMPT_USER_CONTINUE, F("M43 Wait Called"), FPSTR(CONTINUE_STR)));
TERN_(EXTENSIBLE_UI, ExtUI::onUserConfirmRequired(F("M43 Wait Called")));
TERN_(HOST_PROMPT_SUPPORT, hostui.continue_prompt(F("M43 Waiting...")));
#if ENABLED(EXTENSIBLE_UI)
ExtUI::onUserConfirmRequired(F("M43 Waiting..."));
#else
LCD_MESSAGE(MSG_USERWAIT);
#endif
#endif
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 =
@@ -368,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;
}
}
@@ -380,11 +403,13 @@ void GcodeSuite::M43() {
safe_delay(200);
}
TERN_(HAS_RESUME_CONTINUE, ui.reset_status());
}
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);
}
}