1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2005 Jonas H�gqvist
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 **************************************************************************/
22 #include "lib/playergfx.h"
23 #include "lib/pluginlib_actions.h"
25 /* this set the context to use with PLA */
26 static const struct button_mapping
*plugin_contexts
[]
28 #ifdef HAVE_REMOTE_LCD
33 #ifdef HAVE_LCD_BITMAP
34 #define DISPLAY_WIDTH LCD_WIDTH
35 #define DISPLAY_HEIGHT LCD_HEIGHT
38 #ifdef HAVE_REMOTE_LCD
39 #define REMOTE_WIDTH LCD_REMOTE_WIDTH
40 #define REMOTE_HEIGHT LCD_REMOTE_HEIGHT
41 #include "pluginbitmaps/remote_rockboxlogo.h"
42 #define REMOTE_LOGO_WIDTH BMPWIDTH_remote_rockboxlogo
43 #define REMOTE_LOGO_HEIGHT BMPHEIGHT_remote_rockboxlogo
44 #define REMOTE_LOGO remote_rockboxlogo
45 extern const fb_remote_data remote_rockboxlogo
[];
46 #endif /* HAVE_REMOTE_LCD */
48 #define LOGO rockboxlogo
49 #include "pluginbitmaps/rockboxlogo.h"
50 #define LOGO_WIDTH BMPWIDTH_rockboxlogo
51 #define LOGO_HEIGHT BMPHEIGHT_rockboxlogo
52 extern const fb_data rockboxlogo
[];
54 #else /* !LCD_BITMAP */
55 #define DISPLAY_WIDTH 55
56 #define DISPLAY_HEIGHT 14
60 #define LOGO rockbox16x7
61 const unsigned char rockbox16x7
[] = {
62 0x47, 0x18, 0xa6, 0xd8, 0x66, 0xde, 0xb7, 0x9b,
63 0x76, 0xdb, 0x26, 0xdb, 0x66, 0xde,
65 #endif /* !LCD_BITMAP */
68 #define LP_QUIT PLA_EXIT
69 #define LP_QUIT2 PLA_CANCEL
70 #define LP_DEC_X PLA_LEFT
71 #define LP_DEC_X_REPEAT PLA_LEFT_REPEAT
72 #define LP_INC_X PLA_RIGHT
73 #define LP_INC_X_REPEAT PLA_RIGHT_REPEAT
74 #define LP_DEC_Y PLA_DOWN
75 #define LP_DEC_Y_REPEAT PLA_DOWN_REPEAT
76 #define LP_INC_Y PLA_UP
77 #define LP_INC_Y_REPEAT PLA_UP_REPEAT
79 enum plugin_status
plugin_start(const void* parameter
) {
82 int x
= (DISPLAY_WIDTH
/ 2) - (LOGO_WIDTH
/ 2);
83 int y
= (DISPLAY_HEIGHT
/ 2) - (LOGO_HEIGHT
/ 2);
86 #ifdef HAVE_LCD_CHARCELLS
93 #ifdef HAVE_LCD_CHARCELLS
94 if (!pgfx_init(4, 2)) {
95 rb
->splash(HZ
*2, "Old LCD :(");
99 rb
->srand(*rb
->current_tick
);
100 dx
= rb
->rand()%(2*RAND_SCALE
+1) - RAND_SCALE
;
101 dy
= rb
->rand()%(2*RAND_SCALE
+1) - RAND_SCALE
;
104 #ifdef HAVE_LCD_BITMAP
105 rb
->lcd_clear_display();
106 rb
->lcd_bitmap(LOGO
, x
, y
, LOGO_WIDTH
, LOGO_HEIGHT
);
108 rb
->lcd_remote_clear_display();
109 rb
->lcd_remote_bitmap(REMOTE_LOGO
,
110 (x
* (REMOTE_WIDTH
- REMOTE_LOGO_WIDTH
)) / (DISPLAY_WIDTH
- LOGO_WIDTH
),
111 (y
* (REMOTE_HEIGHT
- REMOTE_LOGO_HEIGHT
)) / (DISPLAY_HEIGHT
- LOGO_HEIGHT
),
112 REMOTE_LOGO_WIDTH
, REMOTE_LOGO_HEIGHT
);
115 pgfx_clear_display();
116 pgfx_mono_bitmap(LOGO
, x
% 5, y
, LOGO_WIDTH
, LOGO_HEIGHT
);
125 if (x
> DISPLAY_WIDTH
- LOGO_WIDTH
) {
127 x
= DISPLAY_WIDTH
- LOGO_WIDTH
;
135 if (y
> DISPLAY_HEIGHT
- LOGO_HEIGHT
) {
137 y
= DISPLAY_HEIGHT
- LOGO_HEIGHT
;
140 #ifdef HAVE_LCD_BITMAP
143 rb
->lcd_remote_update();
146 if (cpos
!= old_cpos
) {
147 rb
->lcd_clear_display();
148 pgfx_display(cpos
, 0);
157 /*We get button from PLA this way */
158 button
= pluginlib_getaction(TIMEOUT_NOBLOCK
, plugin_contexts
,
159 ARRAYLEN(plugin_contexts
));
164 #ifdef HAVE_LCD_CHARCELLS
169 case LP_DEC_X_REPEAT
:
171 dx
+= (dx
< 0) ? 1 : -1;
174 case LP_INC_X_REPEAT
:
175 dx
+= (dx
< 0) ? -1 : 1;
178 case LP_DEC_Y_REPEAT
:
180 dy
+= (dy
< 0) ? 1 : -1;
183 case LP_INC_Y_REPEAT
:
184 dy
+= (dy
< 0) ? -1 : 1;
188 if (rb
->default_event_handler(button
) == SYS_USB_CONNECTED
) {
189 #ifdef HAVE_LCD_CHARCELLS
192 return PLUGIN_USB_CONNECTED
;