mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Implement PCM One Shot feature. Fixes artf4731 (#539)
This commit is contained in:
committed by
Peter Johnson
parent
a338ee8be0
commit
7a250a1b93
@@ -111,6 +111,36 @@ bool Solenoid::IsBlackListed() const {
|
||||
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()
|
||||
*/
|
||||
void Solenoid::SetPulseDuration(double durationSeconds) {
|
||||
int32_t durationMS = durationSeconds * 1000;
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
HAL_SetOneShotDuration(m_solenoidHandle, durationMS, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the PCM to generate a pulse of the duration set in
|
||||
* setPulseDuration.
|
||||
*
|
||||
* @see setPulseDuration()
|
||||
*/
|
||||
void Solenoid::StartPulse() {
|
||||
if (StatusIsFatal()) return;
|
||||
int32_t status = 0;
|
||||
HAL_FireOneShot(m_solenoidHandle, &status);
|
||||
wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
|
||||
}
|
||||
|
||||
void Solenoid::UpdateTable() {
|
||||
if (m_valueEntry) m_valueEntry.SetBoolean(Get());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user