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
@@ -17,12 +17,11 @@ PressedButtonScheduler::PressedButtonScheduler(bool last, Trigger* button,
|
||||
: ButtonScheduler(last, button, orders) {}
|
||||
|
||||
void PressedButtonScheduler::Execute() {
|
||||
if (m_button->Grab()) {
|
||||
if (!m_pressedLast) {
|
||||
m_pressedLast = true;
|
||||
m_command->Start();
|
||||
}
|
||||
} else {
|
||||
m_pressedLast = false;
|
||||
bool pressed = m_button->Grab();
|
||||
|
||||
if (!m_pressedLast && pressed) {
|
||||
m_command->Start();
|
||||
}
|
||||
|
||||
m_pressedLast = pressed;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user