summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Arnold <amiconn@rockbox.org>2005-11-23 20:12:33 +0000
committerJens Arnold <amiconn@rockbox.org>2005-11-23 20:12:33 +0000
commita6d409d9db969aedd3977ca3d0894bbf75533e39 (patch)
tree848ac0a55eb16c5f407017d3f7f73318f248088d
parent47569223ebb5e99040c7c5cfc7d2a725999c6197 (diff)
downloadrockbox-a6d409d9db969aedd3977ca3d0894bbf75533e39.zip
rockbox-a6d409d9db969aedd3977ca3d0894bbf75533e39.tar.gz
rockbox-a6d409d9db969aedd3977ca3d0894bbf75533e39.tar.bz2
rockbox-a6d409d9db969aedd3977ca3d0894bbf75533e39.tar.xz
Replaced the booolean 'Backlight On When Plugged' setting with a complete alternative 'Backlight When Plugged' timeout setting. * Yield during poweroff to make backlight_off() work. * Bumped config version, save your settings.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8053 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--apps/lang/english.lang6
-rw-r--r--apps/screens.c2
-rw-r--r--apps/settings.c37
-rw-r--r--apps/settings.h4
-rw-r--r--apps/settings_menu.c101
-rw-r--r--firmware/backlight.c79
-rw-r--r--firmware/drivers/power.c3
-rw-r--r--firmware/export/backlight.h7
-rw-r--r--firmware/powermgmt.c7
9 files changed, 113 insertions, 133 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index 5e49b95..0192578 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -680,9 +680,9 @@ voice: "Units Per Read"
new:
id: LANG_BACKLIGHT_ON_WHEN_CHARGING
-desc: in display_settings_menu
-eng: "Backlight On When Plugged"
-voice: "Backlight On When Plugged"
+desc: in display_settings_menu, backlight timeout with charger connected
+eng: "Backlight When Plugged"
+voice: "Backlight When Plugged"
new:
id: LANG_REPEAT
diff --git a/apps/screens.c b/apps/screens.c
index 368a185..1693c31 100644
--- a/apps/screens.c
+++ b/apps/screens.c
@@ -313,7 +313,7 @@ int charging_screen(void)
#ifdef HAVE_REMOTE_LCD
remote_backlight_set_timeout(global_settings.remote_backlight_timeout);
#endif
- backlight_set_on_when_charging(global_settings.backlight_on_when_charging);
+ backlight_set_timeout_plugged(global_settings.backlight_timeout_plugged);
gui_syncstatusbar_draw(&statusbars, true);
#ifdef HAVE_LCD_CHARCELLS
diff --git a/apps/settings.c b/apps/settings.c
index 939d488..516518d 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -85,7 +85,7 @@ const char rec_base_directory[] = REC_BASE_DIR;
#include "dsp.h"
#endif
-#define CONFIG_BLOCK_VERSION 32
+#define CONFIG_BLOCK_VERSION 33
#define CONFIG_BLOCK_SIZE 512
#define RTC_BLOCK_SIZE 44
@@ -179,6 +179,11 @@ static const char trig_durations_conf [] =
"0s,1s,2s,5s,10s,15s,20s,25s,30s,1min,2min,5min,10min";
#endif
+#if defined(CONFIG_BACKLIGHT)
+static const char backlight_times_conf [] =
+ "off,on,1,2,3,4,5,6,7,8,9,10,15,20,25,30,45,60,90";
+#endif
+
/* the part of the settings which ends up in the RTC RAM, where available
(those we either need early, save frequently, or without spinup) */
static const struct bit_entry rtc_bits[] =
@@ -216,12 +221,11 @@ static const struct bit_entry rtc_bits[] =
/* LCD */
{6, S_O(contrast), 40, "contrast", NULL },
#ifdef CONFIG_BACKLIGHT
+ {5, S_O(backlight_timeout), 5, "backlight timeout", backlight_times_conf },
#ifdef HAVE_CHARGING
- {1, S_O(backlight_on_when_charging), false,
- "backlight when plugged", off_on },
+ {5, S_O(backlight_timeout_plugged), 11, "backlight timeout plugged",
+ backlight_times_conf },
#endif
- {5, S_O(backlight_timeout), 5, "backlight timeout",
- "off,on,1,2,3,4,5,6,7,8,9,10,15,20,25,30,45,60,90" },
#endif /* CONFIG_BACKLIGHT */
#ifdef HAVE_LCD_BITMAP
{1, S_O(invert), false, "invert", off_on },
@@ -236,6 +240,7 @@ static const struct bit_entry rtc_bits[] =
{1, S_O(volume_type), 0, "volume display", graphic_numeric },
{1, S_O(battery_display), 0, "battery display", graphic_numeric },
{1, S_O(timeformat), 0, "time format", "24hour,12hour" },
+ {1, S_O(bidi_support), false, "bidi hebrew/arabic", off_on },
#endif /* HAVE_LCD_BITMAP */
{1, S_O(show_icons), true, "show icons", off_on },
/* system */
@@ -268,23 +273,16 @@ static const struct bit_entry rtc_bits[] =
/* remote lcd */
{6, S_O(remote_contrast), 42, "remote contrast", NULL },
{1, S_O(remote_invert), false, "remote invert", off_on },
- {5, S_O(remote_backlight_timeout), 5, "remote backlight timeout",
- "off,on,1,2,3,4,5,6,7,8,9,10,15,20,25,30,45,60,90" },
{1, S_O(remote_flip_display), false, "remote flip display", off_on },
+ {5, S_O(remote_backlight_timeout), 5, "remote backlight timeout",
+ backlight_times_conf },
+#ifdef HAVE_CHARGING
+ {5, S_O(remote_backlight_timeout_plugged), 11,
+ "remote backlight timeout plugged", backlight_times_conf },
#endif
-
-#ifdef HAVE_LCD_BITMAP /* move to LCD next time we bump version */
- {1, S_O(bidi_support), false, "bidi hebrew/arabic", off_on },
-#endif
-
-#ifdef HAVE_REMOTE_LCD /* move to REMOTE_LCD next time we bump version */
#ifdef HAVE_REMOTE_LCD_TICKING
{1, S_O(remote_reduce_ticking), false, "remote reduce ticking", off_on },
#endif
-#ifdef HAVE_CHARGING
- {1, S_O(remote_backlight_on_when_charging), false,
- "remote backlight when plugged", off_on },
-#endif
#endif
/* new stuff to be added here */
@@ -871,11 +869,14 @@ void settings_apply(void)
lcd_remote_emireduce(global_settings.remote_reduce_ticking);
#endif
remote_backlight_set_timeout(global_settings.remote_backlight_timeout);
+#ifdef HAVE_CHARGING
+ remote_backlight_set_timeout_plugged(global_settings.remote_backlight_timeout_plugged);
+#endif
#endif
#ifdef CONFIG_BACKLIGHT
backlight_set_timeout(global_settings.backlight_timeout);
#ifdef HAVE_CHARGING
- backlight_set_on_when_charging(global_settings.backlight_on_when_charging);
+ backlight_set_timeout_plugged(global_settings.backlight_timeout_plugged);
#endif
#if (CONFIG_BACKLIGHT == BL_IRIVER_H100) && !defined(SIMULATOR)
backlight_set_fade_in(global_settings.backlight_fade_in);
diff --git a/apps/settings.h b/apps/settings.h
index 689dffc..9587033 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -221,7 +221,7 @@ struct user_settings
int backlight_timeout; /* backlight off timeout: 0-18 0=never,
1=always,
then according to timeout_values[] */
- bool backlight_on_when_charging;
+ int backlight_timeout_plugged;
#if CONFIG_BACKLIGHT == BL_IRIVER_H100
int backlight_fade_in; /* backlight fade in timing: 0..3 */
int backlight_fade_out; /* backlight fade in timing: 0..7 */
@@ -343,7 +343,7 @@ struct user_settings
int remote_backlight_timeout; /* backlight off timeout: 0-18 0=never,
1=always,
then according to timeout_values[] */
- bool remote_backlight_on_when_charging;
+ int remote_backlight_timeout_plugged;
bool remote_caption_backlight; /* turn on backlight at end and start of track */
#ifdef HAVE_REMOTE_LCD_TICKING
bool remote_reduce_ticking; /* 0=normal operation,
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index 5230dd2..864ad63 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -135,6 +135,28 @@ static bool remote_reduce_ticking(void)
#endif
#ifdef CONFIG_BACKLIGHT
+static const struct opt_items backlight_timeouts[] = {
+ { STR(LANG_OFF) },
+ { STR(LANG_ON) },
+ { "1s ", TALK_ID(1, UNIT_SEC) },
+ { "2s ", TALK_ID(2, UNIT_SEC) },
+ { "3s ", TALK_ID(3, UNIT_SEC) },
+ { "4s ", TALK_ID(4, UNIT_SEC) },
+ { "5s ", TALK_ID(5, UNIT_SEC) },
+ { "6s ", TALK_ID(6, UNIT_SEC) },
+ { "7s ", TALK_ID(7, UNIT_SEC) },
+ { "8s ", TALK_ID(8, UNIT_SEC) },
+ { "9s ", TALK_ID(9, UNIT_SEC) },
+ { "10s", TALK_ID(10, UNIT_SEC) },
+ { "15s", TALK_ID(15, UNIT_SEC) },
+ { "20s", TALK_ID(20, UNIT_SEC) },
+ { "25s", TALK_ID(25, UNIT_SEC) },
+ { "30s", TALK_ID(30, UNIT_SEC) },
+ { "45s", TALK_ID(45, UNIT_SEC) },
+ { "60s", TALK_ID(60, UNIT_SEC) },
+ { "90s", TALK_ID(90, UNIT_SEC) }
+};
+
static bool caption_backlight(void)
{
return set_bool( str(LANG_CAPTION_BACKLIGHT),
@@ -142,40 +164,21 @@ static bool caption_backlight(void)
}
#ifdef HAVE_CHARGING
-static bool backlight_on_when_charging(void)
+static bool backlight_timer_plugged(void)
{
- bool result = set_bool(str(LANG_BACKLIGHT_ON_WHEN_CHARGING),
- &global_settings.backlight_on_when_charging);
- backlight_set_on_when_charging(global_settings.backlight_on_when_charging);
- return result;
+ return set_option(str(LANG_BACKLIGHT_ON_WHEN_CHARGING),
+ &global_settings.backlight_timeout_plugged,
+ INT, backlight_timeouts, 19,
+ backlight_set_timeout_plugged );
}
#endif
static bool backlight_timer(void)
{
- static const struct opt_items names[] = {
- { STR(LANG_OFF) },
- { STR(LANG_ON) },
- { "1s ", TALK_ID(1, UNIT_SEC) },
- { "2s ", TALK_ID(2, UNIT_SEC) },
- { "3s ", TALK_ID(3, UNIT_SEC) },
- { "4s ", TALK_ID(4, UNIT_SEC) },
- { "5s ", TALK_ID(5, UNIT_SEC) },
- { "6s ", TALK_ID(6, UNIT_SEC) },
- { "7s ", TALK_ID(7, UNIT_SEC) },
- { "8s ", TALK_ID(8, UNIT_SEC) },
- { "9s ", TALK_ID(9, UNIT_SEC) },
- { "10s", TALK_ID(10, UNIT_SEC) },
- { "15s", TALK_ID(15, UNIT_SEC) },
- { "20s", TALK_ID(20, UNIT_SEC) },
- { "25s", TALK_ID(25, UNIT_SEC) },
- { "30s", TALK_ID(30, UNIT_SEC) },
- { "45s", TALK_ID(45, UNIT_SEC) },
- { "60s", TALK_ID(60, UNIT_SEC) },
- { "90s", TALK_ID(90, UNIT_SEC) }
- };
- return set_option(str(LANG_BACKLIGHT), &global_settings.backlight_timeout,
- INT, names, 19, backlight_set_timeout );
+ return set_option(str(LANG_BACKLIGHT),
+ &global_settings.backlight_timeout,
+ INT, backlight_timeouts, 19,
+ backlight_set_timeout );
}
#if (CONFIG_BACKLIGHT == BL_IRIVER_H100) && !defined(SIMULATOR)
@@ -215,39 +218,19 @@ static bool backlight_fade_out(void)
static bool remote_backlight_timer(void)
{
- static const struct opt_items names[] = {
- { STR(LANG_OFF) },
- { STR(LANG_ON) },
- { "1s ", TALK_ID(1, UNIT_SEC) },
- { "2s ", TALK_ID(2, UNIT_SEC) },
- { "3s ", TALK_ID(3, UNIT_SEC) },
- { "4s ", TALK_ID(4, UNIT_SEC) },
- { "5s ", TALK_ID(5, UNIT_SEC) },
- { "6s ", TALK_ID(6, UNIT_SEC) },
- { "7s ", TALK_ID(7, UNIT_SEC) },
- { "8s ", TALK_ID(8, UNIT_SEC) },
- { "9s ", TALK_ID(9, UNIT_SEC) },
- { "10s", TALK_ID(10, UNIT_SEC) },
- { "15s", TALK_ID(15, UNIT_SEC) },
- { "20s", TALK_ID(20, UNIT_SEC) },
- { "25s", TALK_ID(25, UNIT_SEC) },
- { "30s", TALK_ID(30, UNIT_SEC) },
- { "45s", TALK_ID(45, UNIT_SEC) },
- { "60s", TALK_ID(60, UNIT_SEC) },
- { "90s", TALK_ID(90, UNIT_SEC) }
- };
- return set_option(str(LANG_BACKLIGHT), &global_settings.remote_backlight_timeout,
- INT, names, 19, remote_backlight_set_timeout );
+ return set_option(str(LANG_BACKLIGHT),
+ &global_settings.remote_backlight_timeout,
+ INT, backlight_timeouts, 19,
+ remote_backlight_set_timeout );
}
#ifdef HAVE_CHARGING
-static bool remote_backlight_on_when_charging(void)
+static bool remote_backlight_timer_plugged(void)
{
- bool result = set_bool(str(LANG_BACKLIGHT_ON_WHEN_CHARGING),
- &global_settings.remote_backlight_on_when_charging);
- remote_backlight_set_on_when_charging(
- global_settings.remote_backlight_on_when_charging);
- return result;
+ return set_option(str(LANG_BACKLIGHT_ON_WHEN_CHARGING),
+ &global_settings.remote_backlight_timeout_plugged,
+ INT, backlight_timeouts, 19,
+ remote_backlight_set_timeout_plugged );
}
#endif
@@ -1532,7 +1515,7 @@ static bool lcd_settings_menu(void)
#ifdef CONFIG_BACKLIGHT
{ ID2P(LANG_BACKLIGHT), backlight_timer },
#ifdef HAVE_CHARGING
- { ID2P(LANG_BACKLIGHT_ON_WHEN_CHARGING), backlight_on_when_charging },
+ { ID2P(LANG_BACKLIGHT_ON_WHEN_CHARGING), backlight_timer_plugged },
#endif
{ ID2P(LANG_CAPTION_BACKLIGHT), caption_backlight },
#if (CONFIG_BACKLIGHT == BL_IRIVER_H100) && !defined(SIMULATOR)
@@ -1565,7 +1548,7 @@ static bool lcd_remote_settings_menu(void)
{ ID2P(LANG_BACKLIGHT), remote_backlight_timer },
#ifdef HAVE_CHARGING
{ ID2P(LANG_BACKLIGHT_ON_WHEN_CHARGING),
- remote_backlight_on_when_charging },
+ remote_backlight_timer_plugged },
#endif
{ ID2P(LANG_CAPTION_BACKLIGHT), remote_caption_backlight },
{ ID2P(LANG_CONTRAST), remote_contrast },
diff --git a/firmware/backlight.c b/firmware/backlight.c
index 5a3c509..491d2b5 100644
--- a/firmware/backlight.c
+++ b/firmware/backlight.c
@@ -52,14 +52,18 @@ static long backlight_stack[DEFAULT_STACK_SIZE/sizeof(long)];
static const char backlight_thread_name[] = "backlight";
static struct event_queue backlight_queue;
-static bool backlight_on_when_charging = false;
static int backlight_timer;
-static unsigned int backlight_timeout = 5;
+static int backlight_timeout = 5*HZ;
+#ifdef HAVE_CHARGING
+static int backlight_timeout_plugged = 5*HZ;
+#endif
#ifdef HAVE_REMOTE_LCD
-static bool remote_backlight_on_when_charging = false;
static int remote_backlight_timer;
-static unsigned int remote_backlight_timeout = 5;
+static int remote_backlight_timeout = 5*HZ;
+#ifdef HAVE_CHARGING
+static int remote_backlight_timeout_plugged = 5*HZ;
+#endif
#endif
#if (CONFIG_BACKLIGHT == BL_IRIVER_H100) && !defined(SIMULATOR)
@@ -304,19 +308,15 @@ void backlight_thread(void)
{
#ifdef HAVE_REMOTE_LCD
case REMOTE_BACKLIGHT_ON:
- if( remote_backlight_on_when_charging && charger_inserted() )
- {
- /* Forcing to zero keeps the lights on */
- remote_backlight_timer = 0;
- }
+#ifdef HAVE_CHARGING
+ if (charger_inserted())
+ remote_backlight_timer = remote_backlight_timeout_plugged;
else
- {
- remote_backlight_timer =
- HZ*backlight_timeout_value[remote_backlight_timeout];
- }
+#endif
+ remote_backlight_timer = remote_backlight_timeout;
/* Backlight == OFF in the setting? */
- if(remote_backlight_timer < 0)
+ if (remote_backlight_timer < 0)
{
remote_backlight_timer = 0; /* Disable the timeout */
__remote_backlight_off();
@@ -333,17 +333,14 @@ void backlight_thread(void)
#endif /* HAVE_REMOTE_LCD */
case BACKLIGHT_ON:
- if( backlight_on_when_charging && charger_inserted() )
- {
- /* Forcing to zero keeps the lights on */
- backlight_timer = 0;
- }
+#ifdef HAVE_CHARGING
+ if (charger_inserted())
+ backlight_timer = backlight_timeout_plugged;
else
- {
- backlight_timer = HZ*backlight_timeout_value[backlight_timeout];
- }
+#endif
+ backlight_timer = backlight_timeout;
- if(backlight_timer < 0) /* Backlight == OFF in the setting? */
+ if (backlight_timer < 0) /* Backlight == OFF in the setting? */
{
backlight_timer = 0; /* Disable the timeout */
__backlight_off();
@@ -385,11 +382,9 @@ static void backlight_tick(void)
if( charger_was_inserted != charger_is_inserted )
{
- if( backlight_on_when_charging )
- backlight_on();
+ backlight_on();
#ifdef HAVE_REMOTE_LCD
- if( remote_backlight_on_when_charging )
- remote_backlight_on();
+ remote_backlight_on();
#endif
}
charger_was_inserted = charger_is_inserted;
@@ -453,9 +448,14 @@ void backlight_off(void)
queue_post(&backlight_queue, BACKLIGHT_OFF, NULL);
}
-int backlight_get_timeout(void)
+/* return value in ticks; 0 means always on, <0 means always off */
+int backlight_get_current_timeout(void)
{
+#ifdef HAVE_CHARGING
+ return charger_inserted() ? backlight_timeout_plugged : backlight_timeout;
+#else
return backlight_timeout;
+#endif
}
void backlight_set_timeout(int index)
@@ -463,19 +463,17 @@ void backlight_set_timeout(int index)
if((unsigned)index >= sizeof(backlight_timeout_value))
/* if given a weird value, use 0 */
index=0;
- backlight_timeout = index; /* index in the backlight_timeout_value table */
+ backlight_timeout = HZ * backlight_timeout_value[index];
backlight_on();
}
#ifdef HAVE_CHARGING
-bool backlight_get_on_when_charging(void)
-{
- return backlight_on_when_charging;
-}
-
-void backlight_set_on_when_charging(bool yesno)
+void backlight_set_timeout_plugged(int index)
{
- backlight_on_when_charging = yesno;
+ if((unsigned)index >= sizeof(backlight_timeout_value))
+ /* if given a weird value, use 0 */
+ index=0;
+ backlight_timeout_plugged = HZ * backlight_timeout_value[index];
backlight_on();
}
#endif
@@ -496,14 +494,17 @@ void remote_backlight_set_timeout(int index)
if((unsigned)index >= sizeof(backlight_timeout_value))
/* if given a weird value, use 0 */
index=0;
- remote_backlight_timeout = index; /* index in the backlight_timeout_value table */
+ remote_backlight_timeout = HZ * backlight_timeout_value[index];
remote_backlight_on();
}
#ifdef HAVE_CHARGING
-void remote_backlight_set_on_when_charging(bool yesno)
+void remote_backlight_set_timeout_plugged(int index)
{
- remote_backlight_on_when_charging = yesno;
+ if((unsigned)index >= sizeof(backlight_timeout_value))
+ /* if given a weird value, use 0 */
+ index=0;
+ remote_backlight_timeout_plugged = HZ * backlight_timeout_value[index];
remote_backlight_on();
}
#endif
diff --git a/firmware/drivers/power.c b/firmware/drivers/power.c
index 252a04d..e339b90 100644
--- a/firmware/drivers/power.c
+++ b/firmware/drivers/power.c
@@ -280,7 +280,8 @@ void power_off(void)
or_b(0x08, &PAIORH);
#endif
#endif
- while(1);
+ while(1)
+ yield();
}
#else
diff --git a/firmware/export/backlight.h b/firmware/export/backlight.h
index 6d3d4d5..9c3f5aa 100644
--- a/firmware/export/backlight.h
+++ b/firmware/export/backlight.h
@@ -26,13 +26,12 @@ void backlight_off(void);
void backlight_set_timeout(int index);
#ifdef CONFIG_BACKLIGHT
void backlight_init(void);
-int backlight_get_timeout(void);
+int backlight_get_current_timeout(void);
#if CONFIG_BACKLIGHT == BL_IRIVER_H100
void backlight_set_fade_in(int index);
void backlight_set_fade_out(int index);
#endif
-bool backlight_get_on_when_charging(void);
-void backlight_set_on_when_charging(bool yesno);
+void backlight_set_timeout_plugged(int index);
extern const char backlight_timeout_value[];
#else
#define backlight_init()
@@ -42,7 +41,7 @@ extern const char backlight_timeout_value[];
void remote_backlight_on(void);
void remote_backlight_off(void);
void remote_backlight_set_timeout(int index);
-void remote_backlight_set_on_when_charging(bool yesno);
+void remote_backlight_set_timeout_plugged(int index);
#endif
#ifdef SIMULATOR
diff --git a/firmware/powermgmt.c b/firmware/powermgmt.c
index 72a9b90..e061f70 100644
--- a/firmware/powermgmt.c
+++ b/firmware/powermgmt.c
@@ -449,13 +449,8 @@ static int runcurrent(void)
}
#if defined(CONFIG_BACKLIGHT) && !defined(BOOTLOADER)
- if ((backlight_get_timeout() == 1) /* LED always on */
-#ifdef HAVE_CHARGE_CTRL
- || (charger_inserted() && backlight_get_on_when_charging())
-#endif
- ) {
+ if (backlight_get_current_timeout() == 0) /* LED always on */
current += CURRENT_BACKLIGHT;
- }
#endif
return(current);