mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
Implement PCM One Shot feature. Fixes artf4731 (#539)
This commit is contained in:
committed by
Peter Johnson
parent
a338ee8be0
commit
7a250a1b93
@@ -98,6 +98,30 @@ public class Solenoid extends SolenoidBase implements LiveWindowSendable {
|
||||
return value != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the pulse duration in the PCM. This is used in conjunction with
|
||||
* the startPulse method to allow the PCM to control the timing of a pulse.
|
||||
* The timing can be controlled in 0.01 second increments.
|
||||
*
|
||||
* @param durationSeconds The duration of the pulse, from 0.01 to 2.55 seconds.
|
||||
*
|
||||
* @see #startPulse()
|
||||
*/
|
||||
public void setPulseDuration(double durationSeconds) {
|
||||
long durationMS = (long) (durationSeconds * 1000);
|
||||
SolenoidJNI.setOneShotDuration(m_solenoidHandle, durationMS);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the PCM to generate a pulse of the duration set in
|
||||
* setPulseDuration.
|
||||
*
|
||||
* @see #setPulseDuration()
|
||||
*/
|
||||
public void startPulse() {
|
||||
SolenoidJNI.fireOneShot(m_solenoidHandle);
|
||||
}
|
||||
|
||||
/*
|
||||
* Live Window code, only does anything if live window is activated.
|
||||
*/
|
||||
|
||||
@@ -29,4 +29,8 @@ public class SolenoidJNI extends JNIWrapper {
|
||||
public static native boolean getPCMSolenoidVoltageFault(int module);
|
||||
|
||||
public static native void clearAllPCMStickyFaults(int module);
|
||||
|
||||
public static native void setOneShotDuration(int portHandle, long durationMS);
|
||||
|
||||
public static native void fireOneShot(int portHandle);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user