[newCommands] Trigger: Allow override of debounce type (#3845)

Previously Trigger could only be debounced on rising edges.
This change preserves the default behavior but adds the capability to override it.
This commit is contained in:
Oblarg
2021-12-29 19:10:43 -05:00
committed by GitHub
parent aa9dfabde2
commit eee29daaf9
3 changed files with 28 additions and 10 deletions

View File

@@ -139,8 +139,10 @@ Trigger Trigger::CancelWhenActive(Command* command) {
return *this;
}
Trigger Trigger::Debounce(units::second_t debounceTime) {
return Trigger([debouncer = frc::Debouncer(debounceTime), *this]() mutable {
return debouncer.Calculate(m_isActive());
});
Trigger Trigger::Debounce(units::second_t debounceTime,
frc::Debouncer::DebounceType type) {
return Trigger(
[debouncer = frc::Debouncer(debounceTime, type), *this]() mutable {
return debouncer.Calculate(m_isActive());
});
}