mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Merge "Accumulators wait for the next sample after reset"
This commit is contained in:
committed by
Gerrit Code Review
commit
e0e2b498a5
@@ -310,6 +310,14 @@ public class AnalogInput extends SensorBase implements PIDSource,
|
||||
status.order(ByteOrder.LITTLE_ENDIAN);
|
||||
AnalogJNI.resetAccumulator(m_port, status.asIntBuffer());
|
||||
HALUtil.checkStatus(status.asIntBuffer());
|
||||
|
||||
// Wait until the next sample, so the next call to getAccumulator*()
|
||||
// won't have old values.
|
||||
final double sampleTime = 1.0 / getGlobalSampleRate();
|
||||
final double overSamples = 1 << getOversampleBits();
|
||||
final double averageSamples = 1 << getAverageBits();
|
||||
Timer.delay(sampleTime * overSamples * averageSamples);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user