@Override public void setPullResistance(Pin pin, PinPullResistance resistance) { if (!hasPin(pin)) { throw new InvalidPinException(pin); } if (!pin.getSupportedPinPullResistance().contains(resistance)) { throw new UnsupportedPinPullResistanceException(pin, resistance); } // cache resistance getPinCache(pin).setResistance(resistance); }
@Override public void setPullResistance(Pin pin, PinPullResistance resistance) { if (!hasPin(pin)) { throw new InvalidPinException(pin); } if (!pin.getSupportedPinPullResistance().contains(resistance)) { throw new UnsupportedPinPullResistanceException(pin, resistance); } // cache resistance getPinCache(pin).setResistance(resistance); }
@Override public void setPullResistance(Pin pin, PinPullResistance resistance) { // validate if (hasPin(pin) == false) { throw new InvalidPinException(pin); } // validate if (!pin.getSupportedPinPullResistance().contains(resistance)) { throw new UnsupportedPinPullResistanceException(pin, resistance); } try { // determine pin address int pinAddress = pin.getAddress(); // determine pull up value for pin bit if (resistance == PinPullResistance.PULL_UP) { currentPullup |= pinAddress; } else { currentPullup &= ~pinAddress; } // next update pull up resistor value device.write(REGISTER_GPPU, (byte) currentPullup); } catch (IOException ex) { throw new RuntimeException(ex); } // cache resistance getPinCache(pin).setResistance(resistance); }
@Override public void setPullResistance(Pin pin, PinPullResistance resistance) { // validate if (hasPin(pin) == false) { throw new InvalidPinException(pin); } // validate if (!pin.getSupportedPinPullResistance().contains(resistance)) { throw new UnsupportedPinPullResistanceException(pin, resistance); } try { // determine A or B port based on pin address if (pin.getAddress() < GPIO_B_OFFSET) { setPullResistanceA(pin, resistance); } else { setPullResistanceB(pin, resistance); } } catch (IOException ex) { throw new RuntimeException(ex); } // cache resistance getPinCache(pin).setResistance(resistance); }
@Override public void setPullResistance(Pin pin, PinPullResistance resistance) { // validate if (hasPin(pin) == false) { throw new InvalidPinException(pin); } // validate if (!pin.getSupportedPinPullResistance().contains(resistance)) { throw new UnsupportedPinPullResistanceException(pin, resistance); } try { // determine A or B port based on pin address if (pin.getAddress() < GPIO_B_OFFSET) { setPullResistanceA(pin, resistance); } else { setPullResistanceB(pin, resistance); } } catch (IOException ex) { throw new RuntimeException(ex); } // cache resistance getPinCache(pin).setResistance(resistance); }
@Override public void setPullResistance(Pin pin, PinPullResistance resistance) { // validate if (hasPin(pin) == false) { throw new InvalidPinException(pin); } // validate if (!pin.getSupportedPinPullResistance().contains(resistance)) { throw new UnsupportedPinPullResistanceException(pin, resistance); } try { // determine A or B port based on pin address if (pin.getAddress() < GPIO_B_OFFSET) { setPullResistanceA(pin, resistance); } else { setPullResistanceB(pin, resistance); } } catch (IOException ex) { throw new RuntimeException(ex); } // cache resistance getPinCache(pin).setResistance(resistance); }