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"
33 #ifdef HAVE_LCD_BITMAP
35 #define MAXLINES (LCD_HEIGHT/6)
37 #define RECT_SPACING 2
39 #else /* HAVE_LCD_CHARCELLS */
43 #define RECT_SPACING 0
48 static void splash_internal(struct screen
* screen
, const char *fmt
, va_list ap
)
50 char splash_buf
[MAXBUFFER
];
51 char *lines
[MAXLINES
];
54 char *lastbreak
= NULL
;
60 #ifdef HAVE_LCD_BITMAP
64 viewport_set_defaults(&vp
, screen
->screen_type
);
65 screen
->set_viewport(&vp
);
67 screen
->getstringsize(" ", &space_w
, &h
);
68 #else /* HAVE_LCD_CHARCELLS */
71 screen
->double_height (false);
75 vsnprintf(splash_buf
, sizeof(splash_buf
), fmt
, ap
);
78 /* break splash string into display lines, doing proper word wrap */
80 next
= strtok_r(splash_buf
, " ", &store
);
82 goto end
; /* nothing to display */
87 #ifdef HAVE_LCD_BITMAP
88 screen
->getstringsize(next
, &w
, NULL
);
94 if (x
+ (next
- lastbreak
) * space_w
+ w
95 > screen
->lcdwidth
- RECT_SPACING
*2)
96 { /* too wide, wrap */
97 #ifdef HAVE_LCD_BITMAP
101 if ((y
+ h
> screen
->lcdheight
) || (line
>= (MAXLINES
-1)))
102 break; /* screen full or out of lines */
105 lines
[++line
] = next
;
109 /* restore & calculate spacing */
111 x
+= (next
- lastbreak
) * space_w
;
115 lastbreak
= next
+ strlen(next
);
116 next
= strtok_r(NULL
, " ", &store
);
118 { /* no more words */
119 #ifdef HAVE_LCD_BITMAP
128 * First boundaries, then the grey filling, then the black border and finally
131 screen
->stop_scroll();
133 #ifdef HAVE_LCD_BITMAP
134 /* If we center the display, then just clear the box we need and put
135 a nice little frame and put the text in there! */
136 vp
.y
= (screen
->lcdheight
- y
) / 2 - RECT_SPACING
; /* height => y start position */
137 vp
.x
= (screen
->lcdwidth
- maxw
) / 2 - RECT_SPACING
;
138 vp
.width
= maxw
+ 2*RECT_SPACING
;
139 vp
.height
= screen
->lcdheight
- (vp
.y
*2) + RECT_SPACING
;
145 if (vp
.width
> screen
->lcdwidth
)
146 vp
.width
= screen
->lcdwidth
;
147 if (vp
.height
> screen
->lcdheight
)
148 vp
.height
= screen
->lcdheight
;
150 vp
.flags
|= VP_FLAG_ALIGN_CENTER
;
152 if (screen
->depth
> 1)
154 vp
.drawmode
= DRMODE_FG
;
155 /* can't do vp.fg_pattern here, since set_foreground does a bit more on
157 screen
->set_foreground(SCREEN_COLOR_TO_NATIVE(screen
, LCD_LIGHTGRAY
));
161 vp
.drawmode
= (DRMODE_SOLID
|DRMODE_INVERSEVID
);
163 screen
->fillrect(0, 0, vp
.width
, vp
.height
);
166 if (screen
->depth
> 1)
167 /* can't do vp.fg_pattern here, since set_foreground does a bit more on
169 screen
->set_foreground(SCREEN_COLOR_TO_NATIVE(screen
, LCD_BLACK
));
172 vp
.drawmode
= DRMODE_SOLID
;
174 screen
->drawrect(0, 0, vp
.width
, vp
.height
);
176 /* prepare putting the text */
178 #else /* HAVE_LCD_CHARCELLS */
179 y
= 0; /* vertical centering on 2 lines would be silly */
180 screen
->clear_display();
183 /* print the message to screen */
184 for (i
= 0; i
<= line
; i
++, y
+=h
)
186 #ifdef HAVE_LCD_BITMAP
187 screen
->putsxy(0, y
, lines
[i
]);
189 screen
->puts(0, y
, lines
[i
]);
192 screen
->update_viewport();
194 screen
->set_viewport(NULL
);
197 void splashf(int ticks
, const char *fmt
, ...)
202 /* If fmt is a lang ID then get the corresponding string (which
203 still might contain % place holders). */
204 fmt
= P2STR((unsigned char *)fmt
);
208 splash_internal(&(screens
[i
]), fmt
, ap
);
215 void splash(int ticks
, const char *str
)
217 #if !defined(SIMULATOR) || CONFIG_CODEC == SWCODEC
219 /* fmt may be a so called virtual pointer. See settings.h. */
220 if((id
= P2ID((const unsigned char*)str
)) >= 0)
221 /* If fmt specifies a voicefont ID, and voice menus are
222 enabled, then speak it. */
223 cond_talk_ids_fq(id
);
225 splashf(ticks
, "%s", P2STR((const unsigned char*)str
));