diff --git a/src/gpio.c b/src/gpio.c index 873fd6c..a3496fe 100644 --- a/src/gpio.c +++ b/src/gpio.c @@ -196,36 +196,3 @@ int Gpio_read_buttons(void) rc |= STATE_BUTTON4; return rc; } - -int Gpio_poll_buttons(void) -{ - int new_state = Gpio_read_buttons(); - int tmp, ndx, mask; - - if (gpio_input(GLINE_BUTTON1) == 0) - new_state |= STATE_BUTTON1; - if (gpio_input(GLINE_BUTTON2) == 0) - new_state |= STATE_BUTTON2; - if (gpio_input(GLINE_BUTTON3) == 0) - new_state |= STATE_BUTTON3; - if (gpio_input(GLINE_BUTTON4) == 0) - new_state |= STATE_BUTTON4; - - if (last_state != new_state) - { - tmp = last_state & ~new_state; - for (ndx = 1, mask = 1; ndx <= 4; ndx++, mask <<= 1) - { - if (tmp & mask) - Log(LDEBUG, "Button %d was released", ndx); - } - tmp = new_state & ~last_state; - for (ndx = 1, mask = 1; ndx <= 4; ndx++, mask <<= 1) - { - if (tmp & mask) - Log(LDEBUG, "Button %d was pressed", ndx); - } - last_state = new_state; - } - return new_state; -} diff --git a/src/gpio.h b/src/gpio.h index 416d4bc..b70caf0 100644 --- a/src/gpio.h +++ b/src/gpio.h @@ -4,6 +4,5 @@ extern int Gpio_setup(void); extern void Gpio_cleanup(void); extern int Gpio_read_buttons(void); -extern int Gpio_poll_buttons(void); #endif /* __GPIO_H_INCLUDED */ diff --git a/src/main.c b/src/main.c index 1490722..d474fc0 100644 --- a/src/main.c +++ b/src/main.c @@ -6,6 +6,7 @@ int main(int argc, char *argv[]) { + int running = 1; MSG msg; TimeInit(); @@ -18,7 +19,7 @@ int main(int argc, char *argv[]) Log(LINFO, "System ready."); - for (;;) + while (running) { if (MqPeek(Sys_Queue, &msg, PEEK_REMOVE)) { @@ -30,6 +31,11 @@ int main(int argc, char *argv[]) case WM_HWBUTTONUP: Log(LINFO, "Button %d was released.", (int)(msg.attrs[0])); + if (msg.attrs[0] == 4) + { + Log(LINFO, "Quitting the message loop."); + running = 0; + } break; default: diff --git a/src/sysinput.c b/src/sysinput.c index c45d6f7..e14291f 100644 --- a/src/sysinput.c +++ b/src/sysinput.c @@ -27,15 +27,9 @@ static void *input_thread(void *arg) for (attr = 1, mask = 1; attr <= 4; attr++, mask <<= 1) { if (up & mask) - { - Log(LDEBUG, "posting WM_HWBUTTONUP(%d)", (int)attr); MqPost1(Sys_Queue, 0, WM_HWBUTTONUP, attr); - } else if (down & mask) - { - Log(LDEBUG, "posting WM_HWBUTTONDOWN(%d)", (int)attr); MqPost1(Sys_Queue, 0, WM_HWBUTTONDOWN, attr); - } } last_bstate = st; }