@Override public PinMode getMode(Pin pin) { return super.getMode(pin); }
@Override public PinMode getMode(Pin pin) { return super.getMode(pin); }
@Override public PinMode getMode(Pin pin) { return super.getMode(pin); }
@Override public PinMode getMode(Pin pin) { return super.getMode(pin); }
@Override public PinMode getMode(Pin pin) { return super.getMode(pin); }
@Override public PinMode getMode(Pin pin) { super.getMode(pin); // return first mode found; this device has singular fixed pin modes for(PinMode mode : pin.getSupportedPinModes()) return mode; return null; }
@Override public double getValue(Pin pin) { // the getMode() will validate the pin exists with the hasPin() function PinMode mode = getMode(pin); if (mode == PinMode.DIGITAL_OUTPUT) { return getState(pin).getValue(); } // return cached pin analog value return getPinCache(pin).getAnalogValue(); }
@Override public double getValue(Pin pin) { // the getMode() will validate the pin exists with the hasPin() function PinMode mode = getMode(pin); if (mode == PinMode.DIGITAL_OUTPUT) { return getState(pin).getValue(); } // return cached pin analog value return getPinCache(pin).getAnalogValue(); }
@Override public PinState getState(Pin pin) { // the getMode() will validate the pin exists with the hasPin() function PinMode mode = getMode(pin); // only permit invocation on pins set to DIGITAL modes if (!PinMode.allDigital().contains(mode)) { throw new InvalidPinModeException(pin, "Invalid pin mode on pin [" + pin.getName() + "]; cannot getState() when pin mode is [" + mode.getName() + "]"); } // return cached pin state return getPinCache(pin).getState(); }
@Override public PinState getState(Pin pin) { // the getMode() will validate the pin exists with the hasPin() function PinMode mode = getMode(pin); // only permit invocation on pins set to DIGITAL modes if (!PinMode.allDigital().contains(mode)) { throw new InvalidPinModeException(pin, "Invalid pin mode on pin [" + pin.getName() + "]; cannot getState() when pin mode is [" + mode.getName() + "]"); } // return cached pin state return getPinCache(pin).getState(); }
@Override public void setValue(Pin pin, double value) { // the getMode() will validate the pin exists with the hasPin() function PinMode mode = getMode(pin); // only permit invocation on pins set to OUTPUT modes if (!PinMode.allOutput().contains(mode)) { throw new InvalidPinModeException(pin, "Invalid pin mode on pin [" + pin.getName() + "]; cannot setValue(" + value + ") when pin mode is [" + mode.getName() + "]"); } // for digital analog pins, we will echo the event feedback dispatchPinAnalogValueChangeEvent(pin, value); // cache pin analog value getPinCache(pin).setAnalogValue(value); }
@Override public void setValue(Pin pin, double value) { // the getMode() will validate the pin exists with the hasPin() function PinMode mode = getMode(pin); // only permit invocation on pins set to OUTPUT modes if (!PinMode.allOutput().contains(mode)) { throw new InvalidPinModeException(pin, "Invalid pin mode on pin [" + pin.getName() + "]; cannot setValue(" + value + ") when pin mode is [" + mode.getName() + "]"); } // for digital analog pins, we will echo the event feedback dispatchPinAnalogValueChangeEvent(pin, value); // cache pin analog value getPinCache(pin).setAnalogValue(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 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); }