public void setProgrammableGainAmplifier(ProgrammableGainAmplifierValue pga, Pin...pin){ for(Pin p : pin){ this.pga[p.getAddress()] = pga; } }
public UnsupportedPinEventsException(Pin pin) { super("This GPIO pin [" + pin.getName() + "] does not support pin events; no support for edge detection or interrupts; you will have to poll this pin for change changes."); this.pin = 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; }
public InvalidPinException(Pin pin) { super("Invalid pin exception; this pin [" + pin.getName() + "] is not supported by GPIO provider [" + pin.getProvider() + "]"); this.pin = pin; }
@Override public boolean equals(Object obj) { // matching object instance if (obj == this) return true; // reject is not a pin instance if (!(obj instanceof Pin)) return false; // match on pin provider, name and address Pin pin = (Pin) obj; return (pin.getProvider().equals(getProvider()) && pin.getName() == getName() && pin.getAddress() == getAddress()); } }
@Override public void setMode(Pin pin, PinMode mode) { super.setMode(pin, mode); // local pin mode cache pinModeCache[pin.getAddress()] = mode; if (!pin.getSupportedPinModes().contains(mode)) { throw new InvalidPinModeException(pin, "Invalid pin mode [" + mode.getName() + "]; pin [" + pin.getName() + "] does not support this mode."); } if (!pin.getSupportedPinModes().contains(mode)) { throw new UnsupportedPinModeException(pin, mode); } // cache mode getPinCache(pin).setMode(mode); // set pin mode on hardware com.pi4j.wiringpi.Gpio.pinMode(pin.getAddress(), mode.getValue()); }
@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); }
"\",\"address\":\"" + pin.getPin().getAddress() + "\",\"provider\":\"" + pin.getPin().getProvider() + "\",\"mode\":\"" + pin.getMode().getName() + "\",\"direction\":\"" + pin.getMode().getDirection() +
@Override public void setMode(Pin pin, PinMode mode) { if (!pin.getSupportedPinModes().contains(mode)) { throw new InvalidPinModeException(pin, "Invalid pin mode [" + mode.getName() + "]; pin [" + pin.getName() + "] does not support this mode."); } if (!pin.getSupportedPinModes().contains(mode)) { throw new UnsupportedPinModeException(pin, mode); } // cache mode getPinCache(pin).setMode(mode); }
public PinProviderException(GpioProvider provider, Pin pin) { super("GPIO pin [" + pin.toString() + "] expects provider [" + pin.getProvider() + "] but is attempting to be provisioned with provider [" + provider.getName() + "]; provisioning failed."); this.pin = pin; this.gpioProvider = provider; }
@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 synchronized void addListener(GpioPinListener listener, GpioPinInput... pin) { if (pin == null || pin.length == 0) { throw new IllegalArgumentException("Missing pin argument."); } for (GpioPinInput p : pin) { // ensure the requested pin has been provisioned if (!pins.contains(p)) { throw new GpioPinNotProvisionedException(p.getPin()); } // ensure the requested pin supports events (interrupts) if (!p.getPin().supportsPinEvents()) { throw new UnsupportedPinEventsException(p.getPin()); } p.addListener(listener); } }
@Override public void setMode(Pin pin, PinMode mode) { // no need to export an Odroid AIN pin if (mode == PinMode.ANALOG_INPUT) { if (!pin.getSupportedPinModes().contains(mode)) { throw new InvalidPinModeException(pin, "Invalid pin mode [" + mode.getName() + "]; pin [" + pin.getName() + "] does not support this mode."); } // local pin mode cache pinModeCache[pin.getAddress()] = mode; // cache mode getPinCache(pin).setMode(mode); return; } super.setMode(pin, mode); }
@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 boolean equals(Object obj) { // matching object instance if (obj == this) return true; // reject is not a pin instance if (!(obj instanceof Pin)) return false; // match on pin provider, name and address Pin pin = (Pin) obj; return (pin.getProvider().equals(getProvider()) && Objects.equals(pin.getName(), getName()) && pin.getAddress() == getAddress()); } }
"\",\"address\":\"" + pin.getPin().getAddress() + "\",\"provider\":\"" + pin.getPin().getProvider() + "\",\"mode\":\"" + pin.getMode().getName() + "\",\"direction\":\"" + pin.getMode().getDirection() +
@Override public void setMode(Pin pin, PinMode mode) { if (!pin.getSupportedPinModes().contains(mode)) { throw new InvalidPinModeException(pin, "Invalid pin mode [" + mode.getName() + "]; pin [" + pin.getName() + "] does not support this mode."); } if (!pin.getSupportedPinModes().contains(mode)) { throw new UnsupportedPinModeException(pin, mode); } // cache mode getPinCache(pin).setMode(mode); }
public InvalidPinException(Pin pin) { super("Invalid pin exception; this pin [" + pin.getName() + "] is not supported by GPIO provider [" + pin.getProvider() + "]"); this.pin = pin; }
public PinProviderException(GpioProvider provider, Pin pin) { super("GPIO pin [" + pin.toString() + "] expects provider [" + pin.getProvider() + "] but is attempting to be provisioned with provider [" + provider.getName() + "]; provisioning failed."); this.pin = pin; this.gpioProvider = provider; }
@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); }