From 3104cc7e24ed7dc2b5bccb8fa8e4fbaa90384695 Mon Sep 17 00:00:00 2001 From: Vasily Davydov Date: Mon, 17 Oct 2022 15:00:10 +0300 Subject: [PATCH] switch-controller: rename b_state to b_pressed --- SwitchController/inc/SwitchController.h | 2 +- SwitchController/src/SwitchController.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/SwitchController/inc/SwitchController.h b/SwitchController/inc/SwitchController.h index 5a9b147..3af237a 100644 --- a/SwitchController/inc/SwitchController.h +++ b/SwitchController/inc/SwitchController.h @@ -26,7 +26,7 @@ private: DigitalIoPin *b; Timer *t; StateHandler *h; - bool b_state; + bool b_pressed; int b_mode; void buttonOnHold (); void buttonInLoop (); diff --git a/SwitchController/src/SwitchController.cpp b/SwitchController/src/SwitchController.cpp index e0e75e0..e294417 100644 --- a/SwitchController/src/SwitchController.cpp +++ b/SwitchController/src/SwitchController.cpp @@ -13,7 +13,7 @@ SwitchController::SwitchController (DigitalIoPin *button, Timer *timer, b = button; t = timer; h = handler; - b_state = false; + b_pressed = false; b_mode = button_mode; } @@ -27,20 +27,20 @@ SwitchController::listen () { int timer = t->getCounter (); /** Button is pressed for the first time*/ - if (b->read () && !b_state) + if (b->read () && !b_pressed) { t->resetCounter (); - b_state = true; + b_pressed = true; } /** Button is released before 2 seconds*/ - if (!b->read () && b_state && timer < 2000) + if (!b->read () && b_pressed && timer < 2000) { h->HandleState (Event (Event::eKey, b_mode)); - b_state = false; + b_pressed = false; t->resetCounter (); } /** Button is pressed after 2 seconds*/ - if (b->read () && b_state && timer >= 2000) + if (b->read () && b_pressed && timer >= 2000) { buttonOnHold (); } @@ -58,7 +58,7 @@ SwitchController::buttonOnHold () { h->HandleState (Event (Event::eKey, b_mode)); } - b_state = false; + b_pressed = false; t->resetCounter (); }