diff options
Diffstat (limited to 'bootloader/common.c')
-rw-r--r-- | bootloader/common.c | 84 |
1 files changed, 84 insertions, 0 deletions
diff --git a/bootloader/common.c b/bootloader/common.c index a2dd35f3a6..3c4e67abbe 100644 --- a/bootloader/common.c +++ b/bootloader/common.c | |||
@@ -30,6 +30,10 @@ | |||
30 | #include "power.h" | 30 | #include "power.h" |
31 | #include "kernel.h" | 31 | #include "kernel.h" |
32 | #include "config.h" | 32 | #include "config.h" |
33 | #include "logf.h" | ||
34 | #include "button.h" | ||
35 | #include "string.h" | ||
36 | #include "usb.h" | ||
33 | 37 | ||
34 | /* TODO: Other bootloaders need to be adjusted to set this variable to true | 38 | /* TODO: Other bootloaders need to be adjusted to set this variable to true |
35 | on a button press - currently only the ipod, H10 and Sansa versions do. */ | 39 | on a button press - currently only the ipod, H10 and Sansa versions do. */ |
@@ -238,3 +242,83 @@ int dbg_ports(void) | |||
238 | void mpeg_stop(void) | 242 | void mpeg_stop(void) |
239 | { | 243 | { |
240 | } | 244 | } |
245 | |||
246 | #ifdef ROCKBOX_HAS_LOGF /* Logf display helper for the bootloader */ | ||
247 | |||
248 | #define LINES (LCD_HEIGHT/SYSFONT_HEIGHT) | ||
249 | #define COLUMNS ((LCD_WIDTH/SYSFONT_WIDTH) > MAX_LOGF_ENTRY ? \ | ||
250 | MAX_LOGF_ENTRY : (LCD_WIDTH/SYSFONT_WIDTH)) | ||
251 | |||
252 | #ifdef ONDA_VX747 | ||
253 | #define LOGF_UP BUTTON_VOL_UP | ||
254 | #define LOGF_DOWN BUTTON_VOL_DOWN | ||
255 | #define LOGF_CLEAR BUTTON_MENU | ||
256 | #else | ||
257 | #warning No keymap defined for this target | ||
258 | #endif | ||
259 | |||
260 | void display_logf(void) /* Doesn't return! */ | ||
261 | { | ||
262 | int i, index, button, user_index=0; | ||
263 | #ifdef HAVE_TOUCHSCREEN | ||
264 | int touch, prev_y=0; | ||
265 | #endif | ||
266 | char buffer[COLUMNS+1]; | ||
267 | |||
268 | while(1) | ||
269 | { | ||
270 | index = logfindex + user_index; | ||
271 | |||
272 | lcd_clear_display(); | ||
273 | for(i = LINES-1; i>=0; i--) | ||
274 | { | ||
275 | if(--index < 0) | ||
276 | { | ||
277 | if(logfwrap) | ||
278 | index = MAX_LOGF_LINES-1; | ||
279 | else | ||
280 | break; /* done */ | ||
281 | } | ||
282 | |||
283 | memcpy(buffer, logfbuffer[index], COLUMNS); | ||
284 | |||
285 | if (logfbuffer[index][MAX_LOGF_ENTRY] == LOGF_TERMINATE_CONTINUE_LINE) | ||
286 | buffer[MAX_LOGF_ENTRY-1] = '>'; | ||
287 | else if (logfbuffer[index][MAX_LOGF_ENTRY] == LOGF_TERMINATE_MULTI_LINE) | ||
288 | buffer[MAX_LOGF_ENTRY-1] = '\0'; | ||
289 | |||
290 | buffer[COLUMNS] = '\0'; | ||
291 | |||
292 | lcd_puts(0, i, buffer); | ||
293 | } | ||
294 | |||
295 | button = button_get(false); | ||
296 | if(button == SYS_USB_CONNECTED) | ||
297 | usb_acknowledge(SYS_USB_CONNECTED_ACK); | ||
298 | else if(button == SYS_USB_DISCONNECTED) | ||
299 | usb_acknowledge(SYS_USB_DISCONNECTED_ACK); | ||
300 | else if(button & LOGF_UP) | ||
301 | user_index++; | ||
302 | else if(button & LOGF_DOWN) | ||
303 | user_index--; | ||
304 | else if(button & LOGF_CLEAR) | ||
305 | user_index = 0; | ||
306 | #ifdef HAVE_TOUCHSCREEN | ||
307 | else if(button & BUTTON_TOUCH) | ||
308 | { | ||
309 | touch = button_get_data(); | ||
310 | |||
311 | if(button & BUTTON_REL) | ||
312 | prev_y = 0; | ||
313 | |||
314 | if(prev_y != 0) | ||
315 | user_index += (prev_y - (touch & 0xFFFF)) / SYSFONT_HEIGHT; | ||
316 | prev_y = touch & 0xFFFF; | ||
317 | } | ||
318 | #endif | ||
319 | |||
320 | lcd_update(); | ||
321 | sleep(HZ/16); | ||
322 | } | ||
323 | } | ||
324 | #endif | ||