summaryrefslogtreecommitdiffstats
path: root/buttons.cpp
diff options
context:
space:
mode:
authorConfuSomu2021-04-22 17:36:29 -0400
committerConfuSomu2021-04-22 17:36:29 -0400
commit80974afc2c2d06e72302938198de4ead2cc03f22 (patch)
tree5d7b7b182454c57b65b968a1890a5f9acea271b5 /buttons.cpp
parentef5953db945206a916f9c98979e99b80a788d96b (diff)
downloadpico-watch-80974afc2c2d06e72302938198de4ead2cc03f22.tar
pico-watch-80974afc2c2d06e72302938198de4ead2cc03f22.tar.gz
pico-watch-80974afc2c2d06e72302938198de4ead2cc03f22.zip
Fix race condition on HOME press while rendering
This existed because waiting for the app to finish rendering was done in a blocking manner, meaning that the rendering state would never end. This would block the microcontroller in a loop. This was fixed by rewriting the part related to app switching to correctly do the switching while the app is not rendering.
Diffstat (limited to 'buttons.cpp')
-rw-r--r--buttons.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/buttons.cpp b/buttons.cpp
index c919562..15e0ff7 100644
--- a/buttons.cpp
+++ b/buttons.cpp
@@ -5,7 +5,7 @@
#include "api.hpp"
// From pico-watch.c:
extern int app_btnpressed(int app_id, uint gpio);
-extern void app_switch(int old_appid, int new_appid);
+extern void app_switch_request(int);
extern Api app_api;
//const uint BUTTON_PINS[] = {BUTTON_HOME, BUTTON_SELECT, BUTTON_MODE, BUTTON_UP, BUTTON_DOWN};
@@ -15,7 +15,7 @@ void gpio_interrupt_cb(uint gpio, uint32_t events) {
if (app_api.m_interpret_button_press) {
if (gpio == BUTTON_HOME && (g_s.current_app != 0)) // Home app
- app_switch(g_s.current_app, 0);
+ app_switch_request(0);
else
app_btnpressed(g_s.current_app, gpio);
}