Peripherals: fix double registration of short and long press in Button class
This commit is contained in:
parent
a0639ec3f1
commit
8fbb0efd5d
@ -50,7 +50,7 @@ public:
|
||||
}
|
||||
else if (!is_pressed && was_pressed_)
|
||||
{
|
||||
if (time_held > TIMEOUT_SHORT_PRESS)
|
||||
if (time_held > TIMEOUT_SHORT_PRESS && time_held <= TIMEOUT_LONG_PRESS)
|
||||
new_state = ButtonPress::SHORT_PRESS;
|
||||
|
||||
time_pressed_down_ = 0;
|
||||
|
||||
@ -109,7 +109,6 @@ TEST_CASE("Button reads presses properly.", "[peripherals],[button]")
|
||||
SECTION("Long press is identified properly.")
|
||||
{
|
||||
HAL::millis = Button::TIMEOUT_LONG_PRESS + 2;
|
||||
Gpio::set = false;
|
||||
|
||||
button.update();
|
||||
|
||||
@ -121,6 +120,16 @@ TEST_CASE("Button reads presses properly.", "[peripherals],[button]")
|
||||
button.update();
|
||||
|
||||
REQUIRE(button.getState() == Peripherals::ButtonPress::NOT_PRESSED);
|
||||
|
||||
SECTION("Releasing keeps NOT_PRESSED state.")
|
||||
{
|
||||
HAL::millis += 1;
|
||||
Gpio::set = false;
|
||||
|
||||
button.update();
|
||||
|
||||
REQUIRE(button.getState() == Peripherals::ButtonPress::NOT_PRESSED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user