Package crackers.kobots.devices
Class DebouncedButton
-
- All Implemented Interfaces:
-
com.diozero.api.DeviceInterface
,com.diozero.api.DigitalInputDeviceInterface
,com.diozero.api.function.DeviceEventConsumer
,java.lang.AutoCloseable
,java.util.function.Consumer
public final class DebouncedButton extends DebouncedDigitalInputDevice
Simple extension to get the
whenPressed
andwhenReleased
semantics with debounce.
-
-
Field Summary
Fields Modifier and Type Field Description private final GpioEventTrigger
trigger
-
Constructor Summary
Constructors Constructor Description DebouncedButton(Integer gpio, Duration debounceTime, GpioPullUpDown pud, Boolean activeHigh, GpioDeviceFactoryInterface deviceFactory)
DebouncedButton(Integer gpio, Duration debounceTime, GpioPullUpDown pud, Boolean activeHigh)
DebouncedButton(Integer gpio, Duration debounceTime, GpioPullUpDown pud)
DebouncedButton(Integer gpio, Duration debounceTime)
-
Method Summary
Modifier and Type Method Description final Unit
whenPressed(LongConsumer buttonConsumer)
Action to perform when the button is pressed. final Unit
whenReleased(LongConsumer buttonConsumer)
Action to perform when the button is released. -
Methods inherited from class com.diozero.api.DigitalInputDevice
getName, getPullUpDown, getTrigger, getValue, isActive
-
Methods inherited from class com.diozero.api.DebouncedDigitalInputDevice
accept, changeDetection, close
-
Methods inherited from class com.diozero.api.GpioDevice
getGpio
-
Methods inherited from class java.util.function.Consumer
andThen
-
Methods inherited from class com.diozero.api.GpioInputDevice
addListener, hasListeners, removeAllListeners, removeListener
-
Methods inherited from class com.diozero.api.AbstractDigitalInputDevice
isActiveHigh, waitForActive, waitForActive, waitForInactive, waitForInactive, waitForValue, whenActivated, whenDeactivated
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Method Detail
-
whenPressed
final Unit whenPressed(LongConsumer buttonConsumer)
Action to perform when the button is pressed.
- Parameters:
buttonConsumer
- Callback function to invoke when pressed (long parameter is nanoseconds time).
-
whenReleased
final Unit whenReleased(LongConsumer buttonConsumer)
Action to perform when the button is released.
- Parameters:
buttonConsumer
- Callback function to invoke when released (long parameter is nanoseconds time).
-
-
-
-