public class DigitalOutputDevice extends GpioDevice
Modifier and Type | Field and Description |
---|---|
static int |
INFINITE_ITERATIONS |
pinNumber
Constructor and Description |
---|
DigitalOutputDevice(GpioDeviceFactoryInterface deviceFactory,
int pinNumber,
boolean activeHigh,
boolean initialValue) |
DigitalOutputDevice(int pinNumber)
Defaults to active high logic, initial value is off.
|
DigitalOutputDevice(int pinNumber,
boolean activeHigh,
boolean initialValue) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
boolean |
isOn()
Get the device on / off status.
|
void |
off()
Turn off the device.
|
void |
on()
Turn on the device.
|
void |
onOffLoop(float onTime,
float offTime,
int n,
boolean background)
Toggle the device on-off.
|
void |
setOn(boolean on)
Turn the device on or off.
|
void |
setValueUnsafe(boolean value)
Unsafe operation that has no synchronisation checks and doesn't compensate
for active low logic.
|
void |
toggle()
Toggle the state of the device.
|
getPinNumber
public static final int INFINITE_ITERATIONS
public DigitalOutputDevice(int pinNumber) throws RuntimeIOException
pinNumber
- GPIO pin to which the output device is connected.RuntimeIOException
- If an I/O error occurred.public DigitalOutputDevice(int pinNumber, boolean activeHigh, boolean initialValue) throws RuntimeIOException
pinNumber
- GPIO pin to which the output device is connected.activeHigh
- If true then setting the value to true will turn on the
connected device.initialValue
- Initial output value.RuntimeIOException
- If an I/O error occurred.public DigitalOutputDevice(GpioDeviceFactoryInterface deviceFactory, int pinNumber, boolean activeHigh, boolean initialValue) throws RuntimeIOException
deviceFactory
- Device factory to use to construct the device.pinNumber
- GPIO pin to which the output device is connected.activeHigh
- If true then setting the value to true will turn on the
connected device.initialValue
- Initial output value.RuntimeIOException
- If an I/O error occurred.public void close()
public void on() throws RuntimeIOException
RuntimeIOException
- If an I/O error occurred.public void off() throws RuntimeIOException
RuntimeIOException
- If an I/O error occurred.public void toggle() throws RuntimeIOException
RuntimeIOException
- If an I/O error occurred.public boolean isOn() throws RuntimeIOException
RuntimeIOException
- If an I/O error occurred.public void setOn(boolean on) throws RuntimeIOException
on
- New on/off value.RuntimeIOException
- If an I/O error occurred.public void setValueUnsafe(boolean value) throws RuntimeIOException
value
- The new valueRuntimeIOException
- If an I/O error occurspublic void onOffLoop(float onTime, float offTime, int n, boolean background) throws RuntimeIOException
onTime
- On time in seconds.offTime
- Off time in seconds.n
- Number of iterations. Set to <0 to blink indefinitely.background
- If true start a background thread to control the blink and
return immediately. If false, only return once the blink
iterations have finished.RuntimeIOException
- If an I/O error occursCopyright © 2016 mattjlewis. All rights reserved.