edu.wpi.first.wpilibj
Class DigitalOutput

java.lang.Object
  extended by edu.wpi.first.wpilibj.SensorBase
      extended by edu.wpi.first.wpilibj.InterruptableSensorBase
          extended by edu.wpi.first.wpilibj.DigitalSource
              extended by edu.wpi.first.wpilibj.DigitalOutput
All Implemented Interfaces:
IDevice, IInputOutput, FrcBotSimComponent

public class DigitalOutput
extends DigitalSource
implements IInputOutput

Class to write digital outputs. This class will wrtie digital outputs. Other devices that are implemented elsewhere will automatically allocate digital inputs and outputs as required.


Field Summary
 
Fields inherited from class edu.wpi.first.wpilibj.InterruptableSensorBase
interrupts, m_interrupt, m_interruptIndex, m_manager
 
Fields inherited from class edu.wpi.first.wpilibj.SensorBase
kAnalogChannels, kAnalogModules, kDigitalChannels, kPwmChannels, kRelayChannels, kSolenoidChannels, kSolenoidModules, kSystemClockTicksPerMicrosecond, n_simProperties
 
Constructor Summary
DigitalOutput(int channel)
          Create an instance of a digital output.
DigitalOutput(int moduleNumber, int channel)
          Create an instance of a digital output.
 
Method Summary
 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 getAnalogTriggerForRouting()
          Is this an analog trigger
 int getChannel()
           
 int getChannelForRouting()
          Get the channel routing number
 int getModuleForRouting()
          Get the module routing number
 boolean isPulsing()
          Determine if the pulse is still going.
 void pulse(double length)
          Output a single pulse on the digital output line.
 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.
 
Methods inherited from class edu.wpi.first.wpilibj.InterruptableSensorBase
allocateInterrupts, cancelInterrupts, disableInterrupts, enableInterrupts, readInterruptTimestamp, waitForInterrupt
 
Methods inherited from class edu.wpi.first.wpilibj.SensorBase
checkAnalogChannel, checkAnalogModule, checkDigitalChannel, checkDigitalModule, checkPWMChannel, checkPWMModule, checkRelayChannel, checkRelayModule, checkSolenoidChannel, checkSolenoidModule, getDefaultAnalogModule, getDefaultDigitalModule, getDefaultSolenoidModule, getSimProperties, setDefaultAnalogModule, setDefaultDigitalModule, setDefaultSolenoidModule
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DigitalOutput

public DigitalOutput(int moduleNumber,
                     int channel)
Create an instance of a digital output. Create an instance of a digital output given a module number and channel.

Parameters:
moduleNumber - The number of the digital module to use
channel - the port to use for the digital output

DigitalOutput

public DigitalOutput(int channel)
Create an instance of a digital output. Create a digital output given a channel. The default module is used.

Parameters:
channel - the port to use for the digital output
Method Detail

free

public void free()
Free the resources associated with a digital output.

Overrides:
free in class SensorBase

set

public void set(boolean value)
Set the value of a digital output.

Parameters:
value - true is on, off is false

getChannel

public int getChannel()
Returns:
The GPIO channel number that this object represents.

pulse

public void pulse(double length)
Output a single pulse on the digital output line. Send a single pulse on the digital output line where the pulse diration is specified in seconds. Maximum pulse length is 0.0016 seconds.

Parameters:
length - The pulselength in seconds

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 per digital module.

Parameters:
rate - The frequency to output all digital output PWM signals on this module.

enablePWM

public void enablePWM(double initialDutyCycle)
Enable a PWM Output on this line. Allocate one of the 4 DO PWM generator resources from this module. 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 4 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]

getChannelForRouting

public int getChannelForRouting()
Description copied from class: DigitalSource
Get the channel routing number

Specified by:
getChannelForRouting in class DigitalSource
Returns:
The value to be written to the channel field of a routing mux.

getModuleForRouting

public int getModuleForRouting()
Description copied from class: DigitalSource
Get the module routing number

Specified by:
getModuleForRouting in class DigitalSource
Returns:
The value to be written to the module field of a routing mux.

getAnalogTriggerForRouting

public boolean getAnalogTriggerForRouting()
Description copied from class: DigitalSource
Is this an analog trigger

Specified by:
getAnalogTriggerForRouting in class DigitalSource
Returns:
The value to be written to the analog trigger field of a routing mux.