summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
Diffstat (limited to 'apps')
-rw-r--r--apps/debug_menu.c63
1 files changed, 58 insertions, 5 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 3c089df8bb..04c3f26f2f 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -134,10 +134,19 @@
134#include "rb-loader.h" 134#include "rb-loader.h"
135#endif 135#endif
136 136
137#define SCREEN_MAX_CHARS (LCD_WIDTH / SYSFONT_WIDTH)
138struct dbg_os_threads_t
139{
140 long next_scroll;
141 int scroll_pos;
142 int scroll_delay;
143 int scroll_speed;
144};
145
137static const char* threads_getname(int selected_item, void *data, 146static const char* threads_getname(int selected_item, void *data,
138 char *buffer, size_t buffer_len) 147 char *buffer, size_t buffer_len)
139{ 148{
140 (void)data; 149struct dbg_os_threads_t* ost = (struct dbg_os_threads_t*) data;
141 150
142#if NUM_CORES > 1 151#if NUM_CORES > 1
143 if (selected_item < (int)NUM_CORES) 152 if (selected_item < (int)NUM_CORES)
@@ -161,7 +170,7 @@ static const char* threads_getname(int selected_item, void *data,
161 IFN_SDL(" %2d%%") " %s"; 170 IFN_SDL(" %2d%%") " %s";
162 } 171 }
163 172
164 snprintf(buffer, buffer_len, fmtstr, 173 size_t len = snprintf(buffer, buffer_len, fmtstr,
165 selected_item, 174 selected_item,
166 IF_COP(threadinfo.core,) 175 IF_COP(threadinfo.core,)
167 threadinfo.statusstr, 176 threadinfo.statusstr,
@@ -169,24 +178,68 @@ static const char* threads_getname(int selected_item, void *data,
169 IFN_SDL(threadinfo.stack_usage,) 178 IFN_SDL(threadinfo.stack_usage,)
170 threadinfo.name); 179 threadinfo.name);
171 180
181 buffer[buffer_len - 1] = '\0';
182
183 if (len >= SCREEN_MAX_CHARS)
184 {
185 if (len >= buffer_len)
186 len = buffer_len - 1;
187 int start = ost->scroll_pos%(len-1);
188 int rem = (len - start);
189 if (rem < SCREEN_MAX_CHARS)
190 start -= (SCREEN_MAX_CHARS - rem);
191
192 if (start > 0)
193 {
194 /* don't scroll the # and status */
195 if ((unsigned int)start + 7 < buffer_len)
196 memmove(&buffer[start], &buffer[0], 7);
197 return &buffer[start];
198 }
199 }
172 return buffer; 200 return buffer;
201
173} 202}
174 203
175static int dbg_threads_action_callback(int action, struct gui_synclist *lists) 204static int dbg_threads_action_callback(int action, struct gui_synclist *lists)
176{ 205{
177 (void)lists; 206 struct dbg_os_threads_t* ost = (struct dbg_os_threads_t*) lists->data;
178 if (action == ACTION_NONE) 207 if (action == ACTION_NONE)
208 {
209 if (TIME_AFTER(current_tick, ost->next_scroll))
210 {
211 ost->next_scroll = current_tick + ost->scroll_speed;
212 ost->scroll_pos++;
213 if (ost->scroll_pos > SCREEN_MAX_CHARS * 5)
214 {
215 ost->next_scroll += ost->scroll_delay;
216 ost->scroll_pos = 0;
217 }
218 }
179 action = ACTION_REDRAW; 219 action = ACTION_REDRAW;
220 }
221 else
222 {
223 ost->next_scroll = current_tick + ost->scroll_delay;
224 ost->scroll_pos = 0;
225 }
226
180 return action; 227 return action;
181} 228}
182/* Test code!!! */ 229/* Test code!!! */
183static bool dbg_os(void) 230static bool dbg_os(void)
184{ 231{
185 struct simplelist_info info; 232 struct simplelist_info info;
233 struct dbg_os_threads_t ost;
234 ost.scroll_pos = 0;
235 ost.scroll_speed = lcd_scroll_info.ticks;
236 ost.scroll_delay = global_settings.scroll_delay;
237 ost.next_scroll = current_tick + ost.scroll_delay;
238
186 simplelist_info_init(&info, IF_COP("Core and ") "Stack usage:", 239 simplelist_info_init(&info, IF_COP("Core and ") "Stack usage:",
187 MAXTHREADS IF_COP( + NUM_CORES ), NULL); 240 MAXTHREADS IF_COP( + NUM_CORES ), &ost);
188 info.hide_selection = true; 241 info.hide_selection = true;
189 info.scroll_all = true; 242 info.scroll_all = false;
190 info.action_callback = dbg_threads_action_callback; 243 info.action_callback = dbg_threads_action_callback;
191 info.get_name = threads_getname; 244 info.get_name = threads_getname;
192 return simplelist_show_list(&info); 245 return simplelist_show_list(&info);