Class DigitalOutput
- All Implemented Interfaces:
AutoCloseable, TelemetryLoggable
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidChange this line from a PWM output back to a static Digital Output line.voidenablePPS(double dutyCycle) Enable a PWM PPS (Pulse Per Second) Output on this line.voidenablePWM(double initialDutyCycle) Enable a PWM Output on this line.booleanget()Gets the value being output from the Digital Output.intGet the GPIO channel number that this object represents.Gets the telemetry table type.booleanDetermine if the pulse is still going.voidlogTo(TelemetryTable table) Logs the object to aTelemetryTable.voidpulse(double pulseLength) Output a single pulse on the digital output line.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.
-
Constructor Details
-
DigitalOutput
public DigitalOutput(int channel) Create an instance of a digital output. Create an instance of a digital output given a channel.- Parameters:
channel- the SmartIO channel to use for the digital output.
-
-
Method Details
-
close
public void close()- Specified by:
closein interfaceAutoCloseable
-
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.- Returns:
- The GPIO channel number.
-
pulse
public void pulse(double pulseLength) Output a single pulse on the digital output line.Send a single pulse on the digital output line where the pulse duration is specified in seconds. Maximum of 65535 microseconds.
- Parameters:
pulseLength- The pulse length 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 for all channels.
- Parameters:
rate- The frequency to output all digital output PWM signals.
-
enablePPS
public void enablePPS(double dutyCycle) Enable a PWM PPS (Pulse Per Second) Output on this line.Allocate one of the 6 DO PWM generator resources.
Supply the duty-cycle to output.
The resolution of the duty cycle is 8-bit.
- Parameters:
dutyCycle- The duty-cycle to start generating. [0..1]
-
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 in order 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
Indicates this input is used by a simulated device.- Parameters:
device- simulated device handle
-
logTo
Description copied from interface:TelemetryLoggableLogs the object to aTelemetryTable.- Specified by:
logToin interfaceTelemetryLoggable- Parameters:
table- telemetry table
-
getTelemetryType
Description copied from interface:TelemetryLoggableGets the telemetry table type. Default is no specified table type (null). A mismatch in type during logging results in a reported warning, so this should always return the same value.- Specified by:
getTelemetryTypein interfaceTelemetryLoggable- Returns:
- Table type
-