public class PwmOutputDevice extends GpioDevice
Modifier and Type | Field and Description |
---|---|
static int |
INFINITE_ITERATIONS |
pinNumber
Constructor and Description |
---|
PwmOutputDevice(int pinNumber) |
PwmOutputDevice(int pinNumber,
float initialValue) |
PwmOutputDevice(PwmOutputDeviceFactoryInterface pwmDeviceFactory,
int pinNumber,
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())
). |
getPinNumber
public static final int INFINITE_ITERATIONS
public PwmOutputDevice(int pinNumber) throws RuntimeIOException
pinNumber
- GPIO pin to which the output device is connected.RuntimeIOException
- If an I/O error occurred.public PwmOutputDevice(int pinNumber, float initialValue) throws RuntimeIOException
pinNumber
- GPIO pin 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 pinNumber, float initialValue) throws RuntimeIOException
pwmDeviceFactory
- Device factory to use to provision this device.pinNumber
- GPIO pin to which the output device is connected.initialValue
- Initial output value (0..1).RuntimeIOException
- If an I/O error occurred.public void close()
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
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 mattjlewis. All rights reserved.