Package com.diozero.api
Class DebouncedDigitalInputDevice
java.lang.Object
com.diozero.api.GpioDevice
com.diozero.api.GpioInputDevice<DigitalInputEvent>
com.diozero.api.AbstractDigitalInputDevice
com.diozero.api.DigitalInputDevice
com.diozero.api.DebouncedDigitalInputDevice
- All Implemented Interfaces:
DeviceInterface
,DigitalInputDeviceInterface
,DeviceEventConsumer<DigitalInputEvent>
,AutoCloseable
,Consumer<DigitalInputEvent>
public class DebouncedDigitalInputDevice extends DigitalInputDevice
Digital input device with debounce logic. The goal of this debounce
implementation is to only detect level changes that are held for the
specified debounce time. All other level changes that are shorter than that
duration will be ignored.
-
Nested Class Summary
Nested classes/interfaces inherited from class com.diozero.api.DigitalInputDevice
DigitalInputDevice.Builder
-
Field Summary
Fields inherited from class com.diozero.api.AbstractDigitalInputDevice
activeHigh
Fields inherited from class com.diozero.api.GpioDevice
pinInfo
-
Constructor Summary
Constructors Constructor Description DebouncedDigitalInputDevice(int gpio, int debounceTimeMs)
DebouncedDigitalInputDevice(int gpio, GpioPullUpDown pud, int debounceTimeMs)
-
Method Summary
Modifier and Type Method Description void
accept(DigitalInputEvent event)
void
changeDetection()
void
close()
Close this deviceMethods inherited from class com.diozero.api.DigitalInputDevice
getPullUpDown, getTrigger, getValue, isActive, removeListener, setListener
Methods inherited from class com.diozero.api.AbstractDigitalInputDevice
disableDeviceListener, enableDeviceListener, isActiveHigh, waitForActive, waitForActive, waitForInactive, waitForInactive, waitForValue, whenActivated, whenDeactivated
Methods inherited from class com.diozero.api.GpioInputDevice
addListener, hasListeners, removeAllListeners, removeListener
Methods inherited from class com.diozero.api.GpioDevice
getGpio
-
Constructor Details
-
DebouncedDigitalInputDevice
public DebouncedDigitalInputDevice(int gpio, int debounceTimeMs) throws RuntimeIOException, IllegalArgumentException- Parameters:
gpio
- GPIOdebounceTimeMs
- Specifies the length of time (in seconds) that the component will ignore changes in state after an initial change.- Throws:
RuntimeIOException
- if an I/O error occursIllegalArgumentException
- if the debounce time is less than 0
-
DebouncedDigitalInputDevice
public DebouncedDigitalInputDevice(int gpio, GpioPullUpDown pud, int debounceTimeMs) throws RuntimeIOException, IllegalArgumentException- Parameters:
gpio
- GPIOpud
- Pull-up/down configurationdebounceTimeMs
- Specifies the length of time (in seconds) that the component will ignore changes in state after an initial change.- Throws:
RuntimeIOException
- if an I/O error occursIllegalArgumentException
- if the debounce time is less than 0
-
-
Method Details
-
accept
- Specified by:
accept
in interfaceConsumer<DigitalInputEvent>
- Overrides:
accept
in classAbstractDigitalInputDevice
-
close
public void close()Description copied from interface:DeviceInterface
Close this device- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceDeviceInterface
- Overrides:
close
in classDigitalInputDevice
-
changeDetection
public void changeDetection()
-