1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
8 * $Id: helloworld.c 12807 2007-03-16 21:56:08Z amiconn $
10 * Copyright (C) 2007 Dave Chapman
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
24 static struct plugin_api
* rb
;
26 #ifdef HAVE_LCD_BITMAP
29 #define BGCOLOR_1 LCD_RGBPACK(255,255,0)
30 #define BGCOLOR_2 LCD_RGBPACK(0,255,0)
31 #define FGCOLOR_1 LCD_RGBPACK(0,0,255)
32 #else if LCD_DEPTH > 1
33 #define BGCOLOR_1 LCD_DARKGRAY
34 #define BGCOLOR_2 LCD_LIGHTGRAY
35 #define FGCOLOR_1 LCD_WHITE
38 static struct viewport vp0
=
45 .drawmode
= DRMODE_SOLID
,
49 .fg_pattern
= LCD_DEFAULT_FG
,
50 .bg_pattern
= BGCOLOR_1
,
53 .lss_pattern
= LCD_DEFAULT_BG
,
54 .lse_pattern
= LCD_DEFAULT_BG
,
55 .lst_pattern
= LCD_DEFAULT_BG
,
59 static struct viewport vp1
=
63 .width
= LCD_WIDTH
/ 3,
64 .height
= LCD_HEIGHT
/ 2,
65 .font
= FONT_SYSFIXED
,
66 .drawmode
= DRMODE_SOLID
,
70 .fg_pattern
= LCD_DEFAULT_FG
,
71 .bg_pattern
= LCD_DEFAULT_BG
,
73 .lss_pattern
= LCD_DEFAULT_BG
,
74 .lse_pattern
= LCD_DEFAULT_BG
,
75 .lst_pattern
= LCD_DEFAULT_BG
,
80 static struct viewport vp2
=
84 .width
= LCD_WIDTH
/ 3,
85 .height
= (LCD_HEIGHT
/ 2),
87 .drawmode
= DRMODE_SOLID
,
91 .fg_pattern
= FGCOLOR_1
,
92 .bg_pattern
= BGCOLOR_2
,
94 .lss_pattern
= LCD_DEFAULT_BG
,
95 .lse_pattern
= LCD_DEFAULT_BG
,
96 .lst_pattern
= LCD_DEFAULT_BG
,
102 static struct viewport vp3
=
105 .y
= (5 * LCD_HEIGHT
) / 8,
106 .width
= LCD_WIDTH
/ 2,
107 .height
= (LCD_HEIGHT
/ 4),
108 .font
= FONT_SYSFIXED
,
109 .drawmode
= DRMODE_SOLID
,
113 .fg_pattern
= LCD_BLACK
,
114 .bg_pattern
= LCD_WHITE
,
115 #ifdef HAVE_LCD_COLOR
116 .lss_pattern
= LCD_DEFAULT_BG
,
117 .lse_pattern
= LCD_DEFAULT_BG
,
118 .lst_pattern
= LCD_DEFAULT_BG
,
124 #ifdef HAVE_REMOTE_LCD
125 static struct viewport rvp0
=
129 .width
= LCD_REMOTE_WIDTH
/ 3,
130 .height
= LCD_REMOTE_HEIGHT
- 10,
131 .font
= FONT_SYSFIXED
,
132 .drawmode
= DRMODE_SOLID
,
135 #if LCD_REMOTE_DEPTH > 1
136 .fg_pattern
= LCD_REMOTE_BLACK
,
137 .bg_pattern
= LCD_REMOTE_LIGHTGRAY
,
141 static struct viewport rvp1
=
143 .x
= LCD_REMOTE_WIDTH
/ 2,
145 .width
= LCD_REMOTE_WIDTH
/ 3,
146 .height
= LCD_REMOTE_HEIGHT
- 10,
147 .font
= FONT_SYSFIXED
,
148 .drawmode
= DRMODE_SOLID
,
151 #if LCD_REMOTE_DEPTH > 1
152 .fg_pattern
= LCD_REMOTE_DEFAULT_FG
,
153 .bg_pattern
= LCD_REMOTE_DEFAULT_BG
160 enum plugin_status
plugin_start(struct plugin_api
* api
, void* parameter
)
168 rb
->screens
[SCREEN_MAIN
]->set_viewport(&vp0
);
169 rb
->screens
[SCREEN_MAIN
]->clear_viewport();
170 rb
->screens
[SCREEN_MAIN
]->puts_scroll(0,0,"Viewport testing plugin - this is a scrolling title");
172 rb
->screens
[SCREEN_MAIN
]->set_viewport(&vp1
);
173 rb
->screens
[SCREEN_MAIN
]->clear_viewport();
175 for (i
= 0 ; i
< 3; i
++)
177 rb
->snprintf(buf
,sizeof(buf
),"Left text, scrolling_line %d",i
);
178 rb
->screens
[SCREEN_MAIN
]->puts_scroll(0,i
,buf
);
181 rb
->screens
[SCREEN_MAIN
]->set_viewport(&vp2
);
182 rb
->screens
[SCREEN_MAIN
]->clear_viewport();
183 for (i
= 1 ; i
< 3; i
++)
185 rb
->snprintf(buf
,sizeof(buf
),"Right text, scrolling line %d",i
);
186 rb
->screens
[SCREEN_MAIN
]->puts_scroll(1,i
,buf
);
190 for (i
= -10; i
< vp2
.width
+ 10; i
+= 5)
192 rb
->screens
[SCREEN_MAIN
]->drawline(i
, y
, i
, vp2
.height
- y
);
195 rb
->screens
[SCREEN_MAIN
]->set_viewport(&vp3
);
196 rb
->screens
[SCREEN_MAIN
]->clear_viewport();
197 for (i
= 1 ; i
< 2; i
++)
199 rb
->snprintf(buf
,sizeof(buf
),"Bottom text, a scrolling line %d",i
);
200 rb
->screens
[SCREEN_MAIN
]->puts_scroll(2,i
,buf
);
202 rb
->screens
[SCREEN_MAIN
]->puts_scroll(4,i
,"Short line");
203 rb
->screens
[SCREEN_MAIN
]->update();
206 #ifdef HAVE_REMOTE_LCD
207 rb
->screens
[SCREEN_REMOTE
]->set_viewport(&rvp0
);
208 rb
->screens
[SCREEN_REMOTE
]->clear_viewport();
210 for (i
= 0 ; i
< 5; i
++)
212 rb
->snprintf(buf
,sizeof(buf
),"Left text, scrolling_line %d",i
);
213 rb
->screens
[SCREEN_REMOTE
]->puts_scroll(0,i
,buf
);
215 rb
->screens
[SCREEN_REMOTE
]->puts(1,i
,"Static");
217 rb
->screens
[SCREEN_REMOTE
]->set_viewport(&rvp1
);
218 rb
->screens
[SCREEN_REMOTE
]->clear_viewport();
219 for (i
= 1 ; i
< 3; i
++)
221 rb
->snprintf(buf
,sizeof(buf
),"Right text, scrolling line %d",i
);
222 rb
->screens
[SCREEN_REMOTE
]->puts_scroll(1,i
,buf
);
226 for (i
= -10; i
< rvp1
.width
+ 10; i
+= 5)
228 rb
->screens
[SCREEN_REMOTE
]->drawline(i
, y
, i
, rvp1
.height
- y
);
231 rb
->screens
[SCREEN_REMOTE
]->update();
234 rb
->button_get(true);
236 /* Restore the default viewport */
237 rb
->screens
[SCREEN_MAIN
]->set_viewport(NULL
);
238 #ifdef HAVE_REMOTE_LCD
239 rb
->screens
[SCREEN_REMOTE
]->set_viewport(NULL
);
248 /* Charcell version of plugin */
250 static struct viewport vp0
=
260 static struct viewport vp1
=
270 static struct viewport vp2
=
281 enum plugin_status
plugin_start(struct plugin_api
* api
, void* parameter
)
287 rb
->screens
[SCREEN_MAIN
]->set_viewport(&vp0
);
288 rb
->screens
[SCREEN_MAIN
]->clear_viewport();
289 rb
->screens
[SCREEN_MAIN
]->puts_scroll(0,0,"Rockbox");
291 rb
->screens
[SCREEN_MAIN
]->set_viewport(&vp1
);
292 rb
->screens
[SCREEN_MAIN
]->clear_viewport();
293 rb
->screens
[SCREEN_MAIN
]->puts_scroll(0,0,"Viewports");
295 rb
->screens
[SCREEN_MAIN
]->set_viewport(&vp2
);
296 rb
->screens
[SCREEN_MAIN
]->clear_viewport();
297 rb
->screens
[SCREEN_MAIN
]->puts_scroll(0,0,"Demonstration");
299 rb
->screens
[SCREEN_MAIN
]->update();
301 rb
->button_get(true);
303 /* Restore the default viewport */
304 rb
->screens
[SCREEN_MAIN
]->set_viewport(NULL
);
309 #endif /* !HAVE_LCD_BITMAP */