switch-controller: rename b_state to b_pressed
This commit is contained in:
parent
b8780772a1
commit
3104cc7e24
@ -26,7 +26,7 @@ private:
|
|||||||
DigitalIoPin *b;
|
DigitalIoPin *b;
|
||||||
Timer *t;
|
Timer *t;
|
||||||
StateHandler *h;
|
StateHandler *h;
|
||||||
bool b_state;
|
bool b_pressed;
|
||||||
int b_mode;
|
int b_mode;
|
||||||
void buttonOnHold ();
|
void buttonOnHold ();
|
||||||
void buttonInLoop ();
|
void buttonInLoop ();
|
||||||
|
|||||||
@ -13,7 +13,7 @@ SwitchController::SwitchController (DigitalIoPin *button, Timer *timer,
|
|||||||
b = button;
|
b = button;
|
||||||
t = timer;
|
t = timer;
|
||||||
h = handler;
|
h = handler;
|
||||||
b_state = false;
|
b_pressed = false;
|
||||||
b_mode = button_mode;
|
b_mode = button_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -27,20 +27,20 @@ SwitchController::listen ()
|
|||||||
{
|
{
|
||||||
int timer = t->getCounter ();
|
int timer = t->getCounter ();
|
||||||
/** Button is pressed for the first time*/
|
/** Button is pressed for the first time*/
|
||||||
if (b->read () && !b_state)
|
if (b->read () && !b_pressed)
|
||||||
{
|
{
|
||||||
t->resetCounter ();
|
t->resetCounter ();
|
||||||
b_state = true;
|
b_pressed = true;
|
||||||
}
|
}
|
||||||
/** Button is released before 2 seconds*/
|
/** 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));
|
h->HandleState (Event (Event::eKey, b_mode));
|
||||||
b_state = false;
|
b_pressed = false;
|
||||||
t->resetCounter ();
|
t->resetCounter ();
|
||||||
}
|
}
|
||||||
/** Button is pressed after 2 seconds*/
|
/** Button is pressed after 2 seconds*/
|
||||||
if (b->read () && b_state && timer >= 2000)
|
if (b->read () && b_pressed && timer >= 2000)
|
||||||
{
|
{
|
||||||
buttonOnHold ();
|
buttonOnHold ();
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ SwitchController::buttonOnHold ()
|
|||||||
{
|
{
|
||||||
h->HandleState (Event (Event::eKey, b_mode));
|
h->HandleState (Event (Event::eKey, b_mode));
|
||||||
}
|
}
|
||||||
b_state = false;
|
b_pressed = false;
|
||||||
t->resetCounter ();
|
t->resetCounter ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user