1
0
Fork 0
forked from len0rd/rockbox

Mark A. Hillebrand's patch that offers a new setting that if enabled, keeps

the backlight on all the time while the charger is connected.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@2464 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Daniel Stenberg 2002-10-01 10:59:36 +00:00
parent 180485c304
commit b95fe1afc6
7 changed files with 99 additions and 15 deletions

View file

@ -864,3 +864,8 @@ id: LANG_PM_UNITS_PER_READ
desc: in the peak meter menu
eng: "Units per read"
new:
id: LANG_BACKLIGHT_ON_WHEN_CHARGING
desc: in display_settings_menu
eng: "Backlight on when charging"
new:

View file

@ -74,7 +74,7 @@ offset abs
0x08 0x1c <loudness byte>
0x09 0x1d <bass boost byte>
0x0a 0x1e <contrast byte>
0x0b 0x1f <backlight byte>
0x0b 0x1f <backlight_on_when_charging, backlight_timeout>
0x0c 0x20 <poweroff timer byte>
0x0d 0x21 <resume settings byte>
0x0e 0x22 <shuffle,dirfilter,sort_case,discharge,statusbar,show_hidden,
@ -270,7 +270,16 @@ int settings_save( void )
config_block[0x9] = (unsigned char)global_settings.bass_boost;
config_block[0xa] = (unsigned char)global_settings.contrast;
config_block[0xb] = (unsigned char)global_settings.backlight;
#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[0xc] = (unsigned char)global_settings.poweroff;
config_block[0xd] = (unsigned char)global_settings.resume;
@ -366,8 +375,15 @@ 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;
}
#else
if (config_block[0xb] != 0xFF)
global_settings.backlight = config_block[0xb];
global_settings.backlight_timeout = config_block[0xb];
#endif
if (config_block[0xc] != 0xFF)
global_settings.poweroff = config_block[0xc];
if (config_block[0xd] != 0xFF)
@ -432,7 +448,10 @@ void settings_load(void)
}
lcd_set_contrast(global_settings.contrast);
lcd_scroll_speed(global_settings.scroll_speed);
backlight_time(global_settings.backlight);
backlight_set_timeout(global_settings.backlight_timeout);
#ifdef HAVE_CHARGE_CTRL
backlight_set_on_when_charging(global_settings.backlight_on_when_charging);
#endif
ata_spindown(global_settings.disk_spindown);
set_poweroff_timeout(global_settings.poweroff);
#ifdef HAVE_CHARGE_CTRL
@ -615,7 +634,10 @@ void settings_reset(void) {
global_settings.resume = RESUME_ASK;
global_settings.contrast = DEFAULT_CONTRAST_SETTING;
global_settings.poweroff = DEFAULT_POWEROFF_SETTING;
global_settings.backlight = DEFAULT_BACKLIGHT_SETTING;
global_settings.backlight_timeout = DEFAULT_BACKLIGHT_TIMEOUT_SETTING;
#ifdef HAVE_CHARGE_CTRL
global_settings.backlight_on_when_charging = DEFAULT_BACKLIGHT_ON_WHEN_CHARGING_SETTING;
#endif
global_settings.dirfilter = SHOW_MUSIC;
global_settings.sort_case = false;
global_settings.statusbar = true;
@ -654,10 +676,10 @@ void settings_display(void)
global_settings.loudness,
global_settings.bass_boost );
DEBUGF( "contrast:\t%d\npoweroff:\t%d\nbacklight:\t%d\n",
DEBUGF( "contrast:\t%d\npoweroff:\t%d\nbacklight_timeout:\t%d\n",
global_settings.contrast,
global_settings.poweroff,
global_settings.backlight );
global_settings.backlight_timeout );
#endif
}

View file

@ -63,7 +63,10 @@ struct user_settings
int contrast; /* lcd contrast: 0-100 0=low 100=high */
int poweroff; /* power off timer */
int backlight; /* backlight off timer: 0-100 0=never:each 1% = 10 secs */
int backlight_timeout; /* backlight off timeout: 0-18 0=never,1=always,then according to timeout_values[] */
#ifdef HAVE_CHARGE_CTRL
bool backlight_on_when_charging;
#endif
bool discharge; /* maintain charge of at least: false = 90%, true = 10% */
/* resume settings */
@ -144,7 +147,8 @@ extern char rockboxdir[];
#endif
#define MIN_CONTRAST_SETTING 5
#define DEFAULT_POWEROFF_SETTING 0
#define DEFAULT_BACKLIGHT_SETTING 5
#define DEFAULT_BACKLIGHT_TIMEOUT_SETTING 5
#define DEFAULT_BACKLIGHT_ON_WHEN_CHARGING_SETTING 0
#define DEFAULT_FF_REWIND_MIN_STEP FF_REWIND_1000
#define DEFAULT_FF_REWIND_ACCEL_SETTING 3

View file

@ -144,6 +144,16 @@ static bool resume(void)
names, 3, NULL );
}
#ifdef HAVE_CHARGE_CTRL
static bool backlight_on_when_charging(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;
}
#endif
static bool backlight_timer(void)
{
char* names[] = { str(LANG_OFF), str(LANG_ON),
@ -151,8 +161,8 @@ static bool backlight_timer(void)
"6s ", "7s ", "8s ", "9s ", "10s",
"15s", "20s", "25s", "30s", "45s",
"60s", "90s"};
return set_option(str(LANG_BACKLIGHT), &global_settings.backlight,
names, 19, backlight_time );
return set_option(str(LANG_BACKLIGHT), &global_settings.backlight_timeout,
names, 19, backlight_set_timeout );
}
static bool poweroff_idle_timer(void)
@ -377,6 +387,9 @@ static bool display_settings_menu(void)
struct menu_items items[] = {
{ str(LANG_SCROLL_MENU), scroll_speed },
{ str(LANG_BACKLIGHT), backlight_timer },
#ifdef HAVE_CHARGE_CTRL
{ str(LANG_BACKLIGHT_ON_WHEN_CHARGING), backlight_on_when_charging },
#endif
{ str(LANG_CONTRAST), contrast },
#ifdef HAVE_LCD_BITMAP
{ str(LANG_PM_MENU), peak_meter_menu },

View file

@ -25,6 +25,7 @@
#include "debug.h"
#include "rtc.h"
#include "usb.h"
#include "power.h"
#define BACKLIGHT_ON 1
#define BACKLIGHT_OFF 2
@ -34,6 +35,11 @@ static char backlight_stack[DEFAULT_STACK_SIZE];
static char backlight_thread_name[] = "backlight";
static struct event_queue backlight_queue;
#ifdef HAVE_CHARGE_CTRL
static bool charger_was_inserted = 0;
static bool backlight_on_when_charging = 0;
#endif
static int backlight_timer;
static int backlight_timeout = 5;
@ -52,9 +58,22 @@ void backlight_thread(void)
switch(ev.id)
{
case BACKLIGHT_ON:
#ifdef HAVE_CHARGE_CTRL
if( backlight_on_when_charging && charger_inserted() )
{
/* Forcing to zero keeps the lights on */
backlight_timer = 0;
}
else
{
backlight_timer = HZ*timeout_value[backlight_timeout];
}
#else
backlight_timer = HZ*timeout_value[backlight_timeout];
#endif
if(backlight_timer < 0)
{
backlight_timer = 0; /* timer value 0 will not get ticked */
#ifdef HAVE_RTC
/* Disable square wave */
rtc_write(0x0a, rtc_read(0x0a) & ~0x40);
@ -62,7 +81,8 @@ void backlight_thread(void)
PADR |= 0x4000;
#endif
}
else if(backlight_timer)
/* else if(backlight_timer) */
else
{
#ifdef HAVE_RTC
/* Enable square wave */
@ -105,14 +125,28 @@ void backlight_off(void)
queue_post(&backlight_queue, BACKLIGHT_OFF, NULL);
}
void backlight_time(int value)
void backlight_set_timeout(int seconds)
{
backlight_timeout = value;
backlight_timeout = seconds;
backlight_on();
}
void backlight_set_on_when_charging(bool yesno)
{
backlight_on_when_charging = yesno;
backlight_on();
}
void backlight_tick(void)
{
#ifdef HAVE_CHARGE_CTRL
bool charger_is_inserted = charger_inserted();
if( backlight_on_when_charging && (charger_was_inserted != charger_is_inserted) )
{
backlight_on();
}
charger_was_inserted = charger_is_inserted;
#endif
if(backlight_timer)
{
backlight_timer--;

View file

@ -23,6 +23,7 @@ void backlight_init(void);
void backlight_on(void);
void backlight_off(void);
void backlight_tick(void);
void backlight_time(int seconds);
void backlight_set_timeout(int seconds);
void backlight_set_on_when_charging(bool yesno);
#endif

View file

@ -123,3 +123,8 @@ void lcd_set_contrast( int x )
{
(void)x;
}
void backlight_set_timeout(int seconds)
{
(void)seconds;
}