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:
Tyler Veness
2018-09-26 22:55:34 -07:00
committed by Peter Johnson
parent 6171856020
commit a732854866
8 changed files with 70 additions and 88 deletions

View File

@@ -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;
}