Class EncoderJNI
java.lang.Object
org.wpilib.hardware.hal.JNIWrapper
org.wpilib.hardware.hal.EncoderJNI
-
Nested Class Summary
Nested classes/interfaces inherited from class JNIWrapper
JNIWrapper.Helper -
Method Summary
Modifier and TypeMethodDescriptionstatic voidfreeEncoder(int encoderHandle) Frees an encoder.static intgetEncoder(int encoderHandle) Gets the current counts of the encoder after encoding type scaling.static doublegetEncoderDecodingScaleFactor(int encoderHandle) Gets the decoding scale factor of the encoder.static booleangetEncoderDirection(int encoderHandle) Gets the last direction the encoder value changed.static doublegetEncoderDistance(int encoderHandle) Gets the current distance traveled by the encoder.static doublegetEncoderDistancePerPulse(int encoderHandle) Gets the user set distance per pulse of the encoder.static intgetEncoderEncodingScale(int encoderHandle) Gets the scale value used to convert raw encoder counts to scaled counts.static intgetEncoderEncodingType(int encoderHandle) Gets the encoding type of the encoder.static intgetEncoderFPGAIndex(int encoderHandle) Gets the FPGA index of the encoder.static doublegetEncoderRate(int encoderHandle) Gets the current rate of the encoder.static intgetEncoderRaw(int encoderHandle) Gets the raw counts of the encoder.static booleangetEncoderStopped(int encoderHandle) Determines if the clock is stopped.static intgetEncodingScaleFactor(int encoderHandle) Gets the scale value used to convert raw encoder counts to scaled counts.static intinitializeEncoder(int aChannel, int bChannel, boolean reverseDirection, int encodingType) Initializes an encoder.static voidresetEncoder(int encoderHandle) Reads the current encoder value.static voidsetEncoderDistancePerPulse(int encoderHandle, double distancePerPulse) Sets the distance traveled per encoder pulse.static voidsetEncoderRateWindow(int encoderHandle, int windowMilliseconds) Sets the time window used to calculate the encoder rate.static voidsetEncoderReverseDirection(int encoderHandle, boolean reverseDirection) Sets if to reverse the direction of the encoder.static voidsetEncoderSimDevice(int handle, int device) Indicates the encoder is used by a simulated device.Methods inherited from class JNIWrapper
forceLoad, suppressUnused
-
Method Details
-
initializeEncoder
public static int initializeEncoder(int aChannel, int bChannel, boolean reverseDirection, int encodingType) Initializes an encoder.- Parameters:
aChannel- the A channelbChannel- the B channelreverseDirection- true to reverse the counting direction from standard, otherwise falseencodingType- the encoding type- Returns:
- the created encoder handle
- See Also:
-
freeEncoder
public static void freeEncoder(int encoderHandle) Frees an encoder.- Parameters:
encoderHandle- the encoder handle- See Also:
-
setEncoderSimDevice
public static void setEncoderSimDevice(int handle, int device) Indicates the encoder is used by a simulated device.- Parameters:
handle- the encoder handledevice- simulated device handle- See Also:
-
getEncoder
public static int getEncoder(int encoderHandle) Gets the current counts of the encoder after encoding type scaling.This is scaled by the value passed during initialization to encodingType.
- Parameters:
encoderHandle- the encoder handle- Returns:
- the current scaled count
- See Also:
-
getEncoderRaw
public static int getEncoderRaw(int encoderHandle) Gets the raw counts of the encoder.This is not scaled by any values.
- Parameters:
encoderHandle- the encoder handle- Returns:
- the raw encoder count
- See Also:
-
getEncodingScaleFactor
public static int getEncodingScaleFactor(int encoderHandle) Gets the scale value used to convert raw encoder counts to scaled counts.Raw counts divided by this value produce the scaled encoder count.
- Parameters:
encoderHandle- the encoder handle- Returns:
- the encoder scale value
- See Also:
-
resetEncoder
public static void resetEncoder(int encoderHandle) Reads the current encoder value.Read the value at this instant. It may still be running, so it reflects the current value. Next time it is read, it might have a different value.
- Parameters:
encoderHandle- the encoder handle- See Also:
-
getEncoderStopped
public static boolean getEncoderStopped(int encoderHandle) Determines if the clock is stopped.Determines if the encoder's current rate is zero.
- Parameters:
encoderHandle- the encoder handle- Returns:
- true if the encoder's current rate is zero
- See Also:
-
getEncoderDirection
public static boolean getEncoderDirection(int encoderHandle) Gets the last direction the encoder value changed.- Parameters:
encoderHandle- the encoder handle- Returns:
- the last direction the encoder value changed
- See Also:
-
getEncoderDistance
public static double getEncoderDistance(int encoderHandle) Gets the current distance traveled by the encoder.This is the encoder count scaled by the distance per pulse set for the encoder.
- Parameters:
encoderHandle- the encoder handle- Returns:
- the encoder distance (units are determined by the units passed to setEncoderDistancePerPulse)
- See Also:
-
getEncoderRate
public static double getEncoderRate(int encoderHandle) Gets the current rate of the encoder.This is the encoder rate scaled by the distance per pulse set for the encoder.
- Parameters:
encoderHandle- the encoder handle- Returns:
- the encoder rate (units are determined by the units passed to setEncoderDistancePerPulse, time value is seconds)
- See Also:
-
setEncoderRateWindow
public static void setEncoderRateWindow(int encoderHandle, int windowMilliseconds) Sets the time window used to calculate the encoder rate.- Parameters:
encoderHandle- the encoder handlewindowMilliseconds- the rate calculation window in milliseconds; valid values are 5 through 255- See Also:
-
setEncoderDistancePerPulse
public static void setEncoderDistancePerPulse(int encoderHandle, double distancePerPulse) Sets the distance traveled per encoder pulse. This is used as a scaling factor for the rate and distance calls.- Parameters:
encoderHandle- the encoder handledistancePerPulse- the distance traveled per encoder pulse (units user defined)- See Also:
-
setEncoderReverseDirection
public static void setEncoderReverseDirection(int encoderHandle, boolean reverseDirection) Sets if to reverse the direction of the encoder.Note that this is not a toggle. It is an absolute set.
- Parameters:
encoderHandle- the encoder handlereverseDirection- true to reverse the direction, false to not.- See Also:
-
getEncoderFPGAIndex
public static int getEncoderFPGAIndex(int encoderHandle) Gets the FPGA index of the encoder.- Parameters:
encoderHandle- the encoder handle- Returns:
- the FPGA index of the encoder
- See Also:
-
getEncoderEncodingScale
public static int getEncoderEncodingScale(int encoderHandle) Gets the scale value used to convert raw encoder counts to scaled counts.Raw counts divided by this value produce the scaled encoder count.
- Parameters:
encoderHandle- the encoder handle- Returns:
- the encoder scale value
- See Also:
-
getEncoderDecodingScaleFactor
public static double getEncoderDecodingScaleFactor(int encoderHandle) Gets the decoding scale factor of the encoder.This is used to perform the scaling from raw to type scaled values.
- Parameters:
encoderHandle- the encoder handle- Returns:
- the scale value for the encoder
- See Also:
-
getEncoderDistancePerPulse
public static double getEncoderDistancePerPulse(int encoderHandle) Gets the user set distance per pulse of the encoder.- Parameters:
encoderHandle- the encoder handle- Returns:
- the set distance per pulse
- See Also:
-
getEncoderEncodingType
public static int getEncoderEncodingType(int encoderHandle) Gets the encoding type of the encoder.- Parameters:
encoderHandle- the encoder handle- Returns:
- the encoding type
- See Also:
-