Package com.diozero.devices
Class Button.Builder
- java.lang.Object
-
- com.diozero.devices.Button.Builder
-
- Enclosing class:
- Button
public static class Button.Builder extends Object
Button builder. Default values:- pud:
GpioPullUpDown.NONE
- trigger:
GpioEventTrigger.BOTH
- activeHigh: set to false if pud ==
GpioPullUpDown.PULL_UP
, otherwise true (assumes normally open wiring configuration) - deviceFactory:
DeviceFactoryHelper.getNativeDeviceFactory()
PinInfo
instance must be specified. Using a PinInfo instance allows input devices to be identified by either physical pin number or GPIO chip and line offset. The optional activeHigh parameter default value assumes a normally open wiring configuration, however, this can be overridden for normally closed configurations as well as scenarios where pud isGpioPullUpDown.NONE
and an external pull up/down resistor is used.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description Button
build()
static Button.Builder
builder(int gpio)
Create a new Button builder instancestatic Button.Builder
builder(PinInfo pinInfo)
Create a new DigitalInputDevice builder instanceButton.Builder
setActiveHigh(boolean activeHigh)
Button.Builder
setGpioDeviceFactoryInterface(GpioDeviceFactoryInterface deviceFactory)
Button.Builder
setPullUpDown(GpioPullUpDown pud)
Button.Builder
setTrigger(GpioEventTrigger trigger)
-
-
-
Method Detail
-
builder
public static Button.Builder builder(int gpio)
Create a new Button builder instance- Parameters:
gpio
- The GPIO to be used for the new DigitalInputDevice- Returns:
- A new Button builder instance
-
builder
public static Button.Builder builder(PinInfo pinInfo)
Create a new DigitalInputDevice builder instance- Parameters:
pinInfo
- The pin to be used for the new DigitalInputDevice- Returns:
- A new DigitalInputDevice builder instance
-
setPullUpDown
public Button.Builder setPullUpDown(GpioPullUpDown pud)
-
setTrigger
public Button.Builder setTrigger(GpioEventTrigger trigger)
-
setActiveHigh
public Button.Builder setActiveHigh(boolean activeHigh)
-
setGpioDeviceFactoryInterface
public Button.Builder setGpioDeviceFactoryInterface(GpioDeviceFactoryInterface deviceFactory)
-
build
public Button build() throws RuntimeIOException, NoSuchDeviceException
-
-