mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[hal, wpilibj] Add missing distance per pulse functions to EncoderSim (#4928)
Also fix C++ and Java EncoderSim.setDistancePerPulse() not propagating value to SimEncoderData.
This commit is contained in:
@@ -303,6 +303,38 @@ public class EncoderSim {
|
||||
EncoderDataJNI.setSamplesToAverage(m_index, samplesToAverage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback on the distance per pulse value of this encoder.
|
||||
*
|
||||
* @param callback the callback that will be called whenever the distance per pulse is changed
|
||||
* @param initialNotify if true, the callback will be run on the initial value
|
||||
* @return the {@link CallbackStore} object associated with this callback. Save a reference to
|
||||
* this object so GC doesn't cancel the callback.
|
||||
*/
|
||||
public CallbackStore registerDistancePerPulseCallback(
|
||||
NotifyCallback callback, boolean initialNotify) {
|
||||
int uid = EncoderDataJNI.registerDistancePerPulseCallback(m_index, callback, initialNotify);
|
||||
return new CallbackStore(m_index, uid, EncoderDataJNI::cancelDistancePerPulseCallback);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the distance per pulse value.
|
||||
*
|
||||
* @return the distance per pulse value
|
||||
*/
|
||||
public double getDistancePerPulse() {
|
||||
return EncoderDataJNI.getDistancePerPulse(m_index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the distance per pulse value.
|
||||
*
|
||||
* @param samplesToAverage the new value
|
||||
*/
|
||||
public void setDistancePerPulse(double samplesToAverage) {
|
||||
EncoderDataJNI.setDistancePerPulse(m_index, samplesToAverage);
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the encoder distance.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user