lamp plugin:

-handles sys_events.
-disable idle poweroff (part of FS#11578 by Hayden Pearce.)
-correct button table in the manual.

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28429 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Teruaki Kawashima 2010-11-01 13:37:00 +00:00
parent d055ff4a94
commit f2dbbf45de
4 changed files with 78 additions and 59 deletions

View file

@ -123,40 +123,36 @@
#ifdef HAVE_LCD_COLOR
/* RGB color sets */
#define NUM_COLORSETS 2
static int colorset[NUM_COLORSETS][3] = { { 255, 255, 255 } , /* white */
{ 255, 0, 0 } }; /* red */
static unsigned colorset[NUM_COLORSETS] = {
LCD_RGBPACK(255, 255, 255), /* white */
LCD_RGBPACK(255, 0, 0), /* red */
};
#endif /* HAVE_LCD_COLOR */
/* this is the plugin entry point */
enum plugin_status plugin_start(const void* parameter)
{
enum plugin_status status = PLUGIN_OK;
long button;
(void)parameter;
#ifdef HAVE_LCD_COLOR
int cs = 0;
bool quit = false;
bool update = true;
#endif /* HAVE_LCD_COLOR */
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
short old_brightness = rb->global_settings->brightness;
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
short old_buttonlight_brightness =
rb->global_settings->buttonlight_brightness;
#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
#if LCD_DEPTH > 1
unsigned bg_color=rb->lcd_get_background();
unsigned bg_color = rb->lcd_get_background();
rb->lcd_set_backdrop(NULL);
rb->lcd_set_background(LCD_WHITE);
#endif
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
rb->backlight_set_brightness(MAX_BRIGHTNESS_SETTING);
backlight_brightness_set(MAX_BRIGHTNESS_SETTING);
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
rb->buttonlight_set_brightness(MAX_BRIGHTNESS_SETTING);
buttonlight_brightness_set(MAX_BRIGHTNESS_SETTING);
#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
#ifdef HAVE_LCD_INVERT
@ -175,23 +171,26 @@ enum plugin_status plugin_start(const void* parameter)
#ifdef HAVE_LCD_COLOR
do
{
if(cs < 0)
cs = NUM_COLORSETS-1;
if(cs >= NUM_COLORSETS)
cs = 0;
rb->lcd_set_background( LCD_RGBPACK( colorset[cs][0],
colorset[cs][1],
colorset[cs][2] ) );
rb->lcd_clear_display();
rb->lcd_update();
if(update)
{
if(cs < 0)
cs = NUM_COLORSETS-1;
if(cs >= NUM_COLORSETS)
cs = 0;
rb->lcd_set_background(colorset[cs]);
rb->lcd_clear_display();
rb->lcd_update();
update = false;
}
switch((button = rb->button_get(true)))
switch((button = rb->button_get_w_tmo(HZ*30)))
{
case LAMP_RIGHT:
#ifdef LAMP_NEXT
case LAMP_NEXT:
#endif /* LAMP_NEXT */
cs++;
update = true;
break;
case LAMP_LEFT:
@ -199,25 +198,24 @@ enum plugin_status plugin_start(const void* parameter)
case LAMP_PREV:
#endif /* LAMP_PREV */
cs--;
update = true;
break;
case (LAMP_RIGHT|BUTTON_REPEAT):
case (LAMP_RIGHT|BUTTON_REL):
case (LAMP_LEFT|BUTTON_REPEAT):
case (LAMP_LEFT|BUTTON_REL):
#ifdef LAMP_NEXT
case (LAMP_NEXT|BUTTON_REPEAT):
case (LAMP_NEXT|BUTTON_REL):
#endif /* LAMP_NEXT */
#ifdef LAMP_PREV
case (LAMP_PREV|BUTTON_REPEAT):
case (LAMP_PREV|BUTTON_REL):
#endif /* LAMP_PREV */
/* eat these... */
break;
default:
quit = true;
if(button)
{
if(rb->default_event_handler(button) == SYS_USB_CONNECTED)
{
status = PLUGIN_USB_CONNECTED;
quit = true;
}
if(!(button & (BUTTON_REL|BUTTON_REPEAT))
&& !IS_SYSEVENT(button))
quit = true;
}
break;
}
rb->reset_poweroff_timer();
} while (!quit);
#else /* HAVE_LCD_COLOR */
@ -226,10 +224,18 @@ enum plugin_status plugin_start(const void* parameter)
/* wait */
do
{
button = rb->button_get(false);
if (button && !IS_SYSEVENT(button))
break;
rb->yield();
button = rb->button_get_w_tmo(HZ*30);
if(button)
{
if(rb->default_event_handler(button) == SYS_USB_CONNECTED)
{
status = PLUGIN_USB_CONNECTED;
break;
}
if(!IS_SYSEVENT(button))
break;
}
rb->reset_poweroff_timer();
} while (1);
#endif /*HAVE_LCD_COLOR */
@ -245,15 +251,14 @@ enum plugin_status plugin_start(const void* parameter)
#endif /* HAVE_LCD_INVERT */
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
rb->backlight_set_brightness(old_brightness);
backlight_brightness_use_setting();
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
rb->buttonlight_set_brightness(old_buttonlight_brightness);
buttonlight_brightness_use_setting();
#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
#if LCD_DEPTH > 1
rb->lcd_set_background(bg_color);
#endif
return PLUGIN_OK;
return status;
}

View file

@ -107,3 +107,15 @@ void backlight_brightness_use_setting(void)
rb->backlight_set_brightness(rb->global_settings->brightness);
}
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
void buttonlight_brightness_set(int brightness)
{
rb->buttonlight_set_brightness(brightness);
}
void buttonlight_brightness_use_setting(void)
{
rb->buttonlight_set_brightness(rb->global_settings->buttonlight_brightness);
}
#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */

View file

@ -32,6 +32,7 @@ void backlight_use_settings(void);
void remote_backlight_force_on(void);
void remote_backlight_use_settings(void);
#endif
#ifdef HAVE_BUTTON_LIGHT
void buttonlight_force_on(void);
void buttonlight_use_settings(void);
@ -45,5 +46,9 @@ void backlight_brightness_set(int brightness);
void backlight_brightness_use_setting(void);
#endif
#ifdef HAVE_BUTTONLIGHT_BRIGHTNESS
void buttonlight_brightness_set(int brightness);
void buttonlight_brightness_use_setting(void);
#endif /* HAVE_BUTTONLIGHT_BRIGHTNESS */
#endif /* _LIB_HELPER_H_ */

View file

@ -3,24 +3,21 @@
Lamp is a simple plugin to use your player as a lamp (flashlight, torch).
You get an empty screen with maximum brightness.
\begin{btnmap}
\opt{lcd_color}{
\opt{lcd_color}{
\opt{PLAYER_PAD,RECORDER_PAD,ONDIO_PAD,IRIVER_H100_PAD,IRIVER_H300_PAD%
,IPOD_4G_PAD,IPOD_3G_PAD,IRIVER_H10_PAD,IAUDIO_X5_PAD,SANSA_E200_PAD%
,SANSA_C200_PAD,GIGABEAT_PAD,MROBE100_PAD,SANSA_FUZE_PAD,PBELL_VIBE500_PAD}
{\ButtonLeft/\ButtonRight}
\opt{COWON_D2_PAD}{\TouchMidLeft{} / \TouchMidRight}
\opt{HAVEREMOTEKEYMAP}{& }
\opt{HAVEREMOTEKEYMAP}{& }
& Toggle between colours\\
}
\opt{PLAYER_PAD}{\ButtonMenu}
\opt{RECORDER_PAD,ONDIO_PAD,IRIVER_H100_PAD,IRIVER_H300_PAD}{\ButtonOff}
\opt{IPOD_4G_PAD,IPOD_3G_PAD}{Long \ButtonPlay}
\opt{IRIVER_H10_PAD,IAUDIO_X5_PAD,SANSA_E200_PAD,SANSA_C200_PAD,GIGABEAT_PAD,MROBE100_PAD}{\ButtonPower}
\opt{SANSA_FUZE_PAD}{\ButtonHome}
\opt{COWON_D2_PAD}{\ButtonPower}
\opt{PBELL_VIBE500_PAD}{\ButtonRec}
\opt{HAVEREMOTEKEYMAP}{&
\opt{IRIVER_RC_H100_PAD}{\ButtonRCStop}
}
Any ohter key
\opt{HAVEREMOTEKEYMAP}{& }
& Quit\\
}
\nopt{lcd_color}{
Any key
\opt{HAVEREMOTEKEYMAP}{& }
& Quit\\
}
\end{btnmap}