Index: apps/action.c
===================================================================
--- apps/action.c (Revision 20281)
+++ apps/action.c (Arbeitskopie)
@@ -89,6 +89,36 @@
CONTEXT_STD :
items[i].action_code;
}
+
+static bool backlight_on_action(int action)
+{
+ /* no backlight on volume change and pause/play */
+ return (action != ACTION_WPS_VOLUP)
+ && (action != ACTION_WPS_VOLDOWN)
+ && (action != ACTION_WPS_PLAY);
+}
+
+static bool backlight_on_keypress_oracle(int btn)
+{
+ /* check whether the button would fire an action */
+ /* If yes, check whether that action should turn on the backlight */
+ /* Keep this function fast! It's called from the button ticktask */
+ /* or the scrollwheel interrupt handler! */
+
+ const struct button_mapping *items = NULL;
+ int i = 0;
+
+ if (!global_settings.backlight_on_volume_change)
+ {
+ items = get_context_mapping(CONTEXT_WPS);
+ /* also check action for button release */
+ return backlight_on_action(do_button_check(items, btn, BUTTON_NONE, &i))
+ && backlight_on_action(do_button_check(items, btn | BUTTON_REL, btn, &i));
+ }
+ else
+ return true;
+}
+
/*
* int get_action_worker(int context, struct button_mapping *user_mappings,
int timeout)
@@ -116,6 +146,14 @@
send_event(GUI_EVENT_ACTIONUPDATE, NULL);
+ /* In CONTEXT_WPS we may want to keep the backlight off on certain actions. */
+ /* Thus, a callback function is used to check if it should turn on. */
+ /* See also button.c */
+ if (context == CONTEXT_WPS)
+ set_backlight_on_keypress_oracle(backlight_on_keypress_oracle);
+ else
+ set_backlight_on_keypress_oracle(NULL);
+
if (timeout == TIMEOUT_NOBLOCK)
button = button_get(false);
else if (timeout == TIMEOUT_BLOCK)
Index: apps/lang/deutsch.lang
===================================================================
--- apps/lang/deutsch.lang (Revision 20281)
+++ apps/lang/deutsch.lang (Arbeitskopie)
@@ -2742,6 +2742,20 @@
+ id: LANG_BACKLIGHT_ON_VOLUME_CHANGE
+ desc: Backlight on volume change and on pause/play
+ user: core
+
+ *: "Backlight On Volume Change"
+
+
+ *: "Beleuchtung bei Änderung der Lautstärke"
+
+
+ *: "Beleuchtung bei Änderung der Lautstärke"
+
+
+
id: LANG_LCD_SLEEP_AFTER_BACKLIGHT_OFF
desc: In display settings, time to switch LCD chip into power saving state
user: core
Index: apps/lang/english.lang
===================================================================
--- apps/lang/english.lang (Revision 20281)
+++ apps/lang/english.lang (Arbeitskopie)
@@ -2814,6 +2814,20 @@
+ id: LANG_BACKLIGHT_ON_VOLUME_CHANGE
+ desc: Backlight on volume change and on pause/play
+ user: core
+
+ *: "Backlight on Volume Change"
+
+
+ *: "Backlight on Volume Change"
+
+
+ *: "Backlight on Volume Change"
+
+
+
id: LANG_LCD_SLEEP_AFTER_BACKLIGHT_OFF
desc: In display settings, time to switch LCD chip into power saving state
user: core
Index: apps/settings.h
===================================================================
--- apps/settings.h (Revision 20281)
+++ apps/settings.h (Arbeitskopie)
@@ -653,6 +653,8 @@
then according to timeout_values[] */
bool caption_backlight; /* turn on backlight at end and start of track */
bool bl_filter_first_keypress; /* filter first keypress when dark? */
+ bool backlight_on_volume_change; /* turn on the backlight on volume change
+ and on pause/play? */
#if CONFIG_CHARGING
int backlight_timeout_plugged;
#endif
Index: apps/menus/display_menu.c
===================================================================
--- apps/menus/display_menu.c (Revision 20281)
+++ apps/menus/display_menu.c (Arbeitskopie)
@@ -97,6 +97,9 @@
MENUITEM_SETTING(bl_filter_first_keypress,
&global_settings.bl_filter_first_keypress,
filterfirstkeypress_callback);
+MENUITEM_SETTING(backlight_on_volume_change,
+ &global_settings.backlight_on_volume_change,
+ NULL);
#ifdef HAVE_LCD_SLEEP_SETTING
MENUITEM_SETTING(lcd_sleep_after_backlight_off,
&global_settings.lcd_sleep_after_backlight_off, NULL);
@@ -134,6 +137,7 @@
,&backlight_fade_in, &backlight_fade_out
#endif
,&bl_filter_first_keypress
+ ,&backlight_on_volume_change
# ifdef HAVE_LCD_SLEEP_SETTING
,&lcd_sleep_after_backlight_off
# endif
Index: apps/settings_list.c
===================================================================
--- apps/settings_list.c (Revision 20281)
+++ apps/settings_list.c (Arbeitskopie)
@@ -655,6 +655,9 @@
OFFON_SETTING(0, bl_filter_first_keypress,
LANG_BACKLIGHT_FILTER_FIRST_KEYPRESS, false,
"backlight filters first keypress", NULL),
+ OFFON_SETTING(0, backlight_on_volume_change,
+ LANG_BACKLIGHT_ON_VOLUME_CHANGE, true,
+ "backlight on volume change", NULL),
#ifdef HAVE_REMOTE_LCD
OFFON_SETTING(0, remote_bl_filter_first_keypress,
LANG_BACKLIGHT_FILTER_FIRST_KEYPRESS, false,
Index: firmware/export/button.h
===================================================================
--- firmware/export/button.h (Revision 20281)
+++ firmware/export/button.h (Arbeitskopie)
@@ -43,6 +43,23 @@
#endif
#ifdef HAVE_BACKLIGHT
void set_backlight_filter_keypress(bool value);
+
+/* Callback function to tell whether the backlight should be turned on
+ * when a key is pressed. Called just after a key press.
+ *
+ * @param btn The button that was pressed
+ *
+ * Returns true iff the backlight should be turned on on key press.
+ */
+typedef bool (*backlight_on_keypress_oracle_func)(int btn);
+
+/* Sets the new 'oracle' to tell whether the backlight should be turned
+ * on when a key is pressed. Passing NULL as parameter will turn on the BL
+ * on every key press.
+ */
+void set_backlight_on_keypress_oracle(backlight_on_keypress_oracle_func func);
+void backlight_on_by_button(int btn);
+
#ifdef HAVE_REMOTE_LCD
void set_remote_backlight_filter_keypress(bool value);
#endif
Index: firmware/target/arm/ipod/button-clickwheel.c
===================================================================
--- firmware/target/arm/ipod/button-clickwheel.c (Revision 20281)
+++ firmware/target/arm/ipod/button-clickwheel.c (Arbeitskopie)
@@ -118,8 +118,7 @@
new_wheel_value = (status >> 16) & 0x7f;
whl = new_wheel_value;
- /* switch on backlight (again), reset power-off timer */
- backlight_on();
+ /* reset power-off timer */
reset_poweroff_timer();
/* Check whether the scrollwheel was untouched by accident or by will. */
@@ -162,6 +161,9 @@
if (wheel_keycode != BUTTON_NONE)
{
+ /* switch on backlight (again) */
+ backlight_on_by_button(wheel_keycode);
+
long v = (usec - last_wheel_usec) & 0x7fffffff;
/* undo signedness */
Index: firmware/target/arm/ipod/button-1g-3g.c
===================================================================
--- firmware/target/arm/ipod/button-1g-3g.c (Revision 20281)
+++ firmware/target/arm/ipod/button-1g-3g.c (Arbeitskopie)
@@ -72,7 +72,6 @@
count = 0;
}
else if (!was_hold) {
- backlight_on();
reset_poweroff_timer();
if (++count == 6) { /* reduce sensitivity */
count = 0;
@@ -90,6 +89,8 @@
break;
}
}
+ if (wheel_keycode != BUTTON_NONE)
+ backlight_on_by_button(wheel_keycode);
}
if (wheel_keycode != BUTTON_NONE && queue_empty(&button_queue))
queue_post(&button_queue, wheel_keycode, 0);
Index: firmware/target/arm/ipod/button-mini1g.c
===================================================================
--- firmware/target/arm/ipod/button-mini1g.c (Revision 20281)
+++ firmware/target/arm/ipod/button-mini1g.c (Arbeitskopie)
@@ -70,7 +70,6 @@
count = 0;
}
else if (!was_hold) {
- backlight_on();
reset_poweroff_timer();
if (++count == 6) { /* reduce sensitivity */
count = 0;
@@ -88,6 +87,8 @@
break;
}
}
+ if (wheel_keycode != BUTTON_NONE)
+ backlight_on_by_button(wheel_keycode);
}
if (wheel_keycode != BUTTON_NONE && queue_empty(&button_queue))
queue_post(&button_queue, wheel_keycode, 0);
Index: firmware/target/arm/sandisk/sansa-e200/button-e200.c
===================================================================
--- firmware/target/arm/sandisk/sansa-e200/button-e200.c (Revision 20281)
+++ firmware/target/arm/sandisk/sansa-e200/button-e200.c (Arbeitskopie)
@@ -188,19 +188,18 @@
wheel_delta = 1;
}
- if (TIME_AFTER(current_tick, next_backlight_on) ||
- v <= 4)
- {
- /* poke backlight to turn it on or maintain it no more often
- than every 1/4 second*/
- next_backlight_on = current_tick + HZ/4;
- backlight_on();
- buttonlight_on();
- reset_poweroff_timer();
- }
-
if (btn != BUTTON_NONE)
{
+ if (TIME_AFTER(current_tick, next_backlight_on) ||
+ v <= 4)
+ {
+ /* poke backlight to turn it on or maintain it no more often
+ than every 1/4 second*/
+ next_backlight_on = current_tick + HZ/4;
+ backlight_on_by_button(btn);
+ reset_poweroff_timer();
+ }
+
wheel_click_count = 0;
/* generate repeats if quick enough */
Index: firmware/drivers/button.c
===================================================================
--- firmware/drivers/button.c (Revision 20281)
+++ firmware/drivers/button.c (Arbeitskopie)
@@ -34,6 +34,7 @@
#include "power.h"
#include "powermgmt.h"
#include "button-target.h"
+#include "debug.h"
#ifdef HAVE_REMOTE_LCD
#include "lcd-remote.h"
@@ -58,6 +59,7 @@
#endif
#ifdef HAVE_BACKLIGHT
static bool filter_first_keypress;
+static backlight_on_keypress_oracle_func backlight_on_keypress_oracle = NULL;
#ifdef HAVE_REMOTE_LCD
static bool remote_filter_first_keypress;
#endif
@@ -95,6 +97,28 @@
}
#endif
+void backlight_on_by_button(int btn)
+{
+ bool bl_on;
+ if (backlight_on_keypress_oracle != NULL)
+ {
+ bl_on = (*backlight_on_keypress_oracle)(btn);
+ DEBUGF("BL oracle (%d) returned: %d\n", btn, bl_on);
+ }
+ else
+ {
+ bl_on = true;
+ DEBUGF("BL callback is NULL -> bl ON\n");
+ }
+ if (bl_on)
+ {
+ backlight_on();
+#ifdef HAVE_BUTTON_LIGHT
+ buttonlight_on();
+#endif
+ }
+}
+
static void button_tick(void)
{
static int count = 0;
@@ -260,10 +284,13 @@
skip_remote_release = true;
}
else
-#endif
- if (!filter_first_keypress || is_backlight_on(false)
+#endif /* HAVE_REMOTE_LCD */
+ if (!filter_first_keypress
+ || is_backlight_on(false)
+ || ((backlight_on_keypress_oracle != NULL)
+ && !(*backlight_on_keypress_oracle)(btn))
#if BUTTON_REMOTE
- || (btn & BUTTON_REMOTE)
+ || (btn & BUTTON_REMOTE)
#endif
)
queue_post(&button_queue, btn, data);
@@ -279,12 +306,7 @@
remote_backlight_on();
else
#endif
- {
- backlight_on();
-#ifdef HAVE_BUTTON_LIGHT
- buttonlight_on();
-#endif
- }
+ backlight_on_by_button(btn);
reset_poweroff_timer();
}
@@ -402,6 +424,7 @@
#endif
#ifdef HAVE_BACKLIGHT
filter_first_keypress = false;
+ set_backlight_on_keypress_oracle(NULL);
#ifdef HAVE_REMOTE_LCD
remote_filter_first_keypress = false;
#endif
@@ -496,6 +519,11 @@
{
filter_first_keypress = value;
}
+void set_backlight_on_keypress_oracle(backlight_on_keypress_oracle_func new_value)
+{
+ backlight_on_keypress_oracle = new_value;
+}
+
#ifdef HAVE_REMOTE_LCD
void set_remote_backlight_filter_keypress(bool value)
{
Index: uisimulator/sdl/button.c
===================================================================
--- uisimulator/sdl/button.c (Revision 20281)
+++ uisimulator/sdl/button.c (Arbeitskopie)
@@ -66,6 +66,13 @@
{
filter_first_keypress = value;
}
+static backlight_on_keypress_oracle_func backlight_on_keypress_oracle = NULL;
+void set_backlight_on_keypress_oracle(backlight_on_keypress_oracle_func new_value)
+{
+ backlight_on_keypress_oracle = new_value;
+}
+
+
#ifdef HAVE_REMOTE_LCD
static bool remote_filter_first_keypress;
@@ -1216,7 +1223,10 @@
else
#endif
if (!filter_first_keypress
- || is_backlight_on(false))
+ || is_backlight_on(false)
+ || ((backlight_on_keypress_oracle != NULL)
+ && !(*backlight_on_keypress_oracle)(btn))
+ )
queue_post(&button_queue, btn, data);
else
skip_release = true;
@@ -1231,7 +1241,23 @@
remote_backlight_on();
else
#endif
- backlight_on();
+ {
+ bool bl_on;
+ if (backlight_on_keypress_oracle != NULL)
+ {
+ bl_on = (*backlight_on_keypress_oracle)(btn);
+ DEBUGF("BL oracle (%d) returned: %d\n", btn, bl_on);
+ }
+ else
+ {
+ DEBUGF("BL callback is NULL -> bl ON\n");
+ bl_on = true;
+ }
+ if (bl_on)
+ {
+ backlight_on();
+ }
+ }
}
}