public class DigitalOutput extends SendableBase implements Sendable
Constructor and Description |
---|
DigitalOutput(int channel)
Create an instance of a digital output.
|
Modifier and Type | Method and Description |
---|---|
void |
disablePWM()
Change this line from a PWM output back to a static Digital Output line.
|
void |
enablePWM(double initialDutyCycle)
Enable a PWM Output on this line.
|
void |
free()
Free the resources associated with a digital output.
|
boolean |
get()
Gets the value being output from the Digital Output.
|
int |
getChannel()
Get the GPIO channel number that this object represents.
|
void |
initSendable(SendableBuilder builder)
Initializes this
Sendable object. |
boolean |
isPulsing()
Determine if the pulse is still going.
|
void |
pulse(double pulseLength)
Generate a single pulse.
|
void |
set(boolean value)
Set the value of a digital output.
|
void |
setPWMRate(double rate)
Change the PWM frequency of the PWM output on a Digital Output line.
|
void |
updateDutyCycle(double dutyCycle)
Change the duty-cycle that is being generated on the line.
|
addChild, getName, getSubsystem, setName, setName, setName, setSubsystem
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getName, getSubsystem, setName, setName, setSubsystem
public DigitalOutput(int channel)
channel
- the DIO channel to use for the digital output. 0-9 are on-board, 10-25 are on
the MXPpublic void free()
free
in class SendableBase
public void set(boolean value)
value
- true is on, off is falsepublic boolean get()
public int getChannel()
public void pulse(double pulseLength)
pulseLength
- The length of the pulse.public boolean isPulsing()
public void setPWMRate(double rate)
The valid range is from 0.6 Hz to 19 kHz. The frequency resolution is logarithmic.
There is only one PWM frequency for all channels.
rate
- The frequency to output all digital output PWM signals.public void enablePWM(double initialDutyCycle)
Allocate one of the 6 DO PWM generator resources.
Supply the initial duty-cycle to output so as to avoid a glitch when first starting.
The resolution of the duty cycle is 8-bit for low frequencies (1kHz or less) but is reduced the higher the frequency of the PWM signal is.
initialDutyCycle
- The duty-cycle to start generating. [0..1]public void disablePWM()
Free up one of the 6 DO PWM generator resources that were in use.
public void updateDutyCycle(double dutyCycle)
The resolution of the duty cycle is 8-bit for low frequencies (1kHz or less) but is reduced the higher the frequency of the PWM signal is.
dutyCycle
- The duty-cycle to change to. [0..1]public void initSendable(SendableBuilder builder)
Sendable
Sendable
object.initSendable
in interface Sendable
builder
- sendable builder