@Override public void export(PinMode mode, PinState defaultState, GpioPin... pin){ if (pin == null || pin.length == 0) { throw new IllegalArgumentException("Missing pin argument."); } for (GpioPin p : pin) { // ensure the requested pin has been provisioned if (!pins.contains(p)) { throw new GpioPinNotProvisionedException(p.getPin()); } // export the pin p.export(mode, defaultState); } }
@Override public void export(PinMode mode, PinState defaultState, GpioPin... pin){ if (pin == null || pin.length == 0) { throw new IllegalArgumentException("Missing pin argument."); } for (GpioPin p : pin) { // ensure the requested pin has been provisioned if (!pins.contains(p)) { throw new GpioPinNotProvisionedException(p.getPin()); } // export the pin p.export(mode, defaultState); } }
@Override public GpioPin provisionPin(GpioProvider provider, Pin pin, String name, PinMode mode, PinState defaultState) { // if the provider does not match the pin's provider then throw an error if(!provider.getName().equals(pin.getProvider())){ throw new PinProviderException(provider, pin); } // if an existing pin has been previously created, then throw an error for(GpioPin p : pins) { if (p.getProvider().equals(provider) && p.getPin().equals(pin)) { throw new GpioPinExistsException(pin); } } // create new GPIO pin instance GpioPin gpioPin = new GpioPinImpl(this, provider, pin); // set the gpio pin name if (name != null) { gpioPin.setName(name); } // export this pin gpioPin.export(mode, defaultState); // add this new pin instance to the managed collection pins.add(gpioPin); // return new new pin instance return gpioPin; }
@Override public GpioPin provisionPin(GpioProvider provider, Pin pin, String name, PinMode mode, PinState defaultState) { // if the provider does not match the pin's provider then throw an error if(!provider.getName().equals(pin.getProvider())){ throw new PinProviderException(provider, pin); } // if an existing pin has been previously created, then throw an error for(GpioPin p : pins) { if (p.getProvider().equals(provider) && p.getPin().equals(pin)) { throw new GpioPinExistsException(pin); } } // create new GPIO pin instance GpioPin gpioPin = new GpioPinImpl(this, provider, pin); // set the gpio pin name if (name != null) { gpioPin.setName(name); } // export this pin gpioPin.export(mode, defaultState); // add this new pin instance to the managed collection pins.add(gpioPin); // return new new pin instance return gpioPin; }