Class DutyCycle
java.lang.Object
org.wpilib.hardware.rotation.DutyCycle
- All Implemented Interfaces:
AutoCloseable, TelemetryLoggable
Class to read a duty cycle PWM input.
PWM input signals are specified with a frequency and a ratio of high to low in that frequency. These can be attached to any SmartIO.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Close the DutyCycle and free all resources.doubleGet the frequency of the duty cycle signal.intGet the raw high time of the duty cycle signal.doubleGet the output ratio of the duty cycle signal.intGet the channel of the source.Gets the telemetry table type.voidlogTo(TelemetryTable table) Logs the object to aTelemetryTable.
-
Constructor Details
-
DutyCycle
public DutyCycle(int channel) Constructs a DutyCycle input from a smartio channel.- Parameters:
channel- The channel to use.
-
-
Method Details
-
close
public void close()Close the DutyCycle and free all resources.- Specified by:
closein interfaceAutoCloseable
-
getFrequency
public double getFrequency()Get the frequency of the duty cycle signal.- Returns:
- frequency in Hertz
-
getOutput
public double getOutput()Get the output ratio of the duty cycle signal.0 means always low, 1 means always high.
- Returns:
- output ratio between 0 and 1
-
getHighTimeNanoseconds
public int getHighTimeNanoseconds()Get the raw high time of the duty cycle signal.- Returns:
- high time of last pulse in nanoseconds
-
getSourceChannel
public int getSourceChannel()Get the channel of the source.- Returns:
- the source channel
-
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
-