diff options
-rw-r--r-- | apps/action.c | 26 | ||||
-rw-r--r-- | firmware/export/config.h | 5 |
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) | |||
151 | } | 151 | } |
152 | 152 | ||
153 | #if defined(HAVE_GUI_BOOST) && defined(HAVE_ADJUSTABLE_CPU_FREQ) | 153 | #if defined(HAVE_GUI_BOOST) && defined(HAVE_ADJUSTABLE_CPU_FREQ) |
154 | |||
155 | /* Timeout for gui boost in seconds. */ | ||
156 | #define GUI_BOOST_TIMEOUT (HZ) | ||
157 | |||
154 | /* Helper function which is called to boost / unboost CPU. This function | 158 | /* Helper function which is called to boost / unboost CPU. This function |
155 | * avoids to increase boost_count with each call of gui_boost(). */ | 159 | * avoids to increase boost_count with each call of gui_boost(). */ |
156 | static void gui_boost(bool want_to_boost) | 160 | static void gui_boost(bool want_to_boost) |
@@ -168,6 +172,15 @@ static void gui_boost(bool want_to_boost) | |||
168 | boosted = false; | 172 | boosted = false; |
169 | } | 173 | } |
170 | } | 174 | } |
175 | |||
176 | /* gui_unboost_callback() is called GUI_BOOST_TIMEOUT seconds after the | ||
177 | * last wheel scrolling event. */ | ||
178 | static int gui_unboost_callback(struct timeout *tmo) | ||
179 | { | ||
180 | (void)tmo; | ||
181 | gui_boost(false); | ||
182 | return 0; | ||
183 | } | ||
171 | #endif | 184 | #endif |
172 | 185 | ||
173 | /* | 186 | /* |
@@ -194,7 +207,6 @@ static int get_action_worker(int context, int timeout, | |||
194 | int ret = ACTION_UNKNOWN; | 207 | int ret = ACTION_UNKNOWN; |
195 | static int last_context = CONTEXT_STD; | 208 | static int last_context = CONTEXT_STD; |
196 | 209 | ||
197 | |||
198 | send_event(GUI_EVENT_ACTIONUPDATE, NULL); | 210 | send_event(GUI_EVENT_ACTIONUPDATE, NULL); |
199 | 211 | ||
200 | if (timeout == TIMEOUT_NOBLOCK) | 212 | if (timeout == TIMEOUT_NOBLOCK) |
@@ -205,19 +217,15 @@ static int get_action_worker(int context, int timeout, | |||
205 | button = button_get_w_tmo(timeout); | 217 | button = button_get_w_tmo(timeout); |
206 | 218 | ||
207 | #if defined(HAVE_GUI_BOOST) && defined(HAVE_ADJUSTABLE_CPU_FREQ) | 219 | #if defined(HAVE_GUI_BOOST) && defined(HAVE_ADJUSTABLE_CPU_FREQ) |
208 | /* Boost the CPU in case of wheel scrolling activity in the defined contexts. | 220 | static struct timeout gui_unboost; |
209 | * Unboost the CPU after timeout. */ | 221 | /* Boost the CPU in case of wheel scrolling activity in the defined contexts. |
210 | static long last_boost_tick; | 222 | * Call unboost with a timeout of GUI_BOOST_TIMEOUT. */ |
211 | if ((button&(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD)) && | 223 | if ((button&(BUTTON_SCROLL_BACK|BUTTON_SCROLL_FWD)) && |
212 | (context == CONTEXT_STD || context == CONTEXT_LIST || | 224 | (context == CONTEXT_STD || context == CONTEXT_LIST || |
213 | context == CONTEXT_MAINMENU || context == CONTEXT_TREE)) | 225 | context == CONTEXT_MAINMENU || context == CONTEXT_TREE)) |
214 | { | 226 | { |
215 | last_boost_tick = current_tick; | ||
216 | gui_boost(true); | 227 | gui_boost(true); |
217 | } | 228 | timeout_register(&gui_unboost, gui_unboost_callback, GUI_BOOST_TIMEOUT, 0); |
218 | else if (TIME_AFTER(current_tick, last_boost_tick + HZ)) | ||
219 | { | ||
220 | gui_boost(false); | ||
221 | } | 229 | } |
222 | #endif | 230 | #endif |
223 | 231 | ||
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 */ | |||
983 | #define INCLUDE_TIMEOUT_API | 983 | #define INCLUDE_TIMEOUT_API |
984 | #endif /* HAVE_USB_CHARGING_ENABLE && HAVE_USBSTACK */ | 984 | #endif /* HAVE_USB_CHARGING_ENABLE && HAVE_USBSTACK */ |
985 | 985 | ||
986 | #if defined(HAVE_GUI_BOOST) && defined(HAVE_ADJUSTABLE_CPU_FREQ) | ||
987 | /* Timeout objects required if GUI boost is enabled */ | ||
988 | #define INCLUDE_TIMEOUT_API | ||
989 | #endif /* HAVE_GUI_BOOST && HAVE_ADJUSTABLE_CPU_FREQ */ | ||
990 | |||
986 | #if defined(HAVE_USBSTACK) || (CONFIG_STORAGE & STORAGE_NAND) | 991 | #if defined(HAVE_USBSTACK) || (CONFIG_STORAGE & STORAGE_NAND) |
987 | #define STORAGE_GET_INFO | 992 | #define STORAGE_GET_INFO |
988 | #endif | 993 | #endif |