1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) Daniel Stenberg (2002)
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
23 #include "rbunicode.h"
26 #include "screen_access.h"
34 #ifdef HAVE_LCD_BITMAP
36 #define MAXLINES (LCD_HEIGHT/6)
38 #define RECT_SPACING 2
39 #define SPLASH_MEMORY_INTERVAL (HZ)
41 #else /* HAVE_LCD_CHARCELLS */
45 #define RECT_SPACING 0
50 static void splash_internal(struct screen
* screen
, const char *fmt
, va_list ap
)
52 char splash_buf
[MAXBUFFER
];
53 char *lines
[MAXLINES
];
56 char *lastbreak
= NULL
;
63 #ifdef HAVE_LCD_BITMAP
67 viewport_set_defaults(&vp
, screen
->screen_type
);
68 screen
->set_viewport(&vp
);
70 screen
->getstringsize(" ", &space_w
, &h
);
71 #else /* HAVE_LCD_CHARCELLS */
72 vp
.width
= screen
->lcdwidth
;
73 vp
.height
= screen
->lcdheight
;
76 screen
->double_height (false);
80 vsnprintf(splash_buf
, sizeof(splash_buf
), fmt
, ap
);
83 /* break splash string into display lines, doing proper word wrap */
85 next
= strtok_r(splash_buf
, " ", &store
);
87 goto end
; /* nothing to display */
92 #ifdef HAVE_LCD_BITMAP
93 screen
->getstringsize(next
, &w
, NULL
);
99 if (x
+ (next
- lastbreak
) * space_w
+ w
100 > vp
.width
- RECT_SPACING
*2)
101 { /* too wide, wrap */
102 #ifdef HAVE_LCD_BITMAP
106 if ((y
+ h
> vp
.height
) || (line
>= (MAXLINES
-1)))
107 break; /* screen full or out of lines */
110 lines
[++line
] = next
;
114 /* restore & calculate spacing */
116 x
+= (next
- lastbreak
) * space_w
;
120 lastbreak
= next
+ strlen(next
);
121 next
= strtok_r(NULL
, " ", &store
);
123 { /* no more words */
124 #ifdef HAVE_LCD_BITMAP
133 * First boundaries, then the grey filling, then the black border and finally
136 screen
->stop_scroll();
138 #ifdef HAVE_LCD_BITMAP
140 width
= maxw
+ 2*RECT_SPACING
;
141 height
= y
+ 2*RECT_SPACING
;
143 if (width
> vp
.width
)
145 if (height
> vp
.height
)
148 vp
.x
+= (vp
.width
- width
) / 2;
149 vp
.y
+= (vp
.height
- height
) / 2;
153 vp
.flags
|= VP_FLAG_ALIGN_CENTER
;
155 if (screen
->depth
> 1)
157 vp
.drawmode
= DRMODE_FG
;
158 /* can't do vp.fg_pattern here, since set_foreground does a bit more on
160 screen
->set_foreground(SCREEN_COLOR_TO_NATIVE(screen
, LCD_LIGHTGRAY
));
164 vp
.drawmode
= (DRMODE_SOLID
|DRMODE_INVERSEVID
);
166 screen
->fill_viewport();
169 if (screen
->depth
> 1)
170 /* can't do vp.fg_pattern here, since set_foreground does a bit more on
172 screen
->set_foreground(SCREEN_COLOR_TO_NATIVE(screen
, LCD_BLACK
));
175 vp
.drawmode
= DRMODE_SOLID
;
177 screen
->draw_border_viewport();
179 /* prepare putting the text */
181 #else /* HAVE_LCD_CHARCELLS */
182 y
= 0; /* vertical centering on 2 lines would be silly */
183 screen
->clear_display();
186 /* print the message to screen */
187 for (i
= 0; i
<= line
; i
++, y
+=h
)
189 #ifdef HAVE_LCD_BITMAP
190 screen
->putsxy(0, y
, lines
[i
]);
192 screen
->puts(0, y
, lines
[i
]);
195 screen
->update_viewport();
197 screen
->set_viewport(NULL
);
200 void splashf(int ticks
, const char *fmt
, ...)
205 /* If fmt is a lang ID then get the corresponding string (which
206 still might contain % place holders). */
207 fmt
= P2STR((unsigned char *)fmt
);
211 splash_internal(&(screens
[i
]), fmt
, ap
);
218 void splash(int ticks
, const char *str
)
220 #if !defined(SIMULATOR) || CONFIG_CODEC == SWCODEC
222 /* fmt may be a so called virtual pointer. See settings.h. */
223 if((id
= P2ID((const unsigned char*)str
)) >= 0)
224 /* If fmt specifies a voicefont ID, and voice menus are
225 enabled, then speak it. */
226 cond_talk_ids_fq(id
);
228 splashf(ticks
, "%s", P2STR((const unsigned char*)str
));