diff options
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/SOURCES | 4 | ||||
-rw-r--r-- | apps/plugins/cube.c | 61 |
2 files changed, 57 insertions, 8 deletions
diff --git a/apps/plugins/SOURCES b/apps/plugins/SOURCES index eb05d8a46f..a14bb96cac 100644 --- a/apps/plugins/SOURCES +++ b/apps/plugins/SOURCES | |||
@@ -1,6 +1,7 @@ | |||
1 | /* plugins common to all models */ | 1 | /* plugins common to all models */ |
2 | battery_test.c | 2 | battery_test.c |
3 | chessclock.c | 3 | chessclock.c |
4 | cube.c | ||
4 | favorites.c | 5 | favorites.c |
5 | firmware_flash.c | 6 | firmware_flash.c |
6 | helloworld.c | 7 | helloworld.c |
@@ -16,7 +17,6 @@ viewer.c | |||
16 | bounce.c | 17 | bounce.c |
17 | calculator.c | 18 | calculator.c |
18 | chip8.c | 19 | chip8.c |
19 | cube.c | ||
20 | flipit.c | 20 | flipit.c |
21 | grayscale.c | 21 | grayscale.c |
22 | jpeg.c | 22 | jpeg.c |
@@ -57,7 +57,7 @@ wormlet.c | |||
57 | #ifdef HAVE_LCD_CHARCELLS /* Player model only */ | 57 | #ifdef HAVE_LCD_CHARCELLS /* Player model only */ |
58 | euroconverter.c | 58 | euroconverter.c |
59 | jackpot.c | 59 | jackpot.c |
60 | nim.c | 60 | nim.c |
61 | #endif /* #ifdef HAVE_LCD_CHARCELLS */ | 61 | #endif /* #ifdef HAVE_LCD_CHARCELLS */ |
62 | 62 | ||
63 | #ifndef HAVE_MMC | 63 | #ifndef HAVE_MMC |
diff --git a/apps/plugins/cube.c b/apps/plugins/cube.c index 905d8a582e..52edf3375f 100644 --- a/apps/plugins/cube.c +++ b/apps/plugins/cube.c | |||
@@ -19,7 +19,9 @@ | |||
19 | ***************************************************************************/ | 19 | ***************************************************************************/ |
20 | #include "plugin.h" | 20 | #include "plugin.h" |
21 | 21 | ||
22 | #ifdef HAVE_LCD_BITMAP | 22 | #ifdef HAVE_LCD_CHARCELLS |
23 | #include "playergfx.h" | ||
24 | #endif | ||
23 | 25 | ||
24 | /* Loops that the values are displayed */ | 26 | /* Loops that the values are displayed */ |
25 | #define DISP_TIME 30 | 27 | #define DISP_TIME 30 |
@@ -35,6 +37,16 @@ | |||
35 | #define CUBE_Z_DEC BUTTON_F1 | 37 | #define CUBE_Z_DEC BUTTON_F1 |
36 | #define CUBE_HIGHSPEED BUTTON_PLAY | 38 | #define CUBE_HIGHSPEED BUTTON_PLAY |
37 | 39 | ||
40 | #elif CONFIG_KEYPAD == PLAYER_PAD | ||
41 | #define CUBE_QUIT (BUTTON_STOP | BUTTON_REL) | ||
42 | #define CUBE_X_INC BUTTON_RIGHT | ||
43 | #define CUBE_X_DEC BUTTON_LEFT | ||
44 | #define CUBE_Y_INC (BUTTON_ON | BUTTON_RIGHT) | ||
45 | #define CUBE_Y_DEC (BUTTON_ON | BUTTON_LEFT) | ||
46 | #define CUBE_Z_INC (BUTTON_MENU | BUTTON_RIGHT) | ||
47 | #define CUBE_Z_DEC (BUTTON_MENU | BUTTON_LEFT) | ||
48 | #define CUBE_HIGHSPEED BUTTON_PLAY | ||
49 | |||
38 | #elif CONFIG_KEYPAD == ONDIO_PAD | 50 | #elif CONFIG_KEYPAD == ONDIO_PAD |
39 | #define CUBE_QUIT (BUTTON_OFF | BUTTON_REL) | 51 | #define CUBE_QUIT (BUTTON_OFF | BUTTON_REL) |
40 | #define CUBE_X_INC BUTTON_RIGHT | 52 | #define CUBE_X_INC BUTTON_RIGHT |
@@ -75,8 +87,13 @@ static long matrice[3][3]; | |||
75 | 87 | ||
76 | static int nb_points = 8; | 88 | static int nb_points = 8; |
77 | 89 | ||
90 | #ifdef HAVE_LCD_BITMAP | ||
78 | static int x_off = LCD_WIDTH/2; | 91 | static int x_off = LCD_WIDTH/2; |
79 | static int y_off = LCD_HEIGHT/2; | 92 | static int y_off = LCD_HEIGHT/2; |
93 | #else | ||
94 | static int x_off = 10; | ||
95 | static int y_off = 7; | ||
96 | #endif | ||
80 | static int z_off = 600; | 97 | static int z_off = 600; |
81 | 98 | ||
82 | /* Precalculated sine and cosine * 10000 (four digit fixed point math) */ | 99 | /* Precalculated sine and cosine * 10000 (four digit fixed point math) */ |
@@ -224,10 +241,10 @@ static void cube_viewport(void) | |||
224 | } | 241 | } |
225 | } | 242 | } |
226 | 243 | ||
227 | #if LCD_HEIGHT > 100 | 244 | #ifdef HAVE_LCD_BITMAP |
228 | #define DIST 80 | 245 | #define DIST (10*LCD_HEIGHT/16) |
229 | #else | 246 | #else |
230 | #define DIST 40 | 247 | #define DIST 9 |
231 | #endif | 248 | #endif |
232 | 249 | ||
233 | static void cube_init(void) | 250 | static void cube_init(void) |
@@ -245,7 +262,11 @@ static void cube_init(void) | |||
245 | 262 | ||
246 | static void line(int a, int b) | 263 | static void line(int a, int b) |
247 | { | 264 | { |
265 | #ifdef HAVE_LCD_BITMAP | ||
248 | rb->lcd_drawline(point2D[a].x, point2D[a].y, point2D[b].x, point2D[b].y); | 266 | rb->lcd_drawline(point2D[a].x, point2D[a].y, point2D[b].x, point2D[b].y); |
267 | #else | ||
268 | pgfx_drawline(point2D[a].x, point2D[a].y, point2D[b].x, point2D[b].y); | ||
269 | #endif | ||
249 | } | 270 | } |
250 | 271 | ||
251 | static void cube_draw(void) | 272 | static void cube_draw(void) |
@@ -286,7 +307,15 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
286 | (void)(parameter); | 307 | (void)(parameter); |
287 | rb = api; | 308 | rb = api; |
288 | 309 | ||
310 | #ifdef HAVE_LCD_BITMAP | ||
289 | rb->lcd_setfont(FONT_SYSFIXED); | 311 | rb->lcd_setfont(FONT_SYSFIXED); |
312 | #else | ||
313 | if (!pgfx_init(rb, 4, 2)) | ||
314 | { | ||
315 | rb->splash(HZ*2, true, "Old LCD :("); | ||
316 | return PLUGIN_OK; | ||
317 | } | ||
318 | #endif | ||
290 | 319 | ||
291 | cube_init(); | 320 | cube_init(); |
292 | 321 | ||
@@ -296,11 +325,16 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
296 | rb->yield(); | 325 | rb->yield(); |
297 | else | 326 | else |
298 | rb->sleep(4); | 327 | rb->sleep(4); |
299 | 328 | ||
329 | #ifdef HAVE_LCD_BITMAP | ||
300 | rb->lcd_clear_display(); | 330 | rb->lcd_clear_display(); |
331 | #else | ||
332 | pgfx_clear_display(); | ||
333 | #endif | ||
301 | cube_rotate(xa,ya,za); | 334 | cube_rotate(xa,ya,za); |
302 | cube_viewport(); | 335 | cube_viewport(); |
303 | cube_draw(); | 336 | cube_draw(); |
337 | #ifdef HAVE_LCD_BITMAP | ||
304 | if (t_disp>0) | 338 | if (t_disp>0) |
305 | { | 339 | { |
306 | t_disp--; | 340 | t_disp--; |
@@ -308,6 +342,18 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
308 | rb->lcd_putsxy(0, LCD_HEIGHT-8, buffer); | 342 | rb->lcd_putsxy(0, LCD_HEIGHT-8, buffer); |
309 | } | 343 | } |
310 | rb->lcd_update(); | 344 | rb->lcd_update(); |
345 | #else | ||
346 | rb->lcd_clear_display(); | ||
347 | if (t_disp>0) | ||
348 | { | ||
349 | t_disp--; | ||
350 | rb->snprintf(buffer, 30, "x%d y%d", xs, ys); | ||
351 | rb->lcd_puts(0, 0, buffer); | ||
352 | rb->snprintf(buffer, 30, "z%d h%d", zs, highspeed); | ||
353 | rb->lcd_puts(0, 1, buffer); | ||
354 | } | ||
355 | pgfx_display(3, 0); | ||
356 | #endif | ||
311 | 357 | ||
312 | xa+=xs; | 358 | xa+=xs; |
313 | if (xa>359) | 359 | if (xa>359) |
@@ -384,8 +430,11 @@ enum plugin_status plugin_start(struct plugin_api* api, void* parameter) | |||
384 | if (button!=BUTTON_NONE) | 430 | if (button!=BUTTON_NONE) |
385 | lastbutton=button; | 431 | lastbutton=button; |
386 | } | 432 | } |
433 | |||
434 | #ifdef HAVE_LCD_CHARCELLS | ||
435 | pgfx_release(); | ||
436 | #endif | ||
387 | 437 | ||
388 | return PLUGIN_OK; | 438 | return PLUGIN_OK; |
389 | } | 439 | } |
390 | 440 | ||
391 | #endif | ||