mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[hal] Convert DutyCycle Raw output to be a high time measurement (#4466)
The existing raw time has an issue where it jumps around, as in the FPGA if the frequency is not a multiple or divisor of 25 Mhz it jumps around by 1 every second. While waiting on an FPGA change, update the API to make raw output give nanoseconds rather then a scaled value. This does a longer read cycle to get the correct value, but in the future if a fast FPGA function is added this can be easily changed.
This commit is contained in:
@@ -73,21 +73,19 @@ public class DutyCycle implements Sendable, AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw output ratio of the duty cycle signal.
|
||||
* Get the raw high time of the duty cycle signal.
|
||||
*
|
||||
* <p>0 means always low, an output equal to getOutputScaleFactor() means always high.
|
||||
*
|
||||
* @return output ratio in raw units
|
||||
* @return high time of last pulse in nanoseconds
|
||||
*/
|
||||
public int getOutputRaw() {
|
||||
return DutyCycleJNI.getOutputRaw(m_handle);
|
||||
public int getHighTimeNanoseconds() {
|
||||
return DutyCycleJNI.getHighTime(m_handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the scale factor of the output.
|
||||
*
|
||||
* <p>An output equal to this value is always high, and then linearly scales down to 0. Divide the
|
||||
* result of getOutputRaw by this in order to get the percentage between 0 and 1.
|
||||
* <p>An output equal to this value is always high, and then linearly scales down to 0. Divide a
|
||||
* raw result by this in order to get the percentage between 0 and 1. Used by DMA.
|
||||
*
|
||||
* @return the output scale factor
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user