diff options
author | Daniel Stenberg <daniel@haxx.se> | 2003-03-17 19:32:12 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2003-03-17 19:32:12 +0000 |
commit | 2517523c303e59c7619a771f0723347aadb757b8 (patch) | |
tree | 8abfa56eba6b67bca262c0c3a7932b0c85d6bbe6 | |
parent | 9354c9c98830fd999792fc95395050ff43408e9f (diff) | |
download | rockbox-2517523c303e59c7619a771f0723347aadb757b8.tar.gz rockbox-2517523c303e59c7619a771f0723347aadb757b8.zip |
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
-rw-r--r-- | apps/screens.c | 60 | ||||
-rw-r--r-- | apps/screens.h | 4 |
2 files changed, 64 insertions, 0 deletions
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 |