Protected pin err for M226

This commit is contained in:
Scott Lahteine
2018-06-10 17:45:39 -05:00
parent 4b90cd8ead
commit 968a5d2e63
5 changed files with 28 additions and 32 deletions

View File

@ -33,27 +33,20 @@ void GcodeSuite::M226() {
pin_state = parser.intval('S', -1); // required pin state - default is inverted
const pin_t pin = GET_PIN_MAP_PIN(pin_number);
if (WITHIN(pin_state, -1, 1) && pin > -1 && !pin_is_protected(pin)) {
int target = LOW;
planner.synchronize();
pinMode(pin, INPUT);
switch (pin_state) {
case 1:
target = HIGH;
break;
case 0:
target = LOW;
break;
case -1:
target = !digitalRead(pin);
break;
if (WITHIN(pin_state, -1, 1) && pin > -1) {
if (pin_is_protected(pin))
protected_pin_err();
else {
int target = LOW;
planner.synchronize();
pinMode(pin, INPUT);
switch (pin_state) {
case 1: target = HIGH; break;
case 0: target = LOW; break;
case -1: target = !digitalRead(pin); break;
}
while (digitalRead(pin) != target) idle();
}
while (digitalRead(pin) != target) idle();
} // pin_state -1 0 1 && pin > -1
} // parser.seen('P')
}

View File

@ -41,11 +41,8 @@ void GcodeSuite::M42() {
if (pin_index < 0) return;
const pin_t pin = GET_PIN_MAP_PIN(pin_index);
if (pin_is_protected(pin)) {
SERIAL_ERROR_START();
SERIAL_ERRORLNPGM(MSG_ERR_PROTECTED_PIN);
return;
}
if (pin_is_protected(pin_number)) return protected_pin_err();
pinMode(pin, OUTPUT);
digitalWrite(pin, pin_status);