From 2517523c303e59c7619a771f0723347aadb757b8 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Mon, 17 Mar 2003 19:32:12 +0000 Subject: Hey Linus! Here it is! Added splash(). Shows a message on screen during a given period, waiting for the given keymask. This function word-wraps the input message itself to show it as nicely as possible. Multi platform function. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3462 a1c6a512-1295-4272-9138-f99709370657 --- apps/screens.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ apps/screens.h | 4 ++++ 2 files changed, 64 insertions(+) (limited to 'apps') diff --git a/apps/screens.c b/apps/screens.c index 9a39b184c9..5b41cbf9f2 100644 --- a/apps/screens.c +++ b/apps/screens.c @@ -467,3 +467,63 @@ bool f3_screen(void) return false; } #endif + +#ifdef HAVE_LCD_BITMAP +#define SPACE 4 /* pixels between words */ +#else +#define SPACE 1 /* one letter space */ +#undef LCD_WIDTH +#define LCD_WIDTH 11 +#undef LCD_HEIGHT +#define LCD_HEIGHT 2 +#endif + +void splash(char *text, /* what to say */ + int ticks, /* fow how long */ + int keymask) /* what keymask aborts the waiting (if any) */ +{ + char *next; + char *store=NULL; + int x=0; + int y=0; + int w, h; + lcd_clear_display(); + + next = strtok_r(text, " ", &store); + while (next) { +#ifdef HAVE_LCD_BITMAP + lcd_getstringsize(next, &w, &h); +#else + w = strlen(next); + h = 1; +#endif + if(x) { + if(x+w> LCD_WIDTH) { + /* too wide */ + y+=h; + if(y > (LCD_HEIGHT-h)) + /* STOP */ + break; + x=0; + } + } +#ifdef HAVE_LCD_BITMAP + lcd_putsxy(x, y, next); + lcd_update(); /* DURING DEBUG ONLY */ +#else + lcd_puts(x, y, next); +#endif + x += w+SPACE; /* pixels space! */ + next = strtok_r(NULL, " ", &store); + } + lcd_update(); + + if(ticks) { + int done = ticks + current_tick + 1; + while (TIME_BEFORE( current_tick, done)) { + int button = button_get_w_tmo(ticks); + if((button & keymask) == keymask) + break; + } + } +} diff --git a/apps/screens.h b/apps/screens.h index 27b156b895..93894eb654 100644 --- a/apps/screens.h +++ b/apps/screens.h @@ -28,4 +28,8 @@ bool f2_screen(void); bool f3_screen(void); #endif +void splash(char *text, /* what to say */ + int ticks, /* fow how long */ + int button);/* what keymask aborts the waiting (if any) */ + #endif -- cgit v1.2.3