2017-09-06 13:28:31 +02:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2017-09-06 13:28:31 +02:00
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
2019-06-28 06:57:50 +02:00
|
|
|
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
|
2017-09-06 13:28:31 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-09-16 11:06:28 +02:00
|
|
|
#include "../../inc/MarlinConfig.h"
|
|
|
|
|
|
|
|
#if ENABLED(PINS_DEBUGGING)
|
2017-09-08 05:33:16 +02:00
|
|
|
|
2017-09-16 11:06:28 +02:00
|
|
|
#include "../gcode.h"
|
|
|
|
#include "../../Marlin.h" // for pin_is_protected
|
2017-09-06 13:28:31 +02:00
|
|
|
#include "../../pins/pinsDebug.h"
|
2017-09-16 11:06:28 +02:00
|
|
|
#include "../../module/endstops.h"
|
|
|
|
|
2018-04-02 06:54:12 +02:00
|
|
|
#if HAS_Z_SERVO_PROBE
|
2017-09-16 11:06:28 +02:00
|
|
|
#include "../../module/probe.h"
|
2017-11-19 20:39:46 +01:00
|
|
|
#include "../../module/servo.h"
|
2017-09-16 11:06:28 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
#if ENABLED(BLTOUCH)
|
|
|
|
#include "../../feature/bltouch.h"
|
|
|
|
#endif
|
|
|
|
|
2019-02-12 22:55:47 +01:00
|
|
|
#if ENABLED(HOST_PROMPT_SUPPORT)
|
|
|
|
#include "../../feature/host_actions.h"
|
|
|
|
#endif
|
|
|
|
|
2019-08-19 04:03:26 +02:00
|
|
|
#if ENABLED(EXTENSIBLE_UI)
|
|
|
|
#include "../../lcd/extensible_ui/ui_api.h"
|
|
|
|
#endif
|
|
|
|
|
2019-07-06 05:08:06 +02:00
|
|
|
#ifndef GET_PIN_MAP_PIN_M43
|
|
|
|
#define GET_PIN_MAP_PIN_M43(Q) GET_PIN_MAP_PIN(Q)
|
|
|
|
#endif
|
|
|
|
|
2017-09-06 13:28:31 +02:00
|
|
|
inline void toggle_pins() {
|
2018-06-11 00:45:39 +02:00
|
|
|
const bool ignore_protection = parser.boolval('I');
|
2017-09-06 13:28:31 +02:00
|
|
|
const int repeat = parser.intval('R', 1),
|
2017-10-26 20:37:26 +02:00
|
|
|
start = PARSED_PIN_INDEX('S', 0),
|
2018-11-05 04:24:56 +01:00
|
|
|
end = PARSED_PIN_INDEX('L', NUM_DIGITAL_PINS - 1),
|
2017-09-06 13:28:31 +02:00
|
|
|
wait = parser.intval('W', 500);
|
|
|
|
|
2017-10-26 20:37:26 +02:00
|
|
|
for (uint8_t i = start; i <= end; i++) {
|
2019-07-06 05:08:06 +02:00
|
|
|
pin_t pin = GET_PIN_MAP_PIN_M43(i);
|
2017-09-06 13:28:31 +02:00
|
|
|
if (!VALID_PIN(pin)) continue;
|
2019-04-07 01:06:07 +02:00
|
|
|
if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) {
|
2018-06-11 00:45:39 +02:00
|
|
|
report_pin_state_extended(pin, ignore_protection, true, "Untouched ");
|
2017-09-06 13:28:31 +02:00
|
|
|
SERIAL_EOL();
|
|
|
|
}
|
|
|
|
else {
|
2019-04-07 01:06:07 +02:00
|
|
|
watchdog_reset();
|
2018-06-11 00:45:39 +02:00
|
|
|
report_pin_state_extended(pin, ignore_protection, true, "Pulsing ");
|
2017-09-06 13:28:31 +02:00
|
|
|
#if AVR_AT90USB1286_FAMILY // Teensy IDEs don't know about these pins so must use FASTIO
|
|
|
|
if (pin == TEENSY_E2) {
|
|
|
|
SET_OUTPUT(TEENSY_E2);
|
|
|
|
for (int16_t j = 0; j < repeat; j++) {
|
|
|
|
WRITE(TEENSY_E2, LOW); safe_delay(wait);
|
|
|
|
WRITE(TEENSY_E2, HIGH); safe_delay(wait);
|
|
|
|
WRITE(TEENSY_E2, LOW); safe_delay(wait);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (pin == TEENSY_E3) {
|
|
|
|
SET_OUTPUT(TEENSY_E3);
|
|
|
|
for (int16_t j = 0; j < repeat; j++) {
|
|
|
|
WRITE(TEENSY_E3, LOW); safe_delay(wait);
|
|
|
|
WRITE(TEENSY_E3, HIGH); safe_delay(wait);
|
|
|
|
WRITE(TEENSY_E3, LOW); safe_delay(wait);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
pinMode(pin, OUTPUT);
|
|
|
|
for (int16_t j = 0; j < repeat; j++) {
|
2019-04-07 01:06:07 +02:00
|
|
|
watchdog_reset(); extDigitalWrite(pin, 0); safe_delay(wait);
|
|
|
|
watchdog_reset(); extDigitalWrite(pin, 1); safe_delay(wait);
|
|
|
|
watchdog_reset(); extDigitalWrite(pin, 0); safe_delay(wait);
|
|
|
|
watchdog_reset();
|
2017-09-06 13:28:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
SERIAL_EOL();
|
|
|
|
}
|
|
|
|
SERIAL_ECHOLNPGM("Done.");
|
|
|
|
|
|
|
|
} // toggle_pins
|
|
|
|
|
|
|
|
inline void servo_probe_test() {
|
2019-05-18 02:10:18 +02:00
|
|
|
|
2017-09-06 13:28:31 +02:00
|
|
|
#if !(NUM_SERVOS > 0 && HAS_SERVO_0)
|
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
SERIAL_ERROR_MSG("SERVO not set up.");
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-04-02 06:54:12 +02:00
|
|
|
#elif !HAS_Z_SERVO_PROBE
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
SERIAL_ERROR_MSG("Z_PROBE_SERVO_NR not set up.");
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-04-02 06:54:12 +02:00
|
|
|
#else // HAS_Z_SERVO_PROBE
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2018-04-02 06:54:12 +02:00
|
|
|
const uint8_t probe_index = parser.byteval('P', Z_PROBE_SERVO_NR);
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
SERIAL_ECHOLNPAIR("Servo probe test\n"
|
|
|
|
". using index: ", int(probe_index),
|
|
|
|
", deploy angle: ", servo_angles[probe_index][0],
|
|
|
|
", stow angle: ", servo_angles[probe_index][1]
|
|
|
|
);
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-06-22 07:48:47 +02:00
|
|
|
bool deploy_state = false, stow_state;
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#if ENABLED(Z_MIN_PROBE_USES_Z_MIN_ENDSTOP_PIN)
|
|
|
|
|
|
|
|
#define PROBE_TEST_PIN Z_MIN_PIN
|
2019-05-18 02:10:18 +02:00
|
|
|
constexpr bool probe_inverting = Z_MIN_ENDSTOP_INVERTING;
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
SERIAL_ECHOLNPAIR(". Probe Z_MIN_PIN: ", int(PROBE_TEST_PIN));
|
2018-11-29 23:58:58 +01:00
|
|
|
SERIAL_ECHOPGM(". Z_MIN_ENDSTOP_INVERTING: ");
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
#else
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#define PROBE_TEST_PIN Z_MIN_PROBE_PIN
|
2019-05-18 02:10:18 +02:00
|
|
|
constexpr bool probe_inverting = Z_MIN_PROBE_ENDSTOP_INVERTING;
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
SERIAL_ECHOLNPAIR(". Probe Z_MIN_PROBE_PIN: ", int(PROBE_TEST_PIN));
|
|
|
|
SERIAL_ECHOPGM( ". Z_MIN_PROBE_ENDSTOP_INVERTING: ");
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
serialprint_truefalse(probe_inverting);
|
|
|
|
SERIAL_EOL();
|
|
|
|
|
2017-09-06 13:28:31 +02:00
|
|
|
SET_INPUT_PULLUP(PROBE_TEST_PIN);
|
2019-05-18 02:10:18 +02:00
|
|
|
|
|
|
|
// First, check for a probe that recognizes an advanced BLTouch sequence.
|
|
|
|
// In addition to STOW and DEPLOY, it uses SW MODE (and RESET in the beginning)
|
2019-05-26 22:24:10 +02:00
|
|
|
// to see if this is one of the following: BLTOUCH Classic 1.2, 1.3, or
|
2019-05-18 02:10:18 +02:00
|
|
|
// BLTouch Smart 1.0, 2.0, 2.2, 3.0, 3.1. But only if the user has actually
|
|
|
|
// configured a BLTouch as being present. If the user has not configured this,
|
|
|
|
// the BLTouch will be detected in the last phase of these tests (see further on).
|
|
|
|
bool blt = false;
|
|
|
|
// This code will try to detect a BLTouch probe or clone
|
|
|
|
#if ENABLED(BLTOUCH)
|
|
|
|
SERIAL_ECHOLNPGM(". Check for BLTOUCH");
|
|
|
|
bltouch._reset();
|
|
|
|
bltouch._stow();
|
|
|
|
if (probe_inverting == READ(PROBE_TEST_PIN)) {
|
|
|
|
bltouch._set_SW_mode();
|
|
|
|
if (probe_inverting != READ(PROBE_TEST_PIN)) {
|
|
|
|
bltouch._deploy();
|
|
|
|
if (probe_inverting == READ(PROBE_TEST_PIN)) {
|
|
|
|
bltouch._stow();
|
|
|
|
SERIAL_ECHOLNPGM("= BLTouch Classic 1.2, 1.3, Smart 1.0, 2.0, 2.2, 3.0, 3.1 detected.");
|
|
|
|
// Check for a 3.1 by letting the user trigger it, later
|
|
|
|
blt = true;
|
|
|
|
}
|
2017-09-06 13:28:31 +02:00
|
|
|
}
|
|
|
|
}
|
2019-05-18 02:10:18 +02:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
// The following code is common to all kinds of servo probes.
|
|
|
|
// Since it could be a real servo or a BLTouch (any kind) or a clone,
|
|
|
|
// use only "common" functions - i.e. SERVO_MOVE. No bltouch.xxxx stuff.
|
|
|
|
|
|
|
|
// If it is already recognised as a being a BLTouch, no need for this test
|
|
|
|
if (!blt) {
|
|
|
|
// DEPLOY and STOW 4 times and see if the signal follows
|
|
|
|
// Then it is a mechanical switch
|
|
|
|
uint8_t i = 0;
|
|
|
|
SERIAL_ECHOLNPGM(". Deploy & stow 4 times");
|
|
|
|
do {
|
|
|
|
MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][0]); // Deploy
|
|
|
|
safe_delay(500);
|
|
|
|
deploy_state = READ(PROBE_TEST_PIN);
|
|
|
|
MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][1]); // Stow
|
|
|
|
safe_delay(500);
|
|
|
|
stow_state = READ(PROBE_TEST_PIN);
|
|
|
|
} while (++i < 4);
|
|
|
|
|
|
|
|
if (probe_inverting != deploy_state) SERIAL_ECHOLNPGM("WARNING: INVERTING setting probably backwards.");
|
|
|
|
|
|
|
|
if (deploy_state != stow_state) {
|
|
|
|
SERIAL_ECHOLNPGM("= Mechanical Switch detected");
|
|
|
|
if (deploy_state) {
|
|
|
|
SERIAL_ECHOLNPAIR(" DEPLOYED state: HIGH (logic 1)",
|
|
|
|
" STOWED (triggered) state: LOW (logic 0)");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
SERIAL_ECHOLNPAIR(" DEPLOYED state: LOW (logic 0)",
|
|
|
|
" STOWED (triggered) state: HIGH (logic 1)");
|
|
|
|
}
|
|
|
|
#if ENABLED(BLTOUCH)
|
|
|
|
SERIAL_ECHOLNPGM("FAIL: BLTOUCH enabled - Set up this device as a Servo Probe with INVERTING set to 'true'.");
|
|
|
|
#endif
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
// Ask the user for a trigger event and measure the pulse width.
|
|
|
|
MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][0]); // Deploy
|
|
|
|
safe_delay(500);
|
|
|
|
SERIAL_ECHOLNPGM("** Please trigger probe within 30 sec **");
|
|
|
|
uint16_t probe_counter = 0;
|
|
|
|
|
|
|
|
// Wait 30 seconds for user to trigger probe
|
|
|
|
for (uint16_t j = 0; j < 500 * 30 && probe_counter == 0 ; j++) {
|
|
|
|
safe_delay(2);
|
|
|
|
|
|
|
|
if (0 == j % (500 * 1)) gcode.reset_stepper_timeout(); // Keep steppers powered
|
|
|
|
|
|
|
|
if (deploy_state != READ(PROBE_TEST_PIN)) { // probe triggered
|
|
|
|
for (probe_counter = 0; probe_counter < 15 && deploy_state != READ(PROBE_TEST_PIN); ++probe_counter) safe_delay(2);
|
|
|
|
|
2019-05-26 23:21:28 +02:00
|
|
|
SERIAL_ECHOPGM(". Pulse width");
|
2019-05-26 01:23:25 +02:00
|
|
|
if (probe_counter == 15)
|
2019-05-26 23:21:28 +02:00
|
|
|
SERIAL_ECHOLNPGM(": 30ms or more");
|
2019-05-26 22:24:10 +02:00
|
|
|
else
|
2019-05-26 23:21:28 +02:00
|
|
|
SERIAL_ECHOLNPAIR(" (+/- 4ms): ", probe_counter * 2);
|
2019-05-26 22:24:10 +02:00
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
if (probe_counter >= 4) {
|
|
|
|
if (probe_counter == 15) {
|
|
|
|
if (blt) SERIAL_ECHOPGM("= BLTouch V3.1");
|
|
|
|
else SERIAL_ECHOPGM("= Z Servo Probe");
|
|
|
|
}
|
2019-05-26 23:21:28 +02:00
|
|
|
else SERIAL_ECHOPGM("= BLTouch pre V3.1 (or compatible)");
|
2019-05-18 02:10:18 +02:00
|
|
|
SERIAL_ECHOLNPGM(" detected.");
|
|
|
|
}
|
|
|
|
else SERIAL_ECHOLNPGM("FAIL: Noise detected - please re-run test");
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
MOVE_SERVO(probe_index, servo_angles[Z_PROBE_SERVO_NR][1]); // Stow
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-05-26 23:21:28 +02:00
|
|
|
if (!probe_counter) SERIAL_ECHOLNPGM("FAIL: No trigger detected");
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
#endif // HAS_Z_SERVO_PROBE
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
} // servo_probe_test
|
|
|
|
|
|
|
|
/**
|
|
|
|
* M43: Pin debug - report pin state, watch pins, toggle pins and servo probe test/report
|
|
|
|
*
|
|
|
|
* M43 - report name and state of pin(s)
|
|
|
|
* P<pin> Pin to read or watch. If omitted, reads all pins.
|
|
|
|
* I Flag to ignore Marlin's pin protection.
|
|
|
|
*
|
|
|
|
* M43 W - Watch pins -reporting changes- until reset, click, or M108.
|
|
|
|
* P<pin> Pin to read or watch. If omitted, read/watch all pins.
|
|
|
|
* I Flag to ignore Marlin's pin protection.
|
|
|
|
*
|
|
|
|
* M43 E<bool> - Enable / disable background endstop monitoring
|
|
|
|
* - Machine continues to operate
|
|
|
|
* - Reports changes to endstops
|
|
|
|
* - Toggles LED_PIN when an endstop changes
|
2017-10-07 20:34:25 +02:00
|
|
|
* - Cannot reliably catch the 5mS pulse from BLTouch type probes
|
2017-09-06 13:28:31 +02:00
|
|
|
*
|
|
|
|
* M43 T - Toggle pin(s) and report which pin is being toggled
|
|
|
|
* S<pin> - Start Pin number. If not given, will default to 0
|
|
|
|
* L<pin> - End Pin number. If not given, will default to last pin defined for this board
|
|
|
|
* I<bool> - Flag to ignore Marlin's pin protection. Use with caution!!!!
|
|
|
|
* R - Repeat pulses on each pin this number of times before continueing to next pin
|
|
|
|
* W - Wait time (in miliseconds) between pulses. If not given will default to 500
|
|
|
|
*
|
|
|
|
* M43 S - Servo probe test
|
|
|
|
* P<index> - Probe index (optional - defaults to 0
|
|
|
|
*/
|
2017-09-16 11:06:28 +02:00
|
|
|
void GcodeSuite::M43() {
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
// 'T' must be first. It uses 'S' and 'E' differently.
|
|
|
|
if (parser.seen('T')) return toggle_pins();
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
// 'E' Enable or disable endstop monitoring and return
|
2017-09-06 13:28:31 +02:00
|
|
|
if (parser.seen('E')) {
|
2017-09-18 12:55:09 +02:00
|
|
|
endstops.monitor_flag = parser.value_bool();
|
2018-11-29 23:58:58 +01:00
|
|
|
SERIAL_ECHOPGM("endstop monitor ");
|
2017-09-18 12:55:09 +02:00
|
|
|
serialprintPGM(endstops.monitor_flag ? PSTR("en") : PSTR("dis"));
|
2018-11-29 23:58:58 +01:00
|
|
|
SERIAL_ECHOLNPGM("abled");
|
2017-09-06 13:28:31 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
// 'S' Run servo probe test and return
|
|
|
|
if (parser.seen('S')) return servo_probe_test();
|
2017-09-06 13:28:31 +02:00
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
// 'P' Get the range of pins to test or watch
|
2018-01-01 23:11:56 +01:00
|
|
|
uint8_t first_pin = PARSED_PIN_INDEX('P', 0),
|
|
|
|
last_pin = parser.seenval('P') ? first_pin : NUMBER_PINS_TOTAL - 1;
|
2017-09-06 13:28:31 +02:00
|
|
|
|
|
|
|
if (first_pin > last_pin) return;
|
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
// 'I' to ignore protected pins
|
2017-09-06 13:28:31 +02:00
|
|
|
const bool ignore_protection = parser.boolval('I');
|
|
|
|
|
2019-05-18 02:10:18 +02:00
|
|
|
// 'W' Watch until click, M108, or reset
|
2017-09-06 13:28:31 +02:00
|
|
|
if (parser.boolval('W')) {
|
2018-11-29 23:58:58 +01:00
|
|
|
SERIAL_ECHOLNPGM("Watching pins");
|
2018-01-01 23:11:56 +01:00
|
|
|
#ifdef ARDUINO_ARCH_SAM
|
2019-05-18 02:10:18 +02:00
|
|
|
NOLESS(first_pin, 2); // Don't hijack the UART pins
|
2018-01-01 23:11:56 +01:00
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
uint8_t pin_state[last_pin - first_pin + 1];
|
2017-10-26 20:37:26 +02:00
|
|
|
for (uint8_t i = first_pin; i <= last_pin; i++) {
|
2019-07-06 05:08:06 +02:00
|
|
|
pin_t pin = GET_PIN_MAP_PIN_M43(i);
|
2017-09-06 13:28:31 +02:00
|
|
|
if (!VALID_PIN(pin)) continue;
|
2019-04-07 01:06:07 +02:00
|
|
|
if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue;
|
2017-09-06 13:28:31 +02:00
|
|
|
pinMode(pin, INPUT_PULLUP);
|
|
|
|
delay(1);
|
2019-05-18 02:10:18 +02:00
|
|
|
/*
|
2017-09-06 13:28:31 +02:00
|
|
|
if (IS_ANALOG(pin))
|
|
|
|
pin_state[pin - first_pin] = analogRead(DIGITAL_PIN_TO_ANALOG_PIN(pin)); // int16_t pin_state[...]
|
|
|
|
else
|
2019-05-18 02:10:18 +02:00
|
|
|
//*/
|
2019-03-05 07:41:31 +01:00
|
|
|
pin_state[i - first_pin] = extDigitalRead(pin);
|
2017-09-06 13:28:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#if HAS_RESUME_CONTINUE
|
2019-06-30 05:49:50 +02:00
|
|
|
KEEPALIVE_STATE(PAUSED_FOR_USER);
|
2017-09-06 13:28:31 +02:00
|
|
|
wait_for_user = true;
|
2019-02-12 22:55:47 +01:00
|
|
|
#if ENABLED(HOST_PROMPT_SUPPORT)
|
|
|
|
host_prompt_do(PROMPT_USER_CONTINUE, PSTR("M43 Wait Called"), PSTR("Continue"));
|
|
|
|
#endif
|
2019-08-19 04:03:26 +02:00
|
|
|
#if ENABLED(EXTENSIBLE_UI)
|
|
|
|
ExtUI::onStatusChanged(PSTR("M43 Wait Called"));
|
|
|
|
#endif
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
for (;;) {
|
2017-10-26 20:37:26 +02:00
|
|
|
for (uint8_t i = first_pin; i <= last_pin; i++) {
|
2019-07-06 05:08:06 +02:00
|
|
|
pin_t pin = GET_PIN_MAP_PIN_M43(i);
|
2017-09-06 13:28:31 +02:00
|
|
|
if (!VALID_PIN(pin)) continue;
|
2019-04-07 01:06:07 +02:00
|
|
|
if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue;
|
2017-09-06 13:28:31 +02:00
|
|
|
const byte val =
|
|
|
|
/*
|
2019-05-18 02:10:18 +02:00
|
|
|
IS_ANALOG(pin)
|
|
|
|
? analogRead(DIGITAL_PIN_TO_ANALOG_PIN(pin)) : // int16_t val
|
|
|
|
:
|
2017-09-06 13:28:31 +02:00
|
|
|
//*/
|
2019-03-05 07:41:31 +01:00
|
|
|
extDigitalRead(pin);
|
2017-10-26 20:37:26 +02:00
|
|
|
if (val != pin_state[i - first_pin]) {
|
2017-09-06 13:28:31 +02:00
|
|
|
report_pin_state_extended(pin, ignore_protection, false);
|
2017-10-26 20:37:26 +02:00
|
|
|
pin_state[i - first_pin] = val;
|
2017-09-06 13:28:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if HAS_RESUME_CONTINUE
|
2019-06-30 05:49:50 +02:00
|
|
|
if (!wait_for_user) break;
|
2017-09-06 13:28:31 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
safe_delay(200);
|
|
|
|
}
|
|
|
|
}
|
2019-05-18 02:10:18 +02:00
|
|
|
else {
|
|
|
|
// Report current state of selected pin(s)
|
|
|
|
for (uint8_t i = first_pin; i <= last_pin; i++) {
|
2019-07-06 05:08:06 +02:00
|
|
|
pin_t pin = GET_PIN_MAP_PIN_M43(i);
|
2019-05-18 02:10:18 +02:00
|
|
|
if (VALID_PIN(pin)) report_pin_state_extended(pin, ignore_protection, true);
|
|
|
|
}
|
2017-10-26 20:37:26 +02:00
|
|
|
}
|
2017-09-06 13:28:31 +02:00
|
|
|
}
|
2017-09-16 11:06:28 +02:00
|
|
|
|
|
|
|
#endif // PINS_DEBUGGING
|