diff options
author | Jens Arnold <amiconn@rockbox.org> | 2005-03-05 22:45:04 +0000 |
---|---|---|
committer | Jens Arnold <amiconn@rockbox.org> | 2005-03-05 22:45:04 +0000 |
commit | fabdf1de6f1a8fa8e281a3d428f484778b818344 (patch) | |
tree | db9a6c0a8c5f86d19bf14e7bdde8f9f1944e1871 /apps | |
parent | 576d029ece8fe9fc891ad7b50658b39178a40ead (diff) | |
download | rockbox-fabdf1de6f1a8fa8e281a3d428f484778b818344.tar.gz rockbox-fabdf1de6f1a8fa8e281a3d428f484778b818344.zip |
Logo plugin: (1) Changed button handling. Left/Down now always decreases the absolute delta (down to 0), while Right/Up increaes it. (2) Adapted for player using the player graphics library.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6146 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'apps')
-rw-r--r-- | apps/plugins/SOURCES | 2 | ||||
-rw-r--r-- | apps/plugins/logo.c | 125 |
2 files changed, 97 insertions, 30 deletions
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index 581d164e94..030fc324d9 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES | |||
@@ -5,6 +5,7 @@ cube.c | |||
5 | favorites.c | 5 | favorites.c |
6 | firmware_flash.c | 6 | firmware_flash.c |
7 | helloworld.c | 7 | helloworld.c |
8 | logo.c | ||
8 | metronome.c | 9 | metronome.c |
9 | mosaique.c | 10 | mosaique.c |
10 | rockbox_flash.c | 11 | rockbox_flash.c |
@@ -22,7 +23,6 @@ chip8.c | |||
22 | flipit.c | 23 | flipit.c |
23 | grayscale.c | 24 | grayscale.c |
24 | jpeg.c | 25 | jpeg.c |
25 | logo.c | ||
26 | mandelbrot.c | 26 | mandelbrot.c |
27 | minesweeper.c | 27 | minesweeper.c |
28 | oscillograph.c | 28 | oscillograph.c |
diff --git a/apps/plugins/logo.c b/apps/plugins/logo.c index 50e9c02d68..753b28bf1e 100644 --- a/apps/plugins/logo.c +++ b/apps/plugins/logo.c | |||
@@ -17,12 +17,16 @@ | |||
17 | * | 17 | * |
18 | **************************************************************************/ | 18 | **************************************************************************/ |
19 | #include "plugin.h" | 19 | #include "plugin.h" |
20 | #include "playergfx.h" | ||
20 | 21 | ||
21 | #if defined(HAVE_LCD_BITMAP) && (LCD_WIDTH >= 91) | 22 | #ifdef HAVE_LCD_BITMAP |
23 | #define DISPLAY_WIDTH LCD_WIDTH | ||
24 | #define DISPLAY_HEIGHT LCD_HEIGHT | ||
25 | #define RAND_SCALE 5 | ||
22 | 26 | ||
23 | #if LCD_WIDTH > 112 | 27 | #if LCD_WIDTH > 112 |
24 | #define WIDTH 112 | 28 | #define LOGO_WIDTH 112 |
25 | #define HEIGHT 37 | 29 | #define LOGO_HEIGHT 37 |
26 | #define LOGO rockbox112x37 | 30 | #define LOGO rockbox112x37 |
27 | const unsigned char rockbox112x37[]={ | 31 | const unsigned char rockbox112x37[]={ |
28 | 0x00, 0x00, 0x02, 0xff, 0x02, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, | 32 | 0x00, 0x00, 0x02, 0xff, 0x02, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, |
@@ -76,9 +80,9 @@ const unsigned char rockbox112x37[]={ | |||
76 | 0x08, 0xe8, 0xe8, 0xa8, 0x09, 0x0a, 0x0d, 0x02, | 80 | 0x08, 0xe8, 0xe8, 0xa8, 0x09, 0x0a, 0x0d, 0x02, |
77 | }; | 81 | }; |
78 | 82 | ||
79 | #else | 83 | #else /* LCD_WIDTH <= 112 */ |
80 | #define WIDTH 91 | 84 | #define LOGO_WIDTH 91 |
81 | #define HEIGHT 32 | 85 | #define LOGO_HEIGHT 32 |
82 | #define LOGO rockbox91x32 | 86 | #define LOGO rockbox91x32 |
83 | const unsigned char rockbox91x32[] = { | 87 | const unsigned char rockbox91x32[] = { |
84 | 0x00, 0x02, 0x7f, 0x02, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xf8, 0xf8, 0xf0, | 88 | 0x00, 0x02, 0x7f, 0x02, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xfa, 0xf8, 0xf8, 0xf0, |
@@ -113,37 +117,81 @@ const unsigned char rockbox91x32[] = { | |||
113 | 0x08, 0x10, 0x20, 0x41, 0x42, 0x42, 0x43, 0x42, 0x41, 0x40, 0x60, 0x50, 0x40, | 117 | 0x08, 0x10, 0x20, 0x41, 0x42, 0x42, 0x43, 0x42, 0x41, 0x40, 0x60, 0x50, 0x40, |
114 | 0x40, 0x40, 0x20, 0x50, 0x28, 0x10, 0x20, 0x40, 0x43, 0x44, 0x5b, 0x64, 0x18, | 118 | 0x40, 0x40, 0x20, 0x50, 0x28, 0x10, 0x20, 0x40, 0x43, 0x44, 0x5b, 0x64, 0x18, |
115 | }; | 119 | }; |
120 | #endif /* LCD_WIDTH */ | ||
121 | |||
122 | #else /* !LCD_BITMAP */ | ||
123 | #define DISPLAY_WIDTH 55 | ||
124 | #define DISPLAY_HEIGHT 14 | ||
125 | #define RAND_SCALE 2 | ||
126 | #define LOGO_WIDTH 16 | ||
127 | #define LOGO_HEIGHT 7 | ||
128 | #define LOGO rockbox16x7 | ||
129 | const unsigned char rockbox16x7[] = { | ||
130 | 0x0a, 0x55, 0x7e, 0x18, 0x00, 0xff, 0xff, 0x09, | ||
131 | 0xff, 0x76, 0x00, 0xff, 0xff, 0x44, 0x7c, 0x38, | ||
132 | }; | ||
133 | #endif /* !LCD_BITMAP */ | ||
134 | |||
135 | /* variable button definitions */ | ||
136 | #if CONFIG_KEYPAD == PLAYER_PAD | ||
137 | #define LP_QUIT BUTTON_STOP | ||
138 | #define LP_DEC_X BUTTON_LEFT | ||
139 | #define LP_INC_X BUTTON_RIGHT | ||
140 | #define LP_DEC_Y (BUTTON_ON | BUTTON_LEFT) | ||
141 | #define LP_INC_Y (BUTTON_ON | BUTTON_RIGHT) | ||
142 | #else | ||
143 | #define LP_QUIT BUTTON_OFF | ||
144 | #define LP_DEC_X BUTTON_LEFT | ||
145 | #define LP_INC_X BUTTON_RIGHT | ||
146 | #define LP_DEC_Y BUTTON_DOWN | ||
147 | #define LP_INC_Y BUTTON_UP | ||
116 | #endif | 148 | #endif |
117 | 149 | ||
118 | 150 | ||
119 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) { | 151 | enum plugin_status plugin_start(struct plugin_api* api, void* parameter) { |
120 | int button; | 152 | int button; |
121 | int timer = 10; | 153 | int timer = 10; |
122 | int x = (LCD_WIDTH / 2) - (WIDTH / 2); | 154 | int x = (DISPLAY_WIDTH / 2) - (LOGO_WIDTH / 2); |
123 | int y = (LCD_HEIGHT / 2) - (HEIGHT / 2); | 155 | int y = (DISPLAY_HEIGHT / 2) - (LOGO_HEIGHT / 2); |
124 | struct plugin_api* rb = api; | 156 | struct plugin_api* rb = api; |
125 | int dx; | 157 | int dx; |
126 | int dy; | 158 | int dy; |
159 | #ifdef HAVE_LCD_CHARCELLS | ||
160 | int cpos = -1; | ||
161 | int old_cpos = -1; | ||
162 | #endif | ||
127 | 163 | ||
128 | TEST_PLUGIN_API(api); | 164 | TEST_PLUGIN_API(api); |
129 | (void)parameter; | 165 | (void)parameter; |
130 | rb->srand(*rb->current_tick); | ||
131 | 166 | ||
132 | dx = rb->rand()%11 - 5; | 167 | #ifdef HAVE_LCD_CHARCELLS |
133 | dy = rb->rand()%11 - 5; | 168 | if (!pgfx_init(rb, 4, 2)) { |
169 | rb->splash(HZ*2, true, "Old LCD :("); | ||
170 | return PLUGIN_OK; | ||
171 | } | ||
172 | #endif | ||
173 | rb->srand(*rb->current_tick); | ||
174 | dx = rb->rand()%(2*RAND_SCALE+1) - RAND_SCALE; | ||
175 | dy = rb->rand()%(2*RAND_SCALE+1) - RAND_SCALE; | ||
134 | 176 | ||
135 | while (1) { | 177 | while (1) { |
178 | #ifdef HAVE_LCD_BITMAP | ||
136 | rb->lcd_clear_display(); | 179 | rb->lcd_clear_display(); |
137 | rb->lcd_bitmap(LOGO, x, y, WIDTH, HEIGHT, false); | 180 | rb->lcd_bitmap(LOGO, x, y, LOGO_WIDTH, LOGO_HEIGHT, false); |
181 | #else | ||
182 | pgfx_clear_display(); | ||
183 | pgfx_bitmap(LOGO, x % 5, y, LOGO_WIDTH, LOGO_HEIGHT, false); | ||
184 | cpos = x / 5; | ||
185 | #endif | ||
138 | 186 | ||
139 | x += dx; | 187 | x += dx; |
140 | if (x < 0) { | 188 | if (x < 0) { |
141 | dx = -dx; | 189 | dx = -dx; |
142 | x = 0; | 190 | x = 0; |
143 | } | 191 | } |
144 | if (x + WIDTH > LCD_WIDTH) { | 192 | if (x > DISPLAY_WIDTH - LOGO_WIDTH) { |
145 | dx = -dx; | 193 | dx = -dx; |
146 | x = LCD_WIDTH - WIDTH; | 194 | x = DISPLAY_WIDTH - LOGO_WIDTH; |
147 | } | 195 | } |
148 | 196 | ||
149 | y += dy; | 197 | y += dy; |
@@ -151,37 +199,56 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) { | |||
151 | dy = -dy; | 199 | dy = -dy; |
152 | y = 0; | 200 | y = 0; |
153 | } | 201 | } |
154 | if (y + HEIGHT > LCD_HEIGHT) { | 202 | if (y > DISPLAY_HEIGHT - LOGO_HEIGHT) { |
155 | dy = -dy; | 203 | dy = -dy; |
156 | y = LCD_HEIGHT - HEIGHT; | 204 | y = DISPLAY_HEIGHT - LOGO_HEIGHT; |
157 | } | 205 | } |
158 | 206 | ||
207 | #ifdef HAVE_LCD_BITMAP | ||
159 | rb->lcd_update(); | 208 | rb->lcd_update(); |
209 | #else | ||
210 | if (cpos != old_cpos) { | ||
211 | rb->lcd_clear_display(); | ||
212 | pgfx_update(); | ||
213 | pgfx_display(cpos, 0); | ||
214 | old_cpos = cpos; | ||
215 | } | ||
216 | else | ||
217 | pgfx_update(); | ||
218 | #endif | ||
160 | rb->sleep(HZ/timer); | 219 | rb->sleep(HZ/timer); |
161 | 220 | ||
162 | button = rb->button_get(false); | 221 | button = rb->button_get(false); |
163 | switch (button) { | 222 | switch (button) { |
164 | case BUTTON_OFF: | 223 | case LP_QUIT: |
224 | #ifdef HAVE_LCD_CHARCELLS | ||
225 | pgfx_release(); | ||
226 | #endif | ||
165 | return PLUGIN_OK; | 227 | return PLUGIN_OK; |
166 | case BUTTON_LEFT: | 228 | case LP_DEC_X: |
167 | dx--; | 229 | if (dx) |
230 | dx += (dx < 0) ? 1 : -1; | ||
168 | break; | 231 | break; |
169 | case BUTTON_RIGHT: | 232 | case LP_INC_X: |
170 | dx++; | 233 | dx += (dx < 0) ? -1 : 1; |
171 | break; | 234 | break; |
172 | case BUTTON_UP: | 235 | case LP_DEC_Y: |
173 | dy--; | 236 | if (dy) |
237 | dy += (dy < 0) ? 1 : -1; | ||
174 | break; | 238 | break; |
175 | case BUTTON_DOWN: | 239 | case LP_INC_Y: |
176 | dy++; | 240 | dy += (dy < 0) ? -1 : 1; |
177 | break; | 241 | break; |
178 | 242 | ||
179 | default: | 243 | default: |
180 | if (rb->default_event_handler(button) == SYS_USB_CONNECTED) | 244 | if (rb->default_event_handler(button) == SYS_USB_CONNECTED) { |
181 | return PLUGIN_USB_CONNECTED; | 245 | #ifdef HAVE_LCD_CHARCELLS |
246 | pgfx_release(); | ||
247 | #endif | ||
248 | return PLUGIN_USB_CONNECTED; | ||
249 | } | ||
182 | break; | 250 | break; |
183 | } | 251 | } |
184 | } | 252 | } |
185 | } | 253 | } |
186 | 254 | ||
187 | #endif | ||