Package edu.wpi.first.wpilibj
Class DigitalOutput
- java.lang.Object
-
- edu.wpi.first.wpilibj.InterruptableSensorBase
-
- edu.wpi.first.wpilibj.DigitalSource
-
- edu.wpi.first.wpilibj.DigitalOutput
-
- All Implemented Interfaces:
Sendable,AutoCloseable
public class DigitalOutput extends DigitalSource implements Sendable, AutoCloseable
Class to write digital outputs. This class will write digital outputs. Other devices that are implemented elsewhere will automatically allocate digital inputs and outputs as required.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class edu.wpi.first.wpilibj.InterruptableSensorBase
InterruptableSensorBase.WaitResult
-
-
Field Summary
-
Fields inherited from class edu.wpi.first.wpilibj.InterruptableSensorBase
m_interrupt, m_isSynchronousInterrupt
-
-
Constructor Summary
Constructors Constructor Description DigitalOutput(int channel)Create an instance of a digital output.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voiddisablePWM()Change this line from a PWM output back to a static Digital Output line.voidenablePWM(double initialDutyCycle)Enable a PWM Output on this line.booleanget()Gets the value being output from the Digital Output.intgetAnalogTriggerTypeForRouting()Get the analog trigger type.intgetChannel()Get the GPIO channel number that this object represents.intgetPortHandleForRouting()Get the HAL Port Handle.voidinitSendable(SendableBuilder builder)Initializes thisSendableobject.booleanisAnalogTrigger()Is this an analog trigger.booleanisPulsing()Determine if the pulse is still going.voidpulse(double pulseLength)Generate a single pulse.voidset(boolean value)Set the value of a digital output.voidsetPWMRate(double rate)Change the PWM frequency of the PWM output on a Digital Output line.voidsetSimDevice(SimDevice device)Indicates this input is used by a simulated device.voidupdateDutyCycle(double dutyCycle)Change the duty-cycle that is being generated on the line.-
Methods inherited from class edu.wpi.first.wpilibj.InterruptableSensorBase
allocateInterrupts, cancelInterrupts, disableInterrupts, enableInterrupts, readFallingTimestamp, readRisingTimestamp, requestInterrupts, requestInterrupts, requestInterrupts, setUpSourceEdge, waitForInterrupt, waitForInterrupt
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface edu.wpi.first.wpilibj.Sendable
addChild, getName, getSubsystem, setName, setName, setName, setName, setSubsystem
-
-
-
-
Method Detail
-
close
public void close()
- Specified by:
closein interfaceAutoCloseable- Overrides:
closein classInterruptableSensorBase
-
set
public void set(boolean value)
Set the value of a digital output.- Parameters:
value- true is on, off is false
-
get
public boolean get()
Gets the value being output from the Digital Output.- Returns:
- the state of the digital output.
-
getChannel
public int getChannel()
Get the GPIO channel number that this object represents.- Specified by:
getChannelin classDigitalSource- Returns:
- The GPIO channel number.
-
pulse
public void pulse(double pulseLength)
Generate a single pulse. There can only be a single pulse going at any time.- Parameters:
pulseLength- The length of the pulse.
-
isPulsing
public boolean isPulsing()
Determine if the pulse is still going. Determine if a previously started pulse is still going.- Returns:
- true if pulsing
-
setPWMRate
public void setPWMRate(double rate)
Change the PWM frequency of the PWM output on a Digital Output line.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.
- Parameters:
rate- The frequency to output all digital output PWM signals.
-
enablePWM
public void enablePWM(double initialDutyCycle)
Enable a PWM Output on this line.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.
- Parameters:
initialDutyCycle- The duty-cycle to start generating. [0..1]
-
disablePWM
public void disablePWM()
Change this line from a PWM output back to a static Digital Output line.Free up one of the 6 DO PWM generator resources that were in use.
-
updateDutyCycle
public void updateDutyCycle(double dutyCycle)
Change the duty-cycle that is being generated on the line.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.
- Parameters:
dutyCycle- The duty-cycle to change to. [0..1]
-
setSimDevice
public void setSimDevice(SimDevice device)
Indicates this input is used by a simulated device.- Parameters:
device- simulated device handle
-
initSendable
public void initSendable(SendableBuilder builder)
Description copied from interface:SendableInitializes thisSendableobject.- Specified by:
initSendablein interfaceSendable- Parameters:
builder- sendable builder
-
isAnalogTrigger
public boolean isAnalogTrigger()
Is this an analog trigger.- Specified by:
isAnalogTriggerin classDigitalSource- Returns:
- true if this is an analog trigger
-
getAnalogTriggerTypeForRouting
public int getAnalogTriggerTypeForRouting()
Get the analog trigger type.- Specified by:
getAnalogTriggerTypeForRoutingin classInterruptableSensorBase- Returns:
- false
-
getPortHandleForRouting
public int getPortHandleForRouting()
Get the HAL Port Handle.- Specified by:
getPortHandleForRoutingin classInterruptableSensorBase- Returns:
- The HAL Handle to the specified source.
-
-