From c5b24010cbbf87a979ed78d6b2c9fe76e0e7d439 Mon Sep 17 00:00:00 2001 From: Linus Nielsen Feltzing Date: Sun, 6 Oct 2002 10:13:48 +0000 Subject: [PATCH] Accepted Brian King's backlight-on-when-charging patch, slightly modified git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2515 a1c6a512-1295-4272-9138-f99709370657 --- apps/settings.c | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/apps/settings.c b/apps/settings.c index dab44fe229..122f1109fb 100644 --- a/apps/settings.c +++ b/apps/settings.c @@ -275,15 +275,9 @@ int settings_save( void ) config_block[0xa] = (unsigned char)global_settings.contrast; -#ifdef HAVE_CHARGE_CTRL - if( global_settings.backlight_on_when_charging ) { - config_block[0xb] = (unsigned char) (global_settings.backlight_timeout + 128); - } else { - config_block[0xb] = (unsigned char)global_settings.backlight_timeout; - } -#else - config_block[0xb] = (unsigned char)global_settings.backlight_timeout; -#endif + config_block[0xb] = (unsigned char) + ((global_settings.backlight_on_when_charging?0x40:0) | + (global_settings.backlight_timeout & 0x3f)); config_block[0xc] = (unsigned char)global_settings.poweroff; config_block[0xd] = (unsigned char)global_settings.resume; @@ -408,15 +402,14 @@ void settings_load(void) if ( global_settings.contrast < MIN_CONTRAST_SETTING ) global_settings.contrast = DEFAULT_CONTRAST_SETTING; } -#ifdef HAVE_CHARGE_CTRL + if (config_block[0xb] != 0xFF) { - global_settings.backlight_timeout = config_block[0xb] & 127; - global_settings.backlight_on_when_charging = config_block[0xb] & 128 ? 1 : 0; + /* Bit 7 is unused to be able to detect uninitialized entry */ + global_settings.backlight_timeout = config_block[0xb] & 0x3f; + global_settings.backlight_on_when_charging = + config_block[0xb] & 0x40 ? true : false; } -#else - if (config_block[0xb] != 0xFF) - global_settings.backlight_timeout = config_block[0xb]; -#endif + if (config_block[0xc] != 0xFF) global_settings.poweroff = config_block[0xc]; if (config_block[0xd] != 0xFF)