@Override public void setPwmRange(Pin pin, int range){ if (!hasPin(pin)) { throw new InvalidPinException(pin); } throw new UnsupportedOperationException(); }
@Override public void setPwmRange(Pin pin, int range){ if (!hasPin(pin)) { throw new InvalidPinException(pin); } throw new UnsupportedOperationException(); }
@Override public PinMode getMode(Pin pin) { if (!hasPin(pin)) { throw new InvalidPinException(pin); } // return cached mode value return getPinCache(pin).getMode(); }
@Override public PinMode getMode(Pin pin) { if (!hasPin(pin)) { throw new InvalidPinException(pin); } // return cached mode value return getPinCache(pin).getMode(); }
@Override public int getPwm(Pin pin) { if (!hasPin(pin)) { throw new InvalidPinException(pin); } // return cached pin PWM value return getPinCache(pin).getPwmValue(); }
@Override public PinPullResistance getPullResistance(Pin pin) { if (!hasPin(pin)) { throw new InvalidPinException(pin); } // return cached resistance return getPinCache(pin).getResistance(); }
@Override public boolean isExported(Pin pin) { if (!hasPin(pin)) { throw new InvalidPinException(pin); } // return cached exported state return getPinCache(pin).isExported(); }
@Override public void unexport(Pin pin) { if (!hasPin(pin)) { throw new InvalidPinException(pin); } // cache exported state getPinCache(pin).setExported(false); }
@Override public int getPwm(Pin pin) { if (!hasPin(pin)) { throw new InvalidPinException(pin); } // return cached pin PWM value return getPinCache(pin).getPwmValue(); }
@Override public boolean isExported(Pin pin) { if (!hasPin(pin)) { throw new InvalidPinException(pin); } // return cached exported state return getPinCache(pin).isExported(); }
@Override public void unexport(Pin pin) { if (!hasPin(pin)) { throw new InvalidPinException(pin); } // cache exported state getPinCache(pin).setExported(false); }
@Override public PinPullResistance getPullResistance(Pin pin) { if (!hasPin(pin)) { throw new InvalidPinException(pin); } // return cached resistance return getPinCache(pin).getResistance(); }
@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 export(Pin pin, PinMode mode) { if (!hasPin(pin)) { throw new InvalidPinException(pin); } if (!pin.getSupportedPinModes().contains(mode)) { throw new UnsupportedPinModeException(pin, mode); } // cache exported state getPinCache(pin).setExported(true); // cache mode getPinCache(pin).setMode(mode); }
@Override public void export(Pin pin, PinMode mode) { if (!hasPin(pin)) { throw new InvalidPinException(pin); } if (!pin.getSupportedPinModes().contains(mode)) { throw new UnsupportedPinModeException(pin, mode); } // cache exported state getPinCache(pin).setExported(true); // cache mode getPinCache(pin).setMode(mode); }
@Override public void setPwm(Pin pin, int value) { if (!hasPin(pin)) { throw new InvalidPinException(pin); } PinMode mode = getMode(pin); if (mode != PinMode.PWM_OUTPUT || mode != PinMode.SOFT_PWM_OUTPUT) { throw new InvalidPinModeException(pin, "Invalid pin mode [" + mode.getName() + "]; unable to setPwm(" + value + ")"); } // cache pin PWM value getPinCache(pin).setPwmValue(value); }
@Override public void setPwm(Pin pin, int value) { if (!hasPin(pin)) { throw new InvalidPinException(pin); } PinMode mode = getMode(pin); if (mode != PinMode.PWM_OUTPUT || mode != PinMode.SOFT_PWM_OUTPUT) { throw new InvalidPinModeException(pin, "Invalid pin mode [" + mode.getName() + "]; unable to setPwm(" + value + ")"); } // cache pin PWM value getPinCache(pin).setPwmValue(value); }
@Override public void setState(Pin pin, PinState state) { if (!hasPin(pin)) { throw new InvalidPinException(pin); } GpioProviderPinCache pinCache = getPinCache(pin); // only permit invocation on pins set to DIGITAL_OUTPUT modes if (pinCache.getMode() != PinMode.DIGITAL_OUTPUT) { throw new InvalidPinModeException(pin, "Invalid pin mode on pin [" + pin.getName() + "]; cannot setState() when pin mode is [" + pinCache.getMode().getName() + "]"); } // for digital output pins, we will echo the event feedback dispatchPinDigitalStateChangeEvent(pin, state); // cache pin state pinCache.setState(state); }
@Override public void setState(Pin pin, PinState state) { if (!hasPin(pin)) { throw new InvalidPinException(pin); } GpioProviderPinCache pinCache = getPinCache(pin); // only permit invocation on pins set to DIGITAL_OUTPUT modes if (pinCache.getMode() != PinMode.DIGITAL_OUTPUT) { throw new InvalidPinModeException(pin, "Invalid pin mode on pin [" + pin.getName() + "]; cannot setState() when pin mode is [" + pinCache.getMode().getName() + "]"); } // for digital output pins, we will echo the event feedback dispatchPinDigitalStateChangeEvent(pin, state); // cache pin state pinCache.setState(state); }