diff options
| author | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-02-07 13:52:03 +0000 |
|---|---|---|
| committer | Maurus Cuelenaere <mcuelenaere@gmail.com> | 2009-02-07 13:52:03 +0000 |
| commit | c33209e1b982a8210bd66af4a6cb8408661a3a3a (patch) | |
| tree | f1fbe35346c6fe80d1a4f64aa608c8e7a3ad4f04 /bootloader | |
| parent | 3f109f595cacb781c2639c6e1b95956d1f18fa36 (diff) | |
| download | rockbox-c33209e1b982a8210bd66af4a6cb8408661a3a3a.zip rockbox-c33209e1b982a8210bd66af4a6cb8408661a3a3a.tar.gz rockbox-c33209e1b982a8210bd66af4a6cb8408661a3a3a.tar.bz2 rockbox-c33209e1b982a8210bd66af4a6cb8408661a3a3a.tar.xz | |
Add optional logf display helper function for bootloaders
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@19938 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'bootloader')
| -rw-r--r-- | bootloader/common.c | 84 | ||||
| -rw-r--r-- | bootloader/common.h | 3 |
2 files changed, 87 insertions, 0 deletions
diff --git a/bootloader/common.c b/bootloader/common.c index a2dd35f..3c4e67a 100644 --- a/bootloader/common.c +++ b/bootloader/common.c @@ -30,6 +30,10 @@ #include "power.h" #include "kernel.h" #include "config.h" +#include "logf.h" +#include "button.h" +#include "string.h" +#include "usb.h" /* TODO: Other bootloaders need to be adjusted to set this variable to true on a button press - currently only the ipod, H10 and Sansa versions do. */ @@ -238,3 +242,83 @@ int dbg_ports(void) void mpeg_stop(void) { } + +#ifdef ROCKBOX_HAS_LOGF /* Logf display helper for the bootloader */ + +#define LINES (LCD_HEIGHT/SYSFONT_HEIGHT) +#define COLUMNS ((LCD_WIDTH/SYSFONT_WIDTH) > MAX_LOGF_ENTRY ? \ + MAX_LOGF_ENTRY : (LCD_WIDTH/SYSFONT_WIDTH)) + +#ifdef ONDA_VX747 +#define LOGF_UP BUTTON_VOL_UP +#define LOGF_DOWN BUTTON_VOL_DOWN +#define LOGF_CLEAR BUTTON_MENU +#else +#warning No keymap defined for this target +#endif + +void display_logf(void) /* Doesn't return! */ +{ + int i, index, button, user_index=0; +#ifdef HAVE_TOUCHSCREEN + int touch, prev_y=0; +#endif + char buffer[COLUMNS+1]; + + while(1) + { + index = logfindex + user_index; + + lcd_clear_display(); + for(i = LINES-1; i>=0; i--) + { + if(--index < 0) + { + if(logfwrap) + index = MAX_LOGF_LINES-1; + else + break; /* done */ + } + + memcpy(buffer, logfbuffer[index], COLUMNS); + + if (logfbuffer[index][MAX_LOGF_ENTRY] == LOGF_TERMINATE_CONTINUE_LINE) + buffer[MAX_LOGF_ENTRY-1] = '>'; + else if (logfbuffer[index][MAX_LOGF_ENTRY] == LOGF_TERMINATE_MULTI_LINE) + buffer[MAX_LOGF_ENTRY-1] = '\0'; + + buffer[COLUMNS] = '\0'; + + lcd_puts(0, i, buffer); + } + + button = button_get(false); + if(button == SYS_USB_CONNECTED) + usb_acknowledge(SYS_USB_CONNECTED_ACK); + else if(button == SYS_USB_DISCONNECTED) + usb_acknowledge(SYS_USB_DISCONNECTED_ACK); + else if(button & LOGF_UP) + user_index++; + else if(button & LOGF_DOWN) + user_index--; + else if(button & LOGF_CLEAR) + user_index = 0; +#ifdef HAVE_TOUCHSCREEN + else if(button & BUTTON_TOUCH) + { + touch = button_get_data(); + + if(button & BUTTON_REL) + prev_y = 0; + + if(prev_y != 0) + user_index += (prev_y - (touch & 0xFFFF)) / SYSFONT_HEIGHT; + prev_y = touch & 0xFFFF; + } +#endif + + lcd_update(); + sleep(HZ/16); + } +} +#endif diff --git a/bootloader/common.h b/bootloader/common.h index f73d650..3a3e977 100644 --- a/bootloader/common.h +++ b/bootloader/common.h @@ -46,3 +46,6 @@ char *strerror(int error); void error(int errortype, int error); int load_firmware(unsigned char* buf, char* firmware, int buffer_size); int load_raw_firmware(unsigned char* buf, char* firmware, int buffer_size); +#ifdef ROCKBOX_HAS_LOGF +void display_logf(void); +#endif |