summaryrefslogtreecommitdiffstats
path: root/buttons.cpp
diff options
context:
space:
mode:
authorConfuSomu2021-04-25 17:55:04 -0400
committerConfuSomu2021-04-25 17:55:04 -0400
commit377abedb66676f0102a5a939ff8e91ade75510e4 (patch)
tree48ddd0a3398db4be7eecceb7036796fdbd336e1b /buttons.cpp
parent45d17b9408468cb52ea4e9c27dc23f3682bfa84c (diff)
downloadpico-watch-377abedb66676f0102a5a939ff8e91ade75510e4.tar
pico-watch-377abedb66676f0102a5a939ff8e91ade75510e4.tar.gz
pico-watch-377abedb66676f0102a5a939ff8e91ade75510e4.zip
Move check for button time since press to function
This allows later updating the code to have the check work correctly when start time > current time.
Diffstat (limited to 'buttons.cpp')
-rw-r--r--buttons.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/buttons.cpp b/buttons.cpp
index 15e0ff7..ad1f1dd 100644
--- a/buttons.cpp
+++ b/buttons.cpp
@@ -11,7 +11,7 @@ extern Api app_api;
//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())-g_s.button_last_pressed_time)>g_s.button_delay_time) {
+ if (button_time_since_press() > g_s.button_delay_time) {
if (app_api.m_interpret_button_press) {
if (gpio == BUTTON_HOME && (g_s.current_app != 0)) // Home app
@@ -25,6 +25,11 @@ void gpio_interrupt_cb(uint gpio, uint32_t events) {
}
}
+unsigned long time_since_button_press() {
+ // FIXME: This does not correct overflows
+ return to_ms_since_boot(get_absolute_time())-g_s.button_last_pressed_time;
+}
+
void init_buttons() {
gpio_init(BUTTON_HOME);
gpio_pull_up(BUTTON_HOME);