summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Gevaerts <frank@gevaerts.be>2015-02-22 12:22:40 +0100
committerFrank Gevaerts <frank@gevaerts.be>2015-02-22 12:22:40 +0100
commit272b5586397ebc4479b3ef247775723ddb8a5bd8 (patch)
tree2483abf0176fd3469e1a936bd8531a16f9de56ba
parentb84fd878d3fa7512d93e692f97723007df2939be (diff)
downloadrockbox-272b558.tar.gz
rockbox-272b558.tar.bz2
rockbox-272b558.zip
Lamp plugin: Allow toggling the button light using "select".
Change-Id: I0f276a74010ef463ebdb0eb0cc00fc50123966f0
-rw-r--r--apps/plugins/lamp.c19
-rw-r--r--apps/plugins/lib/helper.c6
-rw-r--r--apps/plugins/lib/helper.h1
-rw-r--r--manual/plugins/lamp.tex8
4 files changed, 34 insertions, 0 deletions
diff --git a/apps/plugins/lamp.c b/apps/plugins/lamp.c
index fa7027ece7..6c9ae6626d 100644
--- a/apps/plugins/lamp.c
+++ b/apps/plugins/lamp.c
@@ -45,6 +45,7 @@ static const struct button_mapping *plugin_contexts[] = { pla_main_ctx };
# define LAMP_DOWN PLA_SCROLL_BACK
# define LAMP_UP_REPEAT PLA_SCROLL_FWD_REPEAT
# define LAMP_DOWN_REPEAT PLA_SCROLL_BACK_REPEAT
+# define LAMP_TOGGLE_BUTTON PLA_SELECT
#else
# define LAMP_LEFT PLA_LEFT
# 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_UP_REPEAT PLA_UP_REPEAT
# define LAMP_DOWN_REPEAT PLA_DOWN_REPEAT
+# define LAMP_TOGGLE_BUTTON PLA_SELECT
#endif/* HAVE_SCROLLWHEEL */
@@ -87,6 +89,9 @@ enum plugin_status plugin_start(const void* parameter)
int cs = 0;
bool update = false;
#endif /* HAVE_LCD_COLOR */
+#ifdef HAVE_BUTTON_LIGHT
+ bool buttonlight_on = true;
+#endif /* HAVE_BUTTON_LIGHT */
#if LCD_DEPTH > 1
unsigned bg_color = rb->lcd_get_background();
@@ -169,6 +174,20 @@ enum plugin_status plugin_start(const void* parameter)
backlight_brightness_set(--current_brightness);
break;
#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_EXIT2:
quit = true;
diff --git a/apps/plugins/lib/helper.c b/apps/plugins/lib/helper.c
index 780d636f41..5aa143a728 100644
--- a/apps/plugins/lib/helper.c
+++ b/apps/plugins/lib/helper.c
@@ -106,6 +106,12 @@ void buttonlight_force_on(void)
rb->buttonlight_set_timeout(0);
}
+/* Force the buttonlight off */
+void buttonlight_force_off(void)
+{
+ rb->buttonlight_set_timeout(-1);
+}
+
/* Turn off backlight timeout */
void buttonlight_ignore_timeout(void)
{
diff --git a/apps/plugins/lib/helper.h b/apps/plugins/lib/helper.h
index 20f5ee285b..8086cb52d4 100644
--- a/apps/plugins/lib/helper.h
+++ b/apps/plugins/lib/helper.h
@@ -37,6 +37,7 @@ void remote_backlight_use_settings(void);
#ifdef HAVE_BUTTON_LIGHT
void buttonlight_force_on(void);
+void buttonlight_force_off(void);
void buttonlight_ignore_timeout(void);
void buttonlight_use_settings(void);
#endif
diff --git a/manual/plugins/lamp.tex b/manual/plugins/lamp.tex
index 73f48f12f8..643f1bb51f 100644
--- a/manual/plugins/lamp.tex
+++ b/manual/plugins/lamp.tex
@@ -20,6 +20,14 @@ You get an empty screen with maximum brightness.
Change the brightness
\\
}
+ \opt{HAVE_BUTTON_LIGHTS}{
+ \PluginSelect{}
+ &
+ \opt{HAVEREMOTEKEYMAP}{
+ & }
+ Toggle the button light
+ \\
+ }
\PluginCancel{} or \PluginExit
& Exit to menu\\
\end{btnmap}