Skip to content

Commit

Permalink
format
Browse files Browse the repository at this point in the history
  • Loading branch information
ahiuchingau committed Sep 19, 2023
1 parent e44fe66 commit 0e7892a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
9 changes: 3 additions & 6 deletions common/tests/test_debounce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ SCENARIO("debouncing gpio pins works") {
}
}


SCENARIO("debouncing with holdoff cnt works") {
GIVEN("a state value and bounce value") {
debouncer::Debouncer subject{.holdoff_cnt = 2};
Expand All @@ -48,9 +47,7 @@ SCENARIO("debouncing with holdoff cnt works") {
subject.debounce_update(true);
THEN("state updates on the third tick") {
REQUIRE(subject.debounce_state() == true);
THEN("cnt gets reset") {
CHECK(subject.cnt == 0);
}
THEN("cnt gets reset") { CHECK(subject.cnt == 0); }
}
WHEN("reset is called") {
subject.reset();
Expand All @@ -72,11 +69,11 @@ SCENARIO("debouncing with holdoff cnt works") {
subject.debounce_update(false);
subject.debounce_update(false);
THEN("state stays the same on the first two ticks") {
REQUIRE(subject.debounce_state() == true);
REQUIRE(subject.debounce_state() == true);
}
subject.debounce_update(false);
THEN("state updates on the third tick") {
REQUIRE(subject.debounce_state() == false);
REQUIRE(subject.debounce_state() == false);
}
}
WHEN("switching from set to unset before holdoff cnt is reached") {
Expand Down
2 changes: 1 addition & 1 deletion include/common/core/debounce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ struct Debouncer {
// will and we can set it to the new state.

if (new_state == state_bounce) {
cnt ++;
cnt++;
if (cnt == holdoff_cnt) {
// update state only when cnt reaches the holdoff count
state = new_state;
Expand Down

0 comments on commit 0e7892a

Please sign in to comment.