public class PwmOutputDevice extends GpioDevice implements OutputDeviceInterface
Modifier and Type | Field and Description |
---|---|
static int |
INFINITE_ITERATIONS |
gpio
Constructor and Description |
---|
PwmOutputDevice(int gpio) |
PwmOutputDevice(int gpio,
float initialValue) |
PwmOutputDevice(int gpio,
int pwmFrequency,
float initialValue) |
PwmOutputDevice(PwmOutputDeviceFactoryInterface pwmDeviceFactory,
int gpio,
float initialValue) |
PwmOutputDevice(PwmOutputDeviceFactoryInterface pwmDeviceFactory,
int gpio,
int pwmFrequency,
float initialValue) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
protected void |
fadeInOutLoop(float fadeTime,
int steps,
int iterations,
boolean background) |
float |
getValue()
Get the current PWM output value (0..1).
|
boolean |
isOn()
Get the device on / off status.
|
void |
off()
Turn off the device (same as
setValue(0) ). |
void |
on()
Turn on the device (same as
setValue(1) ). |
protected void |
onOffLoop(float onTime,
float offTime,
int n,
boolean background) |
void |
setValue(float value)
Set the PWM output value (0..1).
|
protected void |
setValueInternal(float value) |
void |
toggle()
Toggle the state of the device (same as
setValue(1 - getvalue())
). |
getGpio
public static final int INFINITE_ITERATIONS
public PwmOutputDevice(int gpio) throws RuntimeIOException
gpio
- GPIO to which the output device is connected.RuntimeIOException
- If an I/O error occurred.public PwmOutputDevice(int gpio, float initialValue) throws RuntimeIOException
gpio
- GPIO to which the output device is connected.initialValue
- Initial output value (0..1).RuntimeIOException
- If an I/O error occurred.public PwmOutputDevice(int gpio, int pwmFrequency, float initialValue) throws RuntimeIOException
gpio
- GPIO to which the output device is connected.initialValue
- Initial output value (0..1).pwmFrequency
- PWM frequency (Hz).RuntimeIOException
- If an I/O error occurred.public PwmOutputDevice(PwmOutputDeviceFactoryInterface pwmDeviceFactory, int gpio, float initialValue) throws RuntimeIOException
pwmDeviceFactory
- Device factory to use to provision this device.gpio
- GPIO to which the output device is connected.initialValue
- Initial output value (0..1).RuntimeIOException
- If an I/O error occurred.public PwmOutputDevice(PwmOutputDeviceFactoryInterface pwmDeviceFactory, int gpio, int pwmFrequency, float initialValue) throws RuntimeIOException
pwmDeviceFactory
- Device factory to use to provision this device.gpio
- GPIO to which the output device is connected.pwmFrequency
- PWM frequency (Hz).initialValue
- Initial output value (0..1).RuntimeIOException
- If an I/O error occurred.public void close()
close
in interface Closeable
close
in interface AutoCloseable
protected void onOffLoop(float onTime, float offTime, int n, boolean background) throws RuntimeIOException
RuntimeIOException
protected void fadeInOutLoop(float fadeTime, int steps, int iterations, boolean background) throws RuntimeIOException
RuntimeIOException
protected void setValueInternal(float value) throws RuntimeIOException
RuntimeIOException
public float getValue() throws RuntimeIOException
RuntimeIOException
- If an I/O error occurred.public void setValue(float value) throws RuntimeIOException
setValue
in interface OutputDeviceInterface
value
- New PWM output value.RuntimeIOException
- If an I/O error occurred.public void on() throws RuntimeIOException
setValue(1)
).RuntimeIOException
- If an I/O error occurred.public void off() throws RuntimeIOException
setValue(0)
).RuntimeIOException
- If an I/O error occurred.public void toggle() throws RuntimeIOException
setValue(1 - getvalue())
).RuntimeIOException
- If an I/O error occurred.public boolean isOn() throws RuntimeIOException
RuntimeIOException
- If an I/O error occurred.Copyright © 2016–2017 mattjlewis. All rights reserved.