[wpimath] Fix Debouncer type-changing behavior (#7870)

Closes #7867

Properly resets the baseline upon switching the debounce type, and adds
a test for such.

Signed-off-by: swurl <swurl@swurl.xyz>
This commit is contained in:
crueter
2025-04-26 01:05:31 -04:00
committed by GitHub
parent 3960045663
commit 0695a4db89
5 changed files with 12 additions and 15 deletions

View File

@@ -10,15 +10,7 @@ using namespace frc;
Debouncer::Debouncer(units::second_t debounceTime, DebounceType type)
: m_debounceTime(debounceTime), m_debounceType(type) {
switch (type) {
case DebounceType::kBoth: // fall-through
case DebounceType::kRising:
m_baseline = false;
break;
case DebounceType::kFalling:
m_baseline = true;
break;
}
m_baseline = m_debounceType == DebounceType::kFalling;
ResetTimer();
}