summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2022-03-14 20:50:05 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2022-03-14 20:53:45 -0400
commit20b9ce5497c6a02c520e879e6c39a72b2c858b48 (patch)
tree64edcdb993caae4057f362c0f576e486f8475a20 /apps
parent542609bb310921b48ba16944d539e1447e2bbd8e (diff)
downloadrockbox-20b9ce5497c6a02c520e879e6c39a72b2c858b48.tar.gz
rockbox-20b9ce5497c6a02c520e879e6c39a72b2c858b48.zip
debug_menu make scrolling manual for OS Threads item
the automatic scrolling is not very nice to try and read instead use OK button to advance and long press std ok to reset to beginning (or scroll up and down) Change-Id: I964ccefcd3c16836cc92f52247d7b8e65c6d627b
Diffstat (limited to 'apps')
-rw-r--r--apps/debug_menu.c73
1 files changed, 28 insertions, 45 deletions
diff --git a/apps/debug_menu.c b/apps/debug_menu.c
index 04c3f26f2f..9546de45db 100644
--- a/apps/debug_menu.c
+++ b/apps/debug_menu.c
@@ -135,18 +135,11 @@
135#endif 135#endif
136 136
137#define SCREEN_MAX_CHARS (LCD_WIDTH / SYSFONT_WIDTH) 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 138
146static const char* threads_getname(int selected_item, void *data, 139static const char* threads_getname(int selected_item, void *data,
147 char *buffer, size_t buffer_len) 140 char *buffer, size_t buffer_len)
148{ 141{
149struct dbg_os_threads_t* ost = (struct dbg_os_threads_t*) data; 142 int *x_offset = (int*) data;
150 143
151#if NUM_CORES > 1 144#if NUM_CORES > 1
152 if (selected_item < (int)NUM_CORES) 145 if (selected_item < (int)NUM_CORES)
@@ -166,62 +159,56 @@ struct dbg_os_threads_t* ost = (struct dbg_os_threads_t*) data;
166 struct thread_debug_info threadinfo; 159 struct thread_debug_info threadinfo;
167 if (thread_get_debug_info(selected_item, &threadinfo) > 0) 160 if (thread_get_debug_info(selected_item, &threadinfo) > 0)
168 { 161 {
169 fmtstr = "%2d:" IF_COP(" (%d)") " %s" IF_PRIO(" %d %d") 162 fmtstr = "%2d:" IF_COP(" (%d)") " %s%n" IF_PRIO(" %d %d")
170 IFN_SDL(" %2d%%") " %s"; 163 IFN_SDL(" %2d%%") " %s";
171 } 164 }
172 165 int status_len;
173 size_t len = snprintf(buffer, buffer_len, fmtstr, 166 size_t len = snprintf(buffer, buffer_len, fmtstr,
174 selected_item, 167 selected_item,
175 IF_COP(threadinfo.core,) 168 IF_COP(threadinfo.core,)
176 threadinfo.statusstr, 169 threadinfo.statusstr,
170 &status_len,
177 IF_PRIO(threadinfo.base_priority, threadinfo.current_priority,) 171 IF_PRIO(threadinfo.base_priority, threadinfo.current_priority,)
178 IFN_SDL(threadinfo.stack_usage,) 172 IFN_SDL(threadinfo.stack_usage,)
179 threadinfo.name); 173 threadinfo.name);
180 174
181 buffer[buffer_len - 1] = '\0'; 175 int start = 0;
182
183 if (len >= SCREEN_MAX_CHARS) 176 if (len >= SCREEN_MAX_CHARS)
184 { 177 {
185 if (len >= buffer_len) 178 int ch_offset = (*x_offset)%(len-1);
186 len = buffer_len - 1; 179 int rem = SCREEN_MAX_CHARS - (len - ch_offset);
187 int start = ost->scroll_pos%(len-1); 180 if (rem > 0)
188 int rem = (len - start); 181 ch_offset -= rem;
189 if (rem < SCREEN_MAX_CHARS) 182
190 start -= (SCREEN_MAX_CHARS - rem); 183 if (ch_offset > 0)
191
192 if (start > 0)
193 { 184 {
194 /* don't scroll the # and status */ 185 /* don't scroll the # and status */
195 if ((unsigned int)start + 7 < buffer_len) 186 status_len++;
196 memmove(&buffer[start], &buffer[0], 7); 187 if ((unsigned int)ch_offset + status_len < buffer_len)
197 return &buffer[start]; 188 memmove(&buffer[ch_offset], &buffer[0], status_len);
189 start = ch_offset;
198 } 190 }
199 } 191 }
200 return buffer; 192 return &buffer[start];
201
202} 193}
203 194
204static int dbg_threads_action_callback(int action, struct gui_synclist *lists) 195static int dbg_threads_action_callback(int action, struct gui_synclist *lists)
205{ 196{
206 struct dbg_os_threads_t* ost = (struct dbg_os_threads_t*) lists->data; 197
207 if (action == ACTION_NONE) 198 if (action == ACTION_NONE)
208 { 199 {
209 if (TIME_AFTER(current_tick, ost->next_scroll)) 200 return ACTION_REDRAW;
210 { 201 }
211 ost->next_scroll = current_tick + ost->scroll_speed; 202
212 ost->scroll_pos++; 203 int *x_offset = ((int*) lists->data);
213 if (ost->scroll_pos > SCREEN_MAX_CHARS * 5) 204 if (action == ACTION_STD_OK)
214 { 205 {
215 ost->next_scroll += ost->scroll_delay; 206 *x_offset += 1;
216 ost->scroll_pos = 0;
217 }
218 }
219 action = ACTION_REDRAW; 207 action = ACTION_REDRAW;
220 } 208 }
221 else 209 else if (action != ACTION_UNKNOWN)
222 { 210 {
223 ost->next_scroll = current_tick + ost->scroll_delay; 211 *x_offset = 0;
224 ost->scroll_pos = 0;
225 } 212 }
226 213
227 return action; 214 return action;
@@ -230,14 +217,10 @@ static int dbg_threads_action_callback(int action, struct gui_synclist *lists)
230static bool dbg_os(void) 217static bool dbg_os(void)
231{ 218{
232 struct simplelist_info info; 219 struct simplelist_info info;
233 struct dbg_os_threads_t ost; 220 int xoffset = 0;
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 221
239 simplelist_info_init(&info, IF_COP("Core and ") "Stack usage:", 222 simplelist_info_init(&info, IF_COP("Core and ") "Stack usage:",
240 MAXTHREADS IF_COP( + NUM_CORES ), &ost); 223 MAXTHREADS IF_COP( + NUM_CORES ), &xoffset);
241 info.hide_selection = true; 224 info.hide_selection = true;
242 info.scroll_all = false; 225 info.scroll_all = false;
243 info.action_callback = dbg_threads_action_callback; 226 info.action_callback = dbg_threads_action_callback;