blob: 50a939637262a0bd79cf64eba5589edcfe4afb55 [file] [log] [blame]
Dave Chapman3646c312008-01-08 01:22:14 +00001/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id: helloworld.c 12807 2007-03-16 21:56:08Z amiconn $
9 *
10 * Copyright (C) 2007 Dave Chapman
11 *
Daniel Stenberg2acc0ac2008-06-28 18:10:04 +000012 * 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.
Dave Chapman3646c312008-01-08 01:22:14 +000016 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "plugin.h"
23
24PLUGIN_HEADER
25
Steve Bavin65265772008-05-13 09:57:56 +000026static const struct plugin_api* rb;
Dave Chapman3646c312008-01-08 01:22:14 +000027
28#ifdef HAVE_LCD_BITMAP
29
30#ifdef HAVE_LCD_COLOR
31#define BGCOLOR_1 LCD_RGBPACK(255,255,0)
32#define BGCOLOR_2 LCD_RGBPACK(0,255,0)
33#define FGCOLOR_1 LCD_RGBPACK(0,0,255)
Bertrik Sikkenc8269332008-04-13 22:10:31 +000034#elif LCD_DEPTH > 1
Dave Chapman3646c312008-01-08 01:22:14 +000035#define BGCOLOR_1 LCD_DARKGRAY
36#define BGCOLOR_2 LCD_LIGHTGRAY
37#define FGCOLOR_1 LCD_WHITE
38#endif
39
40static struct viewport vp0 =
41{
42 .x = 0,
43 .y = 0,
44 .width = LCD_WIDTH,
45 .height = 20,
46 .font = FONT_UI,
47 .drawmode = DRMODE_SOLID,
Dave Chapman3646c312008-01-08 01:22:14 +000048#if LCD_DEPTH > 1
49 .fg_pattern = LCD_DEFAULT_FG,
50 .bg_pattern = BGCOLOR_1,
51#endif
52#ifdef HAVE_LCD_COLOR
53 .lss_pattern = LCD_DEFAULT_BG,
54 .lse_pattern = LCD_DEFAULT_BG,
55 .lst_pattern = LCD_DEFAULT_BG,
56#endif
57};
58
59static struct viewport vp1 =
60{
61 .x = LCD_WIDTH / 10,
62 .y = 20,
63 .width = LCD_WIDTH / 3,
64 .height = LCD_HEIGHT / 2,
65 .font = FONT_SYSFIXED,
66 .drawmode = DRMODE_SOLID,
Dave Chapman3646c312008-01-08 01:22:14 +000067#if LCD_DEPTH > 1
68 .fg_pattern = LCD_DEFAULT_FG,
69 .bg_pattern = LCD_DEFAULT_BG,
70#ifdef HAVE_LCD_COLOR
71 .lss_pattern = LCD_DEFAULT_BG,
72 .lse_pattern = LCD_DEFAULT_BG,
73 .lst_pattern = LCD_DEFAULT_BG,
74#endif
75#endif
76};
77
78static struct viewport vp2 =
79{
80 .x = LCD_WIDTH / 2,
81 .y = 40,
82 .width = LCD_WIDTH / 3,
83 .height = (LCD_HEIGHT / 2),
84 .font = FONT_UI,
85 .drawmode = DRMODE_SOLID,
Dave Chapman3646c312008-01-08 01:22:14 +000086#if LCD_DEPTH > 1
87 .fg_pattern = FGCOLOR_1,
88 .bg_pattern = BGCOLOR_2,
89#ifdef HAVE_LCD_COLOR
90 .lss_pattern = LCD_DEFAULT_BG,
91 .lse_pattern = LCD_DEFAULT_BG,
92 .lst_pattern = LCD_DEFAULT_BG,
93#endif
94#endif
95};
96
97
98static struct viewport vp3 =
99{
100 .x = LCD_WIDTH / 4,
101 .y = (5 * LCD_HEIGHT) / 8,
102 .width = LCD_WIDTH / 2,
103 .height = (LCD_HEIGHT / 4),
104 .font = FONT_SYSFIXED,
105 .drawmode = DRMODE_SOLID,
Dave Chapman3646c312008-01-08 01:22:14 +0000106#if LCD_DEPTH > 1
107 .fg_pattern = LCD_BLACK,
108 .bg_pattern = LCD_WHITE,
109#ifdef HAVE_LCD_COLOR
110 .lss_pattern = LCD_DEFAULT_BG,
111 .lse_pattern = LCD_DEFAULT_BG,
112 .lst_pattern = LCD_DEFAULT_BG,
113#endif
114#endif
115};
116
117
118#ifdef HAVE_REMOTE_LCD
119static struct viewport rvp0 =
120{
121 .x = 0,
122 .y = 10,
123 .width = LCD_REMOTE_WIDTH / 3,
124 .height = LCD_REMOTE_HEIGHT - 10,
125 .font = FONT_SYSFIXED,
126 .drawmode = DRMODE_SOLID,
Dave Chapman3646c312008-01-08 01:22:14 +0000127#if LCD_REMOTE_DEPTH > 1
128 .fg_pattern = LCD_REMOTE_BLACK,
129 .bg_pattern = LCD_REMOTE_LIGHTGRAY,
130#endif
131};
132
133static struct viewport rvp1 =
134{
135 .x = LCD_REMOTE_WIDTH / 2,
136 .y = 0,
137 .width = LCD_REMOTE_WIDTH / 3,
138 .height = LCD_REMOTE_HEIGHT - 10,
139 .font = FONT_SYSFIXED,
140 .drawmode = DRMODE_SOLID,
Dave Chapman3646c312008-01-08 01:22:14 +0000141#if LCD_REMOTE_DEPTH > 1
142 .fg_pattern = LCD_REMOTE_DEFAULT_FG,
143 .bg_pattern = LCD_REMOTE_DEFAULT_BG
144#endif
145};
146
147#endif
148
149
Steve Bavin65265772008-05-13 09:57:56 +0000150enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
Dave Chapman3646c312008-01-08 01:22:14 +0000151{
152 (void)parameter;
153 char buf[80];
154 int i,y;
155
156 rb = api;
157
158 rb->screens[SCREEN_MAIN]->set_viewport(&vp0);
159 rb->screens[SCREEN_MAIN]->clear_viewport();
160 rb->screens[SCREEN_MAIN]->puts_scroll(0,0,"Viewport testing plugin - this is a scrolling title");
161
162 rb->screens[SCREEN_MAIN]->set_viewport(&vp1);
163 rb->screens[SCREEN_MAIN]->clear_viewport();
164
165 for (i = 0 ; i < 3; i++)
166 {
167 rb->snprintf(buf,sizeof(buf),"Left text, scrolling_line %d",i);
168 rb->screens[SCREEN_MAIN]->puts_scroll(0,i,buf);
169 }
170
171 rb->screens[SCREEN_MAIN]->set_viewport(&vp2);
172 rb->screens[SCREEN_MAIN]->clear_viewport();
173 for (i = 1 ; i < 3; i++)
174 {
175 rb->snprintf(buf,sizeof(buf),"Right text, scrolling line %d",i);
176 rb->screens[SCREEN_MAIN]->puts_scroll(1,i,buf);
177 }
178
179 y = -10;
180 for (i = -10; i < vp2.width + 10; i += 5)
181 {
182 rb->screens[SCREEN_MAIN]->drawline(i, y, i, vp2.height - y);
183 }
184
185 rb->screens[SCREEN_MAIN]->set_viewport(&vp3);
186 rb->screens[SCREEN_MAIN]->clear_viewport();
187 for (i = 1 ; i < 2; i++)
188 {
189 rb->snprintf(buf,sizeof(buf),"Bottom text, a scrolling line %d",i);
190 rb->screens[SCREEN_MAIN]->puts_scroll(2,i,buf);
191 }
192 rb->screens[SCREEN_MAIN]->puts_scroll(4,i,"Short line");
193 rb->screens[SCREEN_MAIN]->update();
194
195
196#ifdef HAVE_REMOTE_LCD
197 rb->screens[SCREEN_REMOTE]->set_viewport(&rvp0);
198 rb->screens[SCREEN_REMOTE]->clear_viewport();
199
200 for (i = 0 ; i < 5; i++)
201 {
202 rb->snprintf(buf,sizeof(buf),"Left text, scrolling_line %d",i);
203 rb->screens[SCREEN_REMOTE]->puts_scroll(0,i,buf);
204 }
205 rb->screens[SCREEN_REMOTE]->puts(1,i,"Static");
206
207 rb->screens[SCREEN_REMOTE]->set_viewport(&rvp1);
208 rb->screens[SCREEN_REMOTE]->clear_viewport();
209 for (i = 1 ; i < 3; i++)
210 {
211 rb->snprintf(buf,sizeof(buf),"Right text, scrolling line %d",i);
212 rb->screens[SCREEN_REMOTE]->puts_scroll(1,i,buf);
213 }
214
215 y = -10;
216 for (i = -10; i < rvp1.width + 10; i += 5)
217 {
218 rb->screens[SCREEN_REMOTE]->drawline(i, y, i, rvp1.height - y);
219 }
220
221 rb->screens[SCREEN_REMOTE]->update();
222#endif
223
224 rb->button_get(true);
225
226 /* Restore the default viewport */
227 rb->screens[SCREEN_MAIN]->set_viewport(NULL);
228#ifdef HAVE_REMOTE_LCD
229 rb->screens[SCREEN_REMOTE]->set_viewport(NULL);
230#endif
231
232 return PLUGIN_OK;
233}
234
235
236#else
237
238/* Charcell version of plugin */
239
240static struct viewport vp0 =
241{
242 .x = 0,
243 .y = 0,
244 .width = 5,
245 .height = 1,
Dave Chapman3646c312008-01-08 01:22:14 +0000246};
247
248static struct viewport vp1 =
249{
250 .x = 6,
251 .y = 0,
252 .width = 5,
253 .height = 1,
Dave Chapman3646c312008-01-08 01:22:14 +0000254};
255
256static struct viewport vp2 =
257{
258 .x = 0,
259 .y = 1,
260 .width = LCD_WIDTH,
261 .height = 1,
Dave Chapman3646c312008-01-08 01:22:14 +0000262};
263
264
Steve Bavin65265772008-05-13 09:57:56 +0000265enum plugin_status plugin_start(const struct plugin_api* api, const void* parameter)
Dave Chapman3646c312008-01-08 01:22:14 +0000266{
267 (void)parameter;
268
269 rb = api;
270
271 rb->screens[SCREEN_MAIN]->set_viewport(&vp0);
272 rb->screens[SCREEN_MAIN]->clear_viewport();
273 rb->screens[SCREEN_MAIN]->puts_scroll(0,0,"Rockbox");
274
275 rb->screens[SCREEN_MAIN]->set_viewport(&vp1);
276 rb->screens[SCREEN_MAIN]->clear_viewport();
277 rb->screens[SCREEN_MAIN]->puts_scroll(0,0,"Viewports");
278
279 rb->screens[SCREEN_MAIN]->set_viewport(&vp2);
280 rb->screens[SCREEN_MAIN]->clear_viewport();
281 rb->screens[SCREEN_MAIN]->puts_scroll(0,0,"Demonstration");
282
283 rb->screens[SCREEN_MAIN]->update();
284
285 rb->button_get(true);
286
287 /* Restore the default viewport */
288 rb->screens[SCREEN_MAIN]->set_viewport(NULL);
289
290 return PLUGIN_OK;
291}
292
293#endif /* !HAVE_LCD_BITMAP */