summaryrefslogtreecommitdiffstats
path: root/buttons.cpp
diff options
context:
space:
mode:
authorConfuSomu2021-03-02 21:24:15 -0500
committerConfuSomu2021-03-02 22:51:55 -0500
commiteb01ae68e4ffc5850b1b1182844ae4e60611fe0e (patch)
treef8454457238dc8d318dd5f8d19823e6882fa2d28 /buttons.cpp
parenta304e37c5fb70bb465165105f484a9b2f2c5393f (diff)
downloadpico-watch-eb01ae68e4ffc5850b1b1182844ae4e60611fe0e.tar
pico-watch-eb01ae68e4ffc5850b1b1182844ae4e60611fe0e.tar.gz
pico-watch-eb01ae68e4ffc5850b1b1182844ae4e60611fe0e.zip
Enter shallow sleep when there are no interactions
Current app stops getting refreshed and display is turned off.
Diffstat (limited to 'buttons.cpp')
-rw-r--r--buttons.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/buttons.cpp b/buttons.cpp
index cd94504..7ecc8a4 100644
--- a/buttons.cpp
+++ b/buttons.cpp
@@ -11,20 +11,19 @@ extern Api app_api;
// Debounce control
// See https://www.raspberrypi.org/forums/viewtopic.php?f=145&t=301522#p1812063
-// time is currently shared between all buttons.
-unsigned long button_time;
-const int button_delayTime = 50; // 50ms worked fine for me .... change it to your needs/specs.
+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_time)>button_delayTime) {
+ if ((to_ms_since_boot(get_absolute_time())-button_last_pressed_time)>button_delay_time) {
if (gpio == BUTTON_HOME && (current_app != 0)) // Home app
app_switch(current_app, 0);
else
app_btnpressed(current_app, gpio);
app_api.button_last_set(gpio);
- button_time = to_ms_since_boot(get_absolute_time());
+ button_last_pressed_time = to_ms_since_boot(get_absolute_time());
}
}
@@ -53,5 +52,5 @@ void init_buttons() {
gpio_set_irq_enabled_with_callback(button, GPIO_IRQ_EDGE_FALL , true, &gpio_interrupt_cb);
}
*/
- button_time = to_ms_since_boot(get_absolute_time());
+ button_last_pressed_time = to_ms_since_boot(get_absolute_time());
}