Lamp plugin: Allow toggling the button light using "select".

Change-Id: I0f276a74010ef463ebdb0eb0cc00fc50123966f0
This commit is contained in:
Frank Gevaerts 2015-02-22 12:22:40 +01:00
parent b84fd878d3
commit 272b558639
4 changed files with 34 additions and 0 deletions

View file

@ -45,6 +45,7 @@ static const struct button_mapping *plugin_contexts[] = { pla_main_ctx };
# define LAMP_DOWN PLA_SCROLL_BACK # define LAMP_DOWN PLA_SCROLL_BACK
# define LAMP_UP_REPEAT PLA_SCROLL_FWD_REPEAT # define LAMP_UP_REPEAT PLA_SCROLL_FWD_REPEAT
# define LAMP_DOWN_REPEAT PLA_SCROLL_BACK_REPEAT # define LAMP_DOWN_REPEAT PLA_SCROLL_BACK_REPEAT
# define LAMP_TOGGLE_BUTTON PLA_SELECT
#else #else
# define LAMP_LEFT PLA_LEFT # define LAMP_LEFT PLA_LEFT
# define LAMP_RIGHT PLA_RIGHT # define LAMP_RIGHT PLA_RIGHT
@ -52,6 +53,7 @@ static const struct button_mapping *plugin_contexts[] = { pla_main_ctx };
# define LAMP_DOWN PLA_DOWN # define LAMP_DOWN PLA_DOWN
# define LAMP_UP_REPEAT PLA_UP_REPEAT # define LAMP_UP_REPEAT PLA_UP_REPEAT
# define LAMP_DOWN_REPEAT PLA_DOWN_REPEAT # define LAMP_DOWN_REPEAT PLA_DOWN_REPEAT
# define LAMP_TOGGLE_BUTTON PLA_SELECT
#endif/* HAVE_SCROLLWHEEL */ #endif/* HAVE_SCROLLWHEEL */
@ -87,6 +89,9 @@ enum plugin_status plugin_start(const void* parameter)
int cs = 0; int cs = 0;
bool update = false; bool update = false;
#endif /* HAVE_LCD_COLOR */ #endif /* HAVE_LCD_COLOR */
#ifdef HAVE_BUTTON_LIGHT
bool buttonlight_on = true;
#endif /* HAVE_BUTTON_LIGHT */
#if LCD_DEPTH > 1 #if LCD_DEPTH > 1
unsigned bg_color = rb->lcd_get_background(); unsigned bg_color = rb->lcd_get_background();
@ -169,6 +174,20 @@ enum plugin_status plugin_start(const void* parameter)
backlight_brightness_set(--current_brightness); backlight_brightness_set(--current_brightness);
break; break;
#endif /* HAVE_BACKLIGHT_BRIGHTNESS */ #endif /* HAVE_BACKLIGHT_BRIGHTNESS */
#ifdef HAVE_BUTTON_LIGHT
case LAMP_TOGGLE_BUTTON:
if(buttonlight_on)
{
buttonlight_force_off();
buttonlight_on = false;
}
else
{
buttonlight_force_on();
buttonlight_on = true;
}
break;
#endif /* HAVE_BUTTON_LIGHT */
case LAMP_EXIT: case LAMP_EXIT:
case LAMP_EXIT2: case LAMP_EXIT2:
quit = true; quit = true;

View file

@ -106,6 +106,12 @@ void buttonlight_force_on(void)
rb->buttonlight_set_timeout(0); rb->buttonlight_set_timeout(0);
} }
/* Force the buttonlight off */
void buttonlight_force_off(void)
{
rb->buttonlight_set_timeout(-1);
}
/* Turn off backlight timeout */ /* Turn off backlight timeout */
void buttonlight_ignore_timeout(void) void buttonlight_ignore_timeout(void)
{ {

View file

@ -37,6 +37,7 @@ void remote_backlight_use_settings(void);
#ifdef HAVE_BUTTON_LIGHT #ifdef HAVE_BUTTON_LIGHT
void buttonlight_force_on(void); void buttonlight_force_on(void);
void buttonlight_force_off(void);
void buttonlight_ignore_timeout(void); void buttonlight_ignore_timeout(void);
void buttonlight_use_settings(void); void buttonlight_use_settings(void);
#endif #endif

View file

@ -19,6 +19,14 @@ You get an empty screen with maximum brightness.
& } & }
Change the brightness Change the brightness
\\ \\
}
\opt{HAVE_BUTTON_LIGHTS}{
\PluginSelect{}
&
\opt{HAVEREMOTEKEYMAP}{
& }
Toggle the button light
\\
} }
\PluginCancel{} or \PluginExit \PluginCancel{} or \PluginExit
& Exit to menu\\ & Exit to menu\\