Package com.diozero.api
Class DigitalInputOutputDevice
java.lang.Object
com.diozero.api.GpioDevice
com.diozero.api.GpioInputDevice<DigitalInputEvent>
com.diozero.api.AbstractDigitalInputDevice
com.diozero.api.DigitalInputOutputDevice
- All Implemented Interfaces:
DigitalInputDeviceInterface
,InputEventListener<DigitalInputEvent>
,java.io.Closeable
,java.lang.AutoCloseable
public class DigitalInputOutputDevice extends AbstractDigitalInputDevice
-
Field Summary
-
Constructor Summary
Constructors Constructor Description DigitalInputOutputDevice(int gpio, DeviceMode mode)
DigitalInputOutputDevice(GpioDeviceFactoryInterface deviceFactory, int gpio, DeviceMode mode)
-
Method Summary
Modifier and Type Method Description void
close()
DeviceMode
getMode()
Get the input / output modeboolean
getValue()
Read the current underlying state of the input pin.protected void
removeListener()
protected void
setListener()
void
setMode(DeviceMode mode)
Set the input / output modevoid
setValue(boolean value)
Set the output value (if mode.Methods inherited from class com.diozero.api.AbstractDigitalInputDevice
disableDeviceListener, enableDeviceListener, isActiveHigh, valueChanged, whenActivated, whenDeactivated
Methods inherited from class com.diozero.api.GpioInputDevice
addListener, removeAllListeners, removeListener
-
Constructor Details
-
DigitalInputOutputDevice
- Parameters:
gpio
- GPIO to which the device is connected.mode
- Input or outputMode
- Throws:
RuntimeIOException
- If an I/O error occurs.
-
DigitalInputOutputDevice
public DigitalInputOutputDevice(GpioDeviceFactoryInterface deviceFactory, int gpio, DeviceMode mode) throws RuntimeIOException- Parameters:
deviceFactory
- Device factory to use to provision this digital input device.gpio
- GPIO to which the device is connected.mode
- Input or outputMode
- Throws:
RuntimeIOException
- If an I/O error occurs.
-
-
Method Details
-
close
- Throws:
RuntimeIOException
-
getMode
Get the input / output mode- Returns:
- current mode
-
setMode
Set the input / output mode- Parameters:
mode
- new mode, valid values areDIGITAL_INPUT
andDIGITAL_OUTPUT
-
getValue
Read the current underlying state of the input pin. Does not factor in active high logic.- Returns:
- Device state.
- Throws:
RuntimeIOException
- If an I/O error occurred.
-
setValue
Set the output value (if mode.- Parameters:
value
- The new value- Throws:
RuntimeIOException
- If an I/O error occurs
-
setListener
protected void setListener()- Specified by:
setListener
in classAbstractDigitalInputDevice
-
removeListener
protected void removeListener()- Specified by:
removeListener
in classAbstractDigitalInputDevice
-