Protected pin err for M226
This commit is contained in:
		@@ -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')
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user