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:
DeviceInterface
,DigitalInputDeviceInterface
,DeviceEventConsumer<DigitalInputEvent>
,AutoCloseable
,Consumer<DigitalInputEvent>
public class DigitalInputOutputDevice extends AbstractDigitalInputDevice
-
-
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 DigitalInputOutputDevice(int gpio, DeviceMode mode)
DigitalInputOutputDevice(GpioDeviceFactoryInterface deviceFactory, int gpio, DeviceMode mode)
DigitalInputOutputDevice(GpioDeviceFactoryInterface deviceFactory, PinInfo pinInfo, DeviceMode mode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close this deviceDeviceMode
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 in output mode).-
Methods inherited from class com.diozero.api.AbstractDigitalInputDevice
accept, 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 Detail
-
DigitalInputOutputDevice
public DigitalInputOutputDevice(int gpio, DeviceMode mode) throws RuntimeIOException
- 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.
-
DigitalInputOutputDevice
public DigitalInputOutputDevice(GpioDeviceFactoryInterface deviceFactory, PinInfo pinInfo, DeviceMode mode) throws RuntimeIOException
- Parameters:
deviceFactory
- Device factory to use to provision this digital input device.pinInfo
- Information about the GPIO pin to which the device is connected.mode
- Input or outputMode
- Throws:
RuntimeIOException
- If an I/O error occurs.
-
-
Method Detail
-
close
public void close() throws RuntimeIOException
Description copied from interface:DeviceInterface
Close this device- Throws:
RuntimeIOException
-
getMode
public DeviceMode getMode()
Get the input / output mode- Returns:
- current mode
-
setMode
public void setMode(DeviceMode mode)
Set the input / output mode- Parameters:
mode
- new mode, valid values areDIGITAL_INPUT
andDIGITAL_OUTPUT
-
getValue
public boolean getValue() throws RuntimeIOException
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
public void setValue(boolean value) throws RuntimeIOException
Set the output value (if in output 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
-
-