mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Clean up edge detection logic in ButtonScheduler subclasses (#1340)
This also changes the behavior of whileActive to call start once on the starting edge instead of every loop iteration.
This commit is contained in:
committed by
Peter Johnson
parent
6171856020
commit
a732854866
@@ -14,17 +14,14 @@ using namespace frc;
|
||||
|
||||
CancelButtonScheduler::CancelButtonScheduler(bool last, Trigger* button,
|
||||
Command* orders)
|
||||
: ButtonScheduler(last, button, orders) {
|
||||
pressedLast = m_button->Grab();
|
||||
}
|
||||
: ButtonScheduler(last, button, orders) {}
|
||||
|
||||
void CancelButtonScheduler::Execute() {
|
||||
if (m_button->Grab()) {
|
||||
if (!pressedLast) {
|
||||
pressedLast = true;
|
||||
m_command->Cancel();
|
||||
}
|
||||
} else {
|
||||
pressedLast = false;
|
||||
bool pressed = m_button->Grab();
|
||||
|
||||
if (!m_pressedLast && pressed) {
|
||||
m_command->Cancel();
|
||||
}
|
||||
|
||||
m_pressedLast = pressed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user