summaryrefslogtreecommitdiffstats
path: root/buttons.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'buttons.cpp')
-rw-r--r--buttons.cpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/buttons.cpp b/buttons.cpp
index b86ac5d..c919562 100644
--- a/buttons.cpp
+++ b/buttons.cpp
@@ -6,28 +6,22 @@
// From pico-watch.c:
extern int app_btnpressed(int app_id, uint gpio);
extern void app_switch(int old_appid, int new_appid);
-extern int current_app;
extern Api app_api;
-// Debounce control
-// See https://www.raspberrypi.org/forums/viewtopic.php?f=145&t=301522#p1812063
-unsigned long button_last_pressed_time;
-const int button_delay_time = 50; // 50ms worked fine for me .... change it to your needs/specs.
-
//const uint BUTTON_PINS[] = {BUTTON_HOME, BUTTON_SELECT, BUTTON_MODE, BUTTON_UP, BUTTON_DOWN};
void gpio_interrupt_cb(uint gpio, uint32_t events) {
- if ((to_ms_since_boot(get_absolute_time())-button_last_pressed_time)>button_delay_time) {
+ if ((to_ms_since_boot(get_absolute_time())-g_s.button_last_pressed_time)>g_s.button_delay_time) {
if (app_api.m_interpret_button_press) {
- if (gpio == BUTTON_HOME && (current_app != 0)) // Home app
- app_switch(current_app, 0);
+ if (gpio == BUTTON_HOME && (g_s.current_app != 0)) // Home app
+ app_switch(g_s.current_app, 0);
else
- app_btnpressed(current_app, gpio);
+ app_btnpressed(g_s.current_app, gpio);
}
app_api.button_last_set(gpio);
- button_last_pressed_time = to_ms_since_boot(get_absolute_time());
+ g_s.button_last_pressed_time = to_ms_since_boot(get_absolute_time());
}
}
@@ -56,5 +50,5 @@ void init_buttons() {
gpio_set_irq_enabled_with_callback(button, GPIO_IRQ_EDGE_FALL , true, &gpio_interrupt_cb);
}
*/
- button_last_pressed_time = to_ms_since_boot(get_absolute_time());
+ g_s.button_last_pressed_time = to_ms_since_boot(get_absolute_time());
}