2005-02-15 08:03:56 +00:00
|
|
|
|
/***************************************************************************
|
|
|
|
|
* __________ __ ___.
|
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
|
* $Id$
|
|
|
|
|
*
|
2006-03-27 17:34:23 +00:00
|
|
|
|
* Copyright (C) 2005 Jonas H<EFBFBD>gqvist
|
2005-02-15 08:03:56 +00:00
|
|
|
|
*
|
2008-06-28 18:10:04 +00:00
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
|
* of the License, or (at your option) any later version.
|
2005-02-15 08:03:56 +00:00
|
|
|
|
*
|
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
|
* KIND, either express or implied.
|
|
|
|
|
*
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
#include "plugin.h"
|
2008-11-20 11:27:31 +00:00
|
|
|
|
#include "lib/playergfx.h"
|
2012-02-25 20:29:01 +00:00
|
|
|
|
#include "lib/pluginlib_actions.h"
|
2005-02-15 08:03:56 +00:00
|
|
|
|
|
2012-02-25 20:29:01 +00:00
|
|
|
|
/* this set the context to use with PLA */
|
|
|
|
|
static const struct button_mapping *plugin_contexts[]
|
|
|
|
|
= { pla_main_ctx,
|
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
|
pla_remote_ctx,
|
|
|
|
|
#endif
|
|
|
|
|
};
|
2006-01-15 18:20:18 +00:00
|
|
|
|
|
2005-03-05 22:45:04 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
|
|
|
|
#define DISPLAY_WIDTH LCD_WIDTH
|
|
|
|
|
#define DISPLAY_HEIGHT LCD_HEIGHT
|
|
|
|
|
#define RAND_SCALE 5
|
2005-02-15 08:03:56 +00:00
|
|
|
|
|
2005-05-23 16:23:25 +00:00
|
|
|
|
#ifdef HAVE_REMOTE_LCD
|
|
|
|
|
#define REMOTE_WIDTH LCD_REMOTE_WIDTH
|
|
|
|
|
#define REMOTE_HEIGHT LCD_REMOTE_HEIGHT
|
2008-11-03 14:37:50 +00:00
|
|
|
|
#include "pluginbitmaps/remote_rockboxlogo.h"
|
2008-01-31 21:05:32 +00:00
|
|
|
|
#define REMOTE_LOGO_WIDTH BMPWIDTH_remote_rockboxlogo
|
|
|
|
|
#define REMOTE_LOGO_HEIGHT BMPHEIGHT_remote_rockboxlogo
|
2008-01-31 19:28:51 +00:00
|
|
|
|
#define REMOTE_LOGO remote_rockboxlogo
|
2005-06-30 21:07:00 +00:00
|
|
|
|
#endif /* HAVE_REMOTE_LCD */
|
2005-05-16 12:07:30 +00:00
|
|
|
|
|
2008-01-31 19:28:51 +00:00
|
|
|
|
#define LOGO rockboxlogo
|
2008-11-03 14:37:50 +00:00
|
|
|
|
#include "pluginbitmaps/rockboxlogo.h"
|
2008-01-31 21:05:32 +00:00
|
|
|
|
#define LOGO_WIDTH BMPWIDTH_rockboxlogo
|
|
|
|
|
#define LOGO_HEIGHT BMPHEIGHT_rockboxlogo
|
2005-03-05 22:45:04 +00:00
|
|
|
|
|
|
|
|
|
#else /* !LCD_BITMAP */
|
|
|
|
|
#define DISPLAY_WIDTH 55
|
|
|
|
|
#define DISPLAY_HEIGHT 14
|
|
|
|
|
#define RAND_SCALE 2
|
|
|
|
|
#define LOGO_WIDTH 16
|
|
|
|
|
#define LOGO_HEIGHT 7
|
|
|
|
|
#define LOGO rockbox16x7
|
|
|
|
|
const unsigned char rockbox16x7[] = {
|
2005-06-30 21:07:00 +00:00
|
|
|
|
0x47, 0x18, 0xa6, 0xd8, 0x66, 0xde, 0xb7, 0x9b,
|
|
|
|
|
0x76, 0xdb, 0x26, 0xdb, 0x66, 0xde,
|
2005-03-05 22:45:04 +00:00
|
|
|
|
};
|
|
|
|
|
#endif /* !LCD_BITMAP */
|
|
|
|
|
|
2012-02-25 20:29:01 +00:00
|
|
|
|
/* We use PLA */
|
|
|
|
|
#define LP_QUIT PLA_EXIT
|
|
|
|
|
#define LP_QUIT2 PLA_CANCEL
|
|
|
|
|
#define LP_DEC_X PLA_LEFT
|
|
|
|
|
#define LP_DEC_X_REPEAT PLA_LEFT_REPEAT
|
|
|
|
|
#define LP_INC_X PLA_RIGHT
|
|
|
|
|
#define LP_INC_X_REPEAT PLA_RIGHT_REPEAT
|
|
|
|
|
#define LP_DEC_Y PLA_DOWN
|
|
|
|
|
#define LP_DEC_Y_REPEAT PLA_DOWN_REPEAT
|
|
|
|
|
#define LP_INC_Y PLA_UP
|
|
|
|
|
#define LP_INC_Y_REPEAT PLA_UP_REPEAT
|
2005-02-15 08:03:56 +00:00
|
|
|
|
|
2009-01-16 10:34:40 +00:00
|
|
|
|
enum plugin_status plugin_start(const void* parameter) {
|
2005-02-15 08:03:56 +00:00
|
|
|
|
int button;
|
|
|
|
|
int timer = 10;
|
2005-03-05 22:45:04 +00:00
|
|
|
|
int x = (DISPLAY_WIDTH / 2) - (LOGO_WIDTH / 2);
|
|
|
|
|
int y = (DISPLAY_HEIGHT / 2) - (LOGO_HEIGHT / 2);
|
2005-02-15 09:27:23 +00:00
|
|
|
|
int dx;
|
|
|
|
|
int dy;
|
2005-03-05 22:45:04 +00:00
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
|
int cpos = -1;
|
|
|
|
|
int old_cpos = -1;
|
|
|
|
|
#endif
|
2005-02-15 09:27:23 +00:00
|
|
|
|
|
2005-02-15 08:03:56 +00:00
|
|
|
|
(void)parameter;
|
2005-02-15 09:27:23 +00:00
|
|
|
|
|
2005-03-05 22:45:04 +00:00
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
2009-01-16 10:34:40 +00:00
|
|
|
|
if (!pgfx_init(4, 2)) {
|
2007-03-16 21:56:08 +00:00
|
|
|
|
rb->splash(HZ*2, "Old LCD :(");
|
2005-03-05 22:45:04 +00:00
|
|
|
|
return PLUGIN_OK;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
rb->srand(*rb->current_tick);
|
|
|
|
|
dx = rb->rand()%(2*RAND_SCALE+1) - RAND_SCALE;
|
|
|
|
|
dy = rb->rand()%(2*RAND_SCALE+1) - RAND_SCALE;
|
2005-02-15 08:03:56 +00:00
|
|
|
|
|
|
|
|
|
while (1) {
|
2005-03-05 22:45:04 +00:00
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2005-02-15 08:03:56 +00:00
|
|
|
|
rb->lcd_clear_display();
|
2014-06-18 05:15:00 +00:00
|
|
|
|
rb->lcd_bitmap((const fb_data*)LOGO, x, y, LOGO_WIDTH, LOGO_HEIGHT);
|
2005-05-16 12:07:30 +00:00
|
|
|
|
#ifdef REMOTE_LOGO
|
2005-06-29 01:39:50 +00:00
|
|
|
|
rb->lcd_remote_clear_display();
|
2014-06-20 22:49:05 +00:00
|
|
|
|
rb->lcd_remote_bitmap((const fb_remote_data*)REMOTE_LOGO,
|
2005-05-16 12:07:30 +00:00
|
|
|
|
(x * (REMOTE_WIDTH - REMOTE_LOGO_WIDTH)) / (DISPLAY_WIDTH - LOGO_WIDTH),
|
|
|
|
|
(y * (REMOTE_HEIGHT - REMOTE_LOGO_HEIGHT)) / (DISPLAY_HEIGHT - LOGO_HEIGHT),
|
2005-06-29 01:39:50 +00:00
|
|
|
|
REMOTE_LOGO_WIDTH, REMOTE_LOGO_HEIGHT);
|
2005-05-16 12:07:30 +00:00
|
|
|
|
#endif
|
2005-03-05 22:45:04 +00:00
|
|
|
|
#else
|
|
|
|
|
pgfx_clear_display();
|
2005-07-07 00:05:29 +00:00
|
|
|
|
pgfx_mono_bitmap(LOGO, x % 5, y, LOGO_WIDTH, LOGO_HEIGHT);
|
2005-03-05 22:45:04 +00:00
|
|
|
|
cpos = x / 5;
|
|
|
|
|
#endif
|
2005-02-15 08:03:56 +00:00
|
|
|
|
|
|
|
|
|
x += dx;
|
|
|
|
|
if (x < 0) {
|
|
|
|
|
dx = -dx;
|
|
|
|
|
x = 0;
|
|
|
|
|
}
|
2005-03-05 22:45:04 +00:00
|
|
|
|
if (x > DISPLAY_WIDTH - LOGO_WIDTH) {
|
2005-02-15 08:03:56 +00:00
|
|
|
|
dx = -dx;
|
2005-03-05 22:45:04 +00:00
|
|
|
|
x = DISPLAY_WIDTH - LOGO_WIDTH;
|
2005-02-15 08:03:56 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
y += dy;
|
|
|
|
|
if (y < 0) {
|
|
|
|
|
dy = -dy;
|
|
|
|
|
y = 0;
|
|
|
|
|
}
|
2005-03-05 22:45:04 +00:00
|
|
|
|
if (y > DISPLAY_HEIGHT - LOGO_HEIGHT) {
|
2005-02-15 08:03:56 +00:00
|
|
|
|
dy = -dy;
|
2005-03-05 22:45:04 +00:00
|
|
|
|
y = DISPLAY_HEIGHT - LOGO_HEIGHT;
|
2005-02-15 08:03:56 +00:00
|
|
|
|
}
|
2005-03-05 22:45:04 +00:00
|
|
|
|
|
|
|
|
|
#ifdef HAVE_LCD_BITMAP
|
2005-02-15 08:03:56 +00:00
|
|
|
|
rb->lcd_update();
|
2005-05-16 12:07:30 +00:00
|
|
|
|
#ifdef REMOTE_LOGO
|
2005-06-29 01:39:50 +00:00
|
|
|
|
rb->lcd_remote_update();
|
2005-05-16 12:07:30 +00:00
|
|
|
|
#endif
|
2005-03-05 22:45:04 +00:00
|
|
|
|
#else
|
|
|
|
|
if (cpos != old_cpos) {
|
|
|
|
|
rb->lcd_clear_display();
|
|
|
|
|
pgfx_display(cpos, 0);
|
|
|
|
|
old_cpos = cpos;
|
|
|
|
|
}
|
2007-04-06 22:55:00 +00:00
|
|
|
|
pgfx_update();
|
2005-03-05 22:45:04 +00:00
|
|
|
|
#endif
|
2005-02-15 08:03:56 +00:00
|
|
|
|
rb->sleep(HZ/timer);
|
2012-02-25 20:29:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*We get button from PLA this way */
|
|
|
|
|
button = pluginlib_getaction(TIMEOUT_NOBLOCK, plugin_contexts,
|
|
|
|
|
ARRAYLEN(plugin_contexts));
|
|
|
|
|
|
2005-02-15 08:03:56 +00:00
|
|
|
|
switch (button) {
|
2005-03-05 22:45:04 +00:00
|
|
|
|
case LP_QUIT:
|
2012-02-25 20:29:01 +00:00
|
|
|
|
case LP_QUIT2:
|
2005-03-05 22:45:04 +00:00
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
|
pgfx_release();
|
|
|
|
|
#endif
|
2005-02-15 08:03:56 +00:00
|
|
|
|
return PLUGIN_OK;
|
2005-03-05 22:45:04 +00:00
|
|
|
|
case LP_DEC_X:
|
2012-02-25 20:29:01 +00:00
|
|
|
|
case LP_DEC_X_REPEAT:
|
2005-03-05 22:45:04 +00:00
|
|
|
|
if (dx)
|
|
|
|
|
dx += (dx < 0) ? 1 : -1;
|
2005-02-15 08:03:56 +00:00
|
|
|
|
break;
|
2005-03-05 22:45:04 +00:00
|
|
|
|
case LP_INC_X:
|
2012-02-25 20:29:01 +00:00
|
|
|
|
case LP_INC_X_REPEAT:
|
2005-03-05 22:45:04 +00:00
|
|
|
|
dx += (dx < 0) ? -1 : 1;
|
2005-02-15 08:03:56 +00:00
|
|
|
|
break;
|
2005-03-05 22:45:04 +00:00
|
|
|
|
case LP_DEC_Y:
|
2012-02-25 20:29:01 +00:00
|
|
|
|
case LP_DEC_Y_REPEAT:
|
2005-03-05 22:45:04 +00:00
|
|
|
|
if (dy)
|
|
|
|
|
dy += (dy < 0) ? 1 : -1;
|
2005-02-15 08:03:56 +00:00
|
|
|
|
break;
|
2005-03-05 22:45:04 +00:00
|
|
|
|
case LP_INC_Y:
|
2012-02-25 20:29:01 +00:00
|
|
|
|
case LP_INC_Y_REPEAT:
|
2005-03-05 22:45:04 +00:00
|
|
|
|
dy += (dy < 0) ? -1 : 1;
|
2005-02-15 08:03:56 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
2005-03-05 22:45:04 +00:00
|
|
|
|
if (rb->default_event_handler(button) == SYS_USB_CONNECTED) {
|
|
|
|
|
#ifdef HAVE_LCD_CHARCELLS
|
|
|
|
|
pgfx_release();
|
|
|
|
|
#endif
|
|
|
|
|
return PLUGIN_USB_CONNECTED;
|
|
|
|
|
}
|
2005-02-15 08:03:56 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|