summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/action.c26
-rw-r--r--firmware/export/config.h5
2 files changed, 22 insertions, 9 deletions
diff --git a/apps/action.c b/apps/action.c
index 0b21a27ea9..e192daae4e 100644
--- a/apps/action.c
+++ b/apps/action.c
@@ -151,6 +151,10 @@ static inline int get_next_context(const struct button_mapping *items, int i)
}
#if defined(HAVE_GUI_BOOST) && defined(HAVE_ADJUSTABLE_CPU_FREQ)
+
+/* Timeout for gui boost in seconds. */
+#define GUI_BOOST_TIMEOUT (HZ)
+
/* Helper function which is called to boost / unboost CPU. This function
* avoids to increase boost_count with each call of gui_boost(). */
static void gui_boost(bool want_to_boost)
@@ -168,6 +172,15 @@ static void gui_boost(bool want_to_boost)
boosted = false;
}
}
+
+/* gui_unboost_callback() is called GUI_BOOST_TIMEOUT seconds after the
+ * last wheel scrolling event. */
+static int gui_unboost_callback(struct timeout *tmo)
+{
+ (void)tmo;
+ gui_boost(false);
+ return 0;
+}
#endif
/*
@@ -194,7 +207,6 @@ static int get_action_worker(int context, int timeout,
int ret = ACTION_UNKNOWN;
static int last_context = CONTEXT_STD;
-
send_event(GUI_EVENT_ACTIONUPDATE, NULL);
if (timeout == TIMEOUT_NOBLOCK)
@@ -205,19 +217,15 @@ static int get_action_worker(int context, int timeout,
button = button_get_w_tmo(timeout);
#if defined(HAVE_GUI_BOOST) && defined(HAVE_ADJUSTABLE_CPU_FREQ)
- /* Boost the CPU in case of wheel scrolling activity in the defined contexts.
- * Unboost the CPU after timeout. */
- static long last_boost_tick;
+ static struct timeout gui_unboost;
+ /* Boost the CPU in case of wheel scrolling activity in the defined contexts.
+ * Call unboost with a timeout of GUI_BOOST_TIMEOUT. */
if ((button&(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD)) &&
(context == CONTEXT_STD || context == CONTEXT_LIST ||
context == CONTEXT_MAINMENU || context == CONTEXT_TREE))
{
- last_boost_tick = current_tick;
gui_boost(true);
- }
- else if (TIME_AFTER(current_tick, last_boost_tick + HZ))
- {
- gui_boost(false);
+ timeout_register(&gui_unboost, gui_unboost_callback, GUI_BOOST_TIMEOUT, 0);
}
#endif
diff --git a/firmware/export/config.h b/firmware/export/config.h
index 65c27ce5e0..55a194817d 100644
--- a/firmware/export/config.h
+++ b/firmware/export/config.h
@@ -983,6 +983,11 @@ Lyre prototype 1 */
#define INCLUDE_TIMEOUT_API
#endif /* HAVE_USB_CHARGING_ENABLE && HAVE_USBSTACK */
+#if defined(HAVE_GUI_BOOST) && defined(HAVE_ADJUSTABLE_CPU_FREQ)
+/* Timeout objects required if GUI boost is enabled */
+#define INCLUDE_TIMEOUT_API
+#endif /* HAVE_GUI_BOOST && HAVE_ADJUSTABLE_CPU_FREQ */
+
#if defined(HAVE_USBSTACK) || (CONFIG_STORAGE & STORAGE_NAND)
#define STORAGE_GET_INFO
#endif