summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2006-03-24 13:47:24 +0000
committerBjörn Stenberg <bjorn@haxx.se>2006-03-24 13:47:24 +0000
commitda5fb18bca90ec09b99f28186787d10378a92109 (patch)
tree606690b331740a1a1f022cb8f5fce71fa06ddd10
parent86f1e2ead283d86f6896ca0f98c0b711da5e2cfe (diff)
downloadrockbox-da5fb18bca90ec09b99f28186787d10378a92109.tar.gz
rockbox-da5fb18bca90ec09b99f28186787d10378a92109.zip
New option: First keypress enables backlight only. Patch #2920 by Nicolas Pennequin.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9228 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/lang/english.lang6
-rw-r--r--apps/settings.c12
-rw-r--r--apps/settings.h4
-rw-r--r--apps/settings_menu.c10
-rw-r--r--firmware/backlight.c8
-rw-r--r--firmware/drivers/button.c18
-rw-r--r--firmware/export/backlight.h1
-rw-r--r--firmware/export/button.h3
-rw-r--r--uisimulator/sdl/button.c14
9 files changed, 74 insertions, 2 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 057282f81a..65e45cff5c 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -3832,3 +3832,9 @@ desc: "pitch" in the pitch screen
eng: "Pitch"
voice: "Pitch"
new:
+
+id: LANG_BACKLIGHT_FILTER_FIRST_KEYPRESS
+desc: Backlight behaviour setting
+eng: "First keypress enables backlight only"
+voice: "First keypress enables backlight only"
+new:
diff --git a/apps/settings.c b/apps/settings.c
index f5c0ba7c2d..4487361e8d 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -296,6 +296,14 @@ static const struct bit_entry rtc_bits[] =
#endif
#endif
+#ifdef CONFIG_BACKLIGHT
+#ifdef HAVE_LCD_COLOR
+ {1, S_O(bl_filter_first_keypress), true, "backlight filters first keypress", off_on },
+#else
+ {1, S_O(bl_filter_first_keypress), false, "backlight filters first keypress", off_on },
+#endif
+#endif
+
/* new stuff to be added here */
/* If values are just added to the end, no need to bump the version. */
@@ -1115,6 +1123,10 @@ void settings_apply(void)
#ifdef HAVE_SPDIF_POWER
spdif_power_enable(global_settings.spdif_enable);
#endif
+
+#ifdef CONFIG_BACKLIGHT
+ set_backlight_filter_keypress(global_settings.bl_filter_first_keypress);
+#endif
}
diff --git a/apps/settings.h b/apps/settings.h
index 52e949ea9e..2fd52aea9e 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -472,6 +472,10 @@ struct user_settings
int fg_color; /* foreground color native format */
#endif
bool party_mode; /* party mode - unstoppable music */
+
+#ifdef CONFIG_BACKLIGHT
+ bool bl_filter_first_keypress; /* filter first keypress when dark? */
+#endif
};
enum optiontype { INT, BOOL };
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 6e8d62191f..70703a23ce 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -1046,6 +1046,15 @@ static bool set_party_mode(void)
return set_bool( str(LANG_PARTY_MODE), &global_settings.party_mode );
}
+#ifdef CONFIG_BACKLIGHT
+static bool set_bl_filter_first_keypress(void)
+{
+ bool result = set_bool( str(LANG_BACKLIGHT_FILTER_FIRST_KEYPRESS),
+ &global_settings.bl_filter_first_keypress );
+ set_backlight_filter_keypress(global_settings.bl_filter_first_keypress);
+ return result;
+}
+#endif
static bool ff_rewind_accel(void)
{
@@ -1621,6 +1630,7 @@ static bool lcd_settings_menu(void)
#ifdef HAVE_BACKLIGHT_BRIGHTNESS
{ ID2P(LANG_BRIGHTNESS), brightness },
#endif
+ { ID2P(LANG_BACKLIGHT_FILTER_FIRST_KEYPRESS), set_bl_filter_first_keypress },
#endif /* CONFIG_BACKLIGHT */
{ ID2P(LANG_CONTRAST), contrast },
#ifdef HAVE_LCD_BITMAP
diff --git a/firmware/backlight.c b/firmware/backlight.c
index 66aa2d7c6c..a04000a426 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -522,6 +522,14 @@ void backlight_off(void)
queue_post(&backlight_queue, BACKLIGHT_OFF, NULL);
}
+bool is_backlight_on(void)
+{
+ if (backlight_timer || !backlight_get_current_timeout())
+ return true;
+ else
+ return false;
+}
+
/* return value in ticks; 0 means always on, <0 means always off */
int backlight_get_current_timeout(void)
{
diff --git a/firmware/drivers/button.c b/firmware/drivers/button.c
index dbdb171bf2..9e649ead5a 100644
--- a/firmware/drivers/button.c
+++ b/firmware/drivers/button.c
@@ -52,6 +52,9 @@ static long last_read; /* Last button status, for debouncing/filtering */
#ifdef HAVE_LCD_BITMAP
static bool flipped; /* buttons can be flipped to match the LCD flip */
#endif
+#ifdef CONFIG_BACKLIGHT
+static bool filter_first_keypress;
+#endif
/* how often we check to see if a button is pressed */
#define POLL_FREQUENCY HZ/100
@@ -504,7 +507,10 @@ static void button_tick(void)
}
else
{
- queue_post(&button_queue, btn, NULL);
+#ifdef CONFIG_BACKLIGHT
+ if ( !filter_first_keypress || is_backlight_on())
+#endif
+ queue_post(&button_queue, btn, NULL);
post = false;
}
#ifdef HAVE_REMOTE_LCD
@@ -629,6 +635,9 @@ void button_init(void)
#ifdef HAVE_LCD_BITMAP
flipped = false;
#endif
+#ifdef CONFIG_BACKLIGHT
+ filter_first_keypress = false;
+#endif
}
#ifdef HAVE_LCD_BITMAP /* only bitmap displays can be flipped */
@@ -687,6 +696,13 @@ void button_set_flip(bool flip)
}
#endif /* HAVE_LCD_BITMAP */
+#ifdef CONFIG_BACKLIGHT
+void set_backlight_filter_keypress(bool value)
+{
+ filter_first_keypress = value;
+}
+#endif
+
/*
Archos hardware button hookup
=============================
diff --git a/firmware/export/backlight.h b/firmware/export/backlight.h
index e182803898..f371dc1423 100644
--- a/firmware/export/backlight.h
+++ b/firmware/export/backlight.h
@@ -21,6 +21,7 @@
#include "config.h"
+bool is_backlight_on(void);
void backlight_on(void);
void backlight_off(void);
void backlight_set_timeout(int index);
diff --git a/firmware/export/button.h b/firmware/export/button.h
index 02d91d6a9b..a142540511 100644
--- a/firmware/export/button.h
+++ b/firmware/export/button.h
@@ -42,6 +42,9 @@ void button_clear_queue(void);
#ifdef HAVE_LCD_BITMAP
void button_set_flip(bool flip); /* turn 180 degrees */
#endif
+#ifdef CONFIG_BACKLIGHT
+void set_backlight_filter_keypress(bool value);
+#endif
#ifdef HAS_BUTTON_HOLD
bool button_hold(void);
diff --git a/uisimulator/sdl/button.c b/uisimulator/sdl/button.c
index 00a329924e..bf0396e18d 100644
--- a/uisimulator/sdl/button.c
+++ b/uisimulator/sdl/button.c
@@ -37,6 +37,15 @@ struct event_queue button_queue;
static int btn = 0; /* Hopefully keeps track of currently pressed keys... */
+#ifdef CONFIG_BACKLIGHT
+static bool filter_first_keypress;
+
+void set_backlight_filter_keypress(bool value)
+{
+ filter_first_keypress = value;
+}
+#endif
+
void button_event(int key, bool pressed)
{
int new_btn = 0;
@@ -219,7 +228,10 @@ void button_event(int key, bool pressed)
}
else
{
- queue_post(&button_queue, btn, NULL);
+#ifdef CONFIG_BACKLIGHT
+ if ( !filter_first_keypress || is_backlight_on())
+#endif
+ queue_post(&button_queue, btn, NULL);
post = false;
}