fc3962188552f9ec179047a75c78c8296949b8ea
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
38 #define SPLASH_MEMORY_INTERVAL (HZ)
40 #else /* HAVE_LCD_CHARCELLS */
44 #define RECT_SPACING 0
49 static void splash_internal(struct screen
* screen
, const char *fmt
, va_list ap
)
51 char splash_buf
[MAXBUFFER
];
52 char *lines
[MAXLINES
];
55 char *lastbreak
= NULL
;
62 #ifdef HAVE_LCD_BITMAP
66 viewport_set_defaults(&vp
, screen
->screen_type
);
67 screen
->set_viewport(&vp
);
69 screen
->getstringsize(" ", &space_w
, &h
);
70 #else /* HAVE_LCD_CHARCELLS */
71 vp
.width
= screen
->lcdwidth
;
72 vp
.height
= screen
->lcdheight
;
75 screen
->double_height (false);
79 vsnprintf(splash_buf
, sizeof(splash_buf
), fmt
, ap
);
82 /* break splash string into display lines, doing proper word wrap */
84 next
= strtok_r(splash_buf
, " ", &store
);
86 goto end
; /* nothing to display */
91 #ifdef HAVE_LCD_BITMAP
92 screen
->getstringsize(next
, &w
, NULL
);
98 if (x
+ (next
- lastbreak
) * space_w
+ w
99 > vp
.width
- RECT_SPACING
*2)
100 { /* too wide, wrap */
101 #ifdef HAVE_LCD_BITMAP
105 if ((y
+ h
> vp
.height
) || (line
>= (MAXLINES
-1)))
106 break; /* screen full or out of lines */
109 lines
[++line
] = next
;
113 /* restore & calculate spacing */
115 x
+= (next
- lastbreak
) * space_w
;
119 lastbreak
= next
+ strlen(next
);
120 next
= strtok_r(NULL
, " ", &store
);
122 { /* no more words */
123 #ifdef HAVE_LCD_BITMAP
132 * First boundaries, then the grey filling, then the black border and finally
135 screen
->stop_scroll();
137 #ifdef HAVE_LCD_BITMAP
139 vp
.y
= (vp
.height
- vp
.y
- y
) / 2 - RECT_SPACING
; /* height => y start position */
140 vp
.x
+= (vp
.width
- maxw
) / 2 - RECT_SPACING
;
141 width
= maxw
+ 2*RECT_SPACING
;
142 height
= y
+ 2*RECT_SPACING
;
148 if (width
> vp
.width
)
150 if (height
> vp
.height
)
155 vp
.flags
|= VP_FLAG_ALIGN_CENTER
;
157 if (screen
->depth
> 1)
159 vp
.drawmode
= DRMODE_FG
;
160 /* can't do vp.fg_pattern here, since set_foreground does a bit more on
162 screen
->set_foreground(SCREEN_COLOR_TO_NATIVE(screen
, LCD_LIGHTGRAY
));
166 vp
.drawmode
= (DRMODE_SOLID
|DRMODE_INVERSEVID
);
168 screen
->fillrect(0, 0, vp
.width
, vp
.height
);
171 if (screen
->depth
> 1)
172 /* can't do vp.fg_pattern here, since set_foreground does a bit more on
174 screen
->set_foreground(SCREEN_COLOR_TO_NATIVE(screen
, LCD_BLACK
));
177 vp
.drawmode
= DRMODE_SOLID
;
179 screen
->drawrect(0, 0, vp
.width
, vp
.height
);
181 /* prepare putting the text */
183 #else /* HAVE_LCD_CHARCELLS */
184 y
= 0; /* vertical centering on 2 lines would be silly */
185 screen
->clear_display();
188 /* print the message to screen */
189 for (i
= 0; i
<= line
; i
++, y
+=h
)
191 #ifdef HAVE_LCD_BITMAP
192 screen
->putsxy(0, y
, lines
[i
]);
194 screen
->puts(0, y
, lines
[i
]);
197 screen
->update_viewport();
199 screen
->set_viewport(NULL
);
202 void splashf(int ticks
, const char *fmt
, ...)
207 /* If fmt is a lang ID then get the corresponding string (which
208 still might contain % place holders). */
209 fmt
= P2STR((unsigned char *)fmt
);
213 splash_internal(&(screens
[i
]), fmt
, ap
);
220 void splash(int ticks
, const char *str
)
222 #if !defined(SIMULATOR) || CONFIG_CODEC == SWCODEC
224 /* fmt may be a so called virtual pointer. See settings.h. */
225 if((id
= P2ID((const unsigned char*)str
)) >= 0)
226 /* If fmt specifies a voicefont ID, and voice menus are
227 enabled, then speak it. */
228 cond_talk_ids_fq(id
);
230 splashf(ticks
, "%s", P2STR((const unsigned char*)str
));