diff options
-rw-r--r-- | apps/lang/english.lang | 5 | ||||
-rw-r--r-- | apps/settings.c | 36 | ||||
-rw-r--r-- | apps/settings.h | 8 | ||||
-rw-r--r-- | apps/settings_menu.c | 17 | ||||
-rw-r--r-- | firmware/backlight.c | 40 | ||||
-rw-r--r-- | firmware/backlight.h | 3 | ||||
-rw-r--r-- | uisimulator/common/stubs.c | 5 |
7 files changed, 99 insertions, 15 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang index afea869bee..9ff2b66e44 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang | |||
@@ -864,3 +864,8 @@ id: LANG_PM_UNITS_PER_READ | |||
864 | desc: in the peak meter menu | 864 | desc: in the peak meter menu |
865 | eng: "Units per read" | 865 | eng: "Units per read" |
866 | new: | 866 | new: |
867 | |||
868 | id: LANG_BACKLIGHT_ON_WHEN_CHARGING | ||
869 | desc: in display_settings_menu | ||
870 | eng: "Backlight on when charging" | ||
871 | new: | ||
diff --git a/apps/settings.c b/apps/settings.c index 1b4f864ec5..450a85b2da 100644 --- a/apps/settings.c +++ b/apps/settings.c | |||
@@ -74,7 +74,7 @@ offset abs | |||
74 | 0x08 0x1c <loudness byte> | 74 | 0x08 0x1c <loudness byte> |
75 | 0x09 0x1d <bass boost byte> | 75 | 0x09 0x1d <bass boost byte> |
76 | 0x0a 0x1e <contrast byte> | 76 | 0x0a 0x1e <contrast byte> |
77 | 0x0b 0x1f <backlight byte> | 77 | 0x0b 0x1f <backlight_on_when_charging, backlight_timeout> |
78 | 0x0c 0x20 <poweroff timer byte> | 78 | 0x0c 0x20 <poweroff timer byte> |
79 | 0x0d 0x21 <resume settings byte> | 79 | 0x0d 0x21 <resume settings byte> |
80 | 0x0e 0x22 <shuffle,dirfilter,sort_case,discharge,statusbar,show_hidden, | 80 | 0x0e 0x22 <shuffle,dirfilter,sort_case,discharge,statusbar,show_hidden, |
@@ -270,7 +270,16 @@ int settings_save( void ) | |||
270 | config_block[0x9] = (unsigned char)global_settings.bass_boost; | 270 | config_block[0x9] = (unsigned char)global_settings.bass_boost; |
271 | 271 | ||
272 | config_block[0xa] = (unsigned char)global_settings.contrast; | 272 | config_block[0xa] = (unsigned char)global_settings.contrast; |
273 | config_block[0xb] = (unsigned char)global_settings.backlight; | 273 | |
274 | #ifdef HAVE_CHARGE_CTRL | ||
275 | if( global_settings.backlight_on_when_charging ) { | ||
276 | config_block[0xb] = (unsigned char) (global_settings.backlight_timeout + 128); | ||
277 | } else { | ||
278 | config_block[0xb] = (unsigned char)global_settings.backlight_timeout; | ||
279 | } | ||
280 | #else | ||
281 | config_block[0xb] = (unsigned char)global_settings.backlight_timeout; | ||
282 | #endif | ||
274 | config_block[0xc] = (unsigned char)global_settings.poweroff; | 283 | config_block[0xc] = (unsigned char)global_settings.poweroff; |
275 | config_block[0xd] = (unsigned char)global_settings.resume; | 284 | config_block[0xd] = (unsigned char)global_settings.resume; |
276 | 285 | ||
@@ -366,8 +375,15 @@ void settings_load(void) | |||
366 | if ( global_settings.contrast < MIN_CONTRAST_SETTING ) | 375 | if ( global_settings.contrast < MIN_CONTRAST_SETTING ) |
367 | global_settings.contrast = DEFAULT_CONTRAST_SETTING; | 376 | global_settings.contrast = DEFAULT_CONTRAST_SETTING; |
368 | } | 377 | } |
378 | #ifdef HAVE_CHARGE_CTRL | ||
379 | if (config_block[0xb] != 0xFF) { | ||
380 | global_settings.backlight_timeout = config_block[0xb] & 127; | ||
381 | global_settings.backlight_on_when_charging = config_block[0xb] & 128 ? 1 : 0; | ||
382 | } | ||
383 | #else | ||
369 | if (config_block[0xb] != 0xFF) | 384 | if (config_block[0xb] != 0xFF) |
370 | global_settings.backlight = config_block[0xb]; | 385 | global_settings.backlight_timeout = config_block[0xb]; |
386 | #endif | ||
371 | if (config_block[0xc] != 0xFF) | 387 | if (config_block[0xc] != 0xFF) |
372 | global_settings.poweroff = config_block[0xc]; | 388 | global_settings.poweroff = config_block[0xc]; |
373 | if (config_block[0xd] != 0xFF) | 389 | if (config_block[0xd] != 0xFF) |
@@ -432,7 +448,10 @@ void settings_load(void) | |||
432 | } | 448 | } |
433 | lcd_set_contrast(global_settings.contrast); | 449 | lcd_set_contrast(global_settings.contrast); |
434 | lcd_scroll_speed(global_settings.scroll_speed); | 450 | lcd_scroll_speed(global_settings.scroll_speed); |
435 | backlight_time(global_settings.backlight); | 451 | backlight_set_timeout(global_settings.backlight_timeout); |
452 | #ifdef HAVE_CHARGE_CTRL | ||
453 | backlight_set_on_when_charging(global_settings.backlight_on_when_charging); | ||
454 | #endif | ||
436 | ata_spindown(global_settings.disk_spindown); | 455 | ata_spindown(global_settings.disk_spindown); |
437 | set_poweroff_timeout(global_settings.poweroff); | 456 | set_poweroff_timeout(global_settings.poweroff); |
438 | #ifdef HAVE_CHARGE_CTRL | 457 | #ifdef HAVE_CHARGE_CTRL |
@@ -615,7 +634,10 @@ void settings_reset(void) { | |||
615 | global_settings.resume = RESUME_ASK; | 634 | global_settings.resume = RESUME_ASK; |
616 | global_settings.contrast = DEFAULT_CONTRAST_SETTING; | 635 | global_settings.contrast = DEFAULT_CONTRAST_SETTING; |
617 | global_settings.poweroff = DEFAULT_POWEROFF_SETTING; | 636 | global_settings.poweroff = DEFAULT_POWEROFF_SETTING; |
618 | global_settings.backlight = DEFAULT_BACKLIGHT_SETTING; | 637 | global_settings.backlight_timeout = DEFAULT_BACKLIGHT_TIMEOUT_SETTING; |
638 | #ifdef HAVE_CHARGE_CTRL | ||
639 | global_settings.backlight_on_when_charging = DEFAULT_BACKLIGHT_ON_WHEN_CHARGING_SETTING; | ||
640 | #endif | ||
619 | global_settings.dirfilter = SHOW_MUSIC; | 641 | global_settings.dirfilter = SHOW_MUSIC; |
620 | global_settings.sort_case = false; | 642 | global_settings.sort_case = false; |
621 | global_settings.statusbar = true; | 643 | global_settings.statusbar = true; |
@@ -654,10 +676,10 @@ void settings_display(void) | |||
654 | global_settings.loudness, | 676 | global_settings.loudness, |
655 | global_settings.bass_boost ); | 677 | global_settings.bass_boost ); |
656 | 678 | ||
657 | DEBUGF( "contrast:\t%d\npoweroff:\t%d\nbacklight:\t%d\n", | 679 | DEBUGF( "contrast:\t%d\npoweroff:\t%d\nbacklight_timeout:\t%d\n", |
658 | global_settings.contrast, | 680 | global_settings.contrast, |
659 | global_settings.poweroff, | 681 | global_settings.poweroff, |
660 | global_settings.backlight ); | 682 | global_settings.backlight_timeout ); |
661 | #endif | 683 | #endif |
662 | } | 684 | } |
663 | 685 | ||
diff --git a/apps/settings.h b/apps/settings.h index bbc7bb3dcc..eed0b61c20 100644 --- a/apps/settings.h +++ b/apps/settings.h | |||
@@ -63,7 +63,10 @@ struct user_settings | |||
63 | 63 | ||
64 | int contrast; /* lcd contrast: 0-100 0=low 100=high */ | 64 | int contrast; /* lcd contrast: 0-100 0=low 100=high */ |
65 | int poweroff; /* power off timer */ | 65 | int poweroff; /* power off timer */ |
66 | int backlight; /* backlight off timer: 0-100 0=never:each 1% = 10 secs */ | 66 | int backlight_timeout; /* backlight off timeout: 0-18 0=never,1=always,then according to timeout_values[] */ |
67 | #ifdef HAVE_CHARGE_CTRL | ||
68 | bool backlight_on_when_charging; | ||
69 | #endif | ||
67 | bool discharge; /* maintain charge of at least: false = 90%, true = 10% */ | 70 | bool discharge; /* maintain charge of at least: false = 90%, true = 10% */ |
68 | 71 | ||
69 | /* resume settings */ | 72 | /* resume settings */ |
@@ -144,7 +147,8 @@ extern char rockboxdir[]; | |||
144 | #endif | 147 | #endif |
145 | #define MIN_CONTRAST_SETTING 5 | 148 | #define MIN_CONTRAST_SETTING 5 |
146 | #define DEFAULT_POWEROFF_SETTING 0 | 149 | #define DEFAULT_POWEROFF_SETTING 0 |
147 | #define DEFAULT_BACKLIGHT_SETTING 5 | 150 | #define DEFAULT_BACKLIGHT_TIMEOUT_SETTING 5 |
151 | #define DEFAULT_BACKLIGHT_ON_WHEN_CHARGING_SETTING 0 | ||
148 | #define DEFAULT_FF_REWIND_MIN_STEP FF_REWIND_1000 | 152 | #define DEFAULT_FF_REWIND_MIN_STEP FF_REWIND_1000 |
149 | #define DEFAULT_FF_REWIND_ACCEL_SETTING 3 | 153 | #define DEFAULT_FF_REWIND_ACCEL_SETTING 3 |
150 | 154 | ||
diff --git a/apps/settings_menu.c b/apps/settings_menu.c index 3cb270dafe..4e521bca84 100644 --- a/apps/settings_menu.c +++ b/apps/settings_menu.c | |||
@@ -144,6 +144,16 @@ static bool resume(void) | |||
144 | names, 3, NULL ); | 144 | names, 3, NULL ); |
145 | } | 145 | } |
146 | 146 | ||
147 | #ifdef HAVE_CHARGE_CTRL | ||
148 | static bool backlight_on_when_charging(void) | ||
149 | { | ||
150 | bool result = set_bool(str(LANG_BACKLIGHT_ON_WHEN_CHARGING), | ||
151 | &global_settings.backlight_on_when_charging); | ||
152 | backlight_set_on_when_charging(global_settings.backlight_on_when_charging); | ||
153 | return result; | ||
154 | } | ||
155 | #endif | ||
156 | |||
147 | static bool backlight_timer(void) | 157 | static bool backlight_timer(void) |
148 | { | 158 | { |
149 | char* names[] = { str(LANG_OFF), str(LANG_ON), | 159 | char* names[] = { str(LANG_OFF), str(LANG_ON), |
@@ -151,8 +161,8 @@ static bool backlight_timer(void) | |||
151 | "6s ", "7s ", "8s ", "9s ", "10s", | 161 | "6s ", "7s ", "8s ", "9s ", "10s", |
152 | "15s", "20s", "25s", "30s", "45s", | 162 | "15s", "20s", "25s", "30s", "45s", |
153 | "60s", "90s"}; | 163 | "60s", "90s"}; |
154 | return set_option(str(LANG_BACKLIGHT), &global_settings.backlight, | 164 | return set_option(str(LANG_BACKLIGHT), &global_settings.backlight_timeout, |
155 | names, 19, backlight_time ); | 165 | names, 19, backlight_set_timeout ); |
156 | } | 166 | } |
157 | 167 | ||
158 | static bool poweroff_idle_timer(void) | 168 | static bool poweroff_idle_timer(void) |
@@ -377,6 +387,9 @@ static bool display_settings_menu(void) | |||
377 | struct menu_items items[] = { | 387 | struct menu_items items[] = { |
378 | { str(LANG_SCROLL_MENU), scroll_speed }, | 388 | { str(LANG_SCROLL_MENU), scroll_speed }, |
379 | { str(LANG_BACKLIGHT), backlight_timer }, | 389 | { str(LANG_BACKLIGHT), backlight_timer }, |
390 | #ifdef HAVE_CHARGE_CTRL | ||
391 | { str(LANG_BACKLIGHT_ON_WHEN_CHARGING), backlight_on_when_charging }, | ||
392 | #endif | ||
380 | { str(LANG_CONTRAST), contrast }, | 393 | { str(LANG_CONTRAST), contrast }, |
381 | #ifdef HAVE_LCD_BITMAP | 394 | #ifdef HAVE_LCD_BITMAP |
382 | { str(LANG_PM_MENU), peak_meter_menu }, | 395 | { str(LANG_PM_MENU), peak_meter_menu }, |
diff --git a/firmware/backlight.c b/firmware/backlight.c index 4dcdea917c..8a7c4ceb76 100644 --- a/firmware/backlight.c +++ b/firmware/backlight.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include "debug.h" | 25 | #include "debug.h" |
26 | #include "rtc.h" | 26 | #include "rtc.h" |
27 | #include "usb.h" | 27 | #include "usb.h" |
28 | #include "power.h" | ||
28 | 29 | ||
29 | #define BACKLIGHT_ON 1 | 30 | #define BACKLIGHT_ON 1 |
30 | #define BACKLIGHT_OFF 2 | 31 | #define BACKLIGHT_OFF 2 |
@@ -34,6 +35,11 @@ static char backlight_stack[DEFAULT_STACK_SIZE]; | |||
34 | static char backlight_thread_name[] = "backlight"; | 35 | static char backlight_thread_name[] = "backlight"; |
35 | static struct event_queue backlight_queue; | 36 | static struct event_queue backlight_queue; |
36 | 37 | ||
38 | #ifdef HAVE_CHARGE_CTRL | ||
39 | static bool charger_was_inserted = 0; | ||
40 | static bool backlight_on_when_charging = 0; | ||
41 | #endif | ||
42 | |||
37 | static int backlight_timer; | 43 | static int backlight_timer; |
38 | static int backlight_timeout = 5; | 44 | static int backlight_timeout = 5; |
39 | 45 | ||
@@ -52,9 +58,22 @@ void backlight_thread(void) | |||
52 | switch(ev.id) | 58 | switch(ev.id) |
53 | { | 59 | { |
54 | case BACKLIGHT_ON: | 60 | case BACKLIGHT_ON: |
61 | #ifdef HAVE_CHARGE_CTRL | ||
62 | if( backlight_on_when_charging && charger_inserted() ) | ||
63 | { | ||
64 | /* Forcing to zero keeps the lights on */ | ||
65 | backlight_timer = 0; | ||
66 | } | ||
67 | else | ||
68 | { | ||
69 | backlight_timer = HZ*timeout_value[backlight_timeout]; | ||
70 | } | ||
71 | #else | ||
55 | backlight_timer = HZ*timeout_value[backlight_timeout]; | 72 | backlight_timer = HZ*timeout_value[backlight_timeout]; |
73 | #endif | ||
56 | if(backlight_timer < 0) | 74 | if(backlight_timer < 0) |
57 | { | 75 | { |
76 | backlight_timer = 0; /* timer value 0 will not get ticked */ | ||
58 | #ifdef HAVE_RTC | 77 | #ifdef HAVE_RTC |
59 | /* Disable square wave */ | 78 | /* Disable square wave */ |
60 | rtc_write(0x0a, rtc_read(0x0a) & ~0x40); | 79 | rtc_write(0x0a, rtc_read(0x0a) & ~0x40); |
@@ -62,7 +81,8 @@ void backlight_thread(void) | |||
62 | PADR |= 0x4000; | 81 | PADR |= 0x4000; |
63 | #endif | 82 | #endif |
64 | } | 83 | } |
65 | else if(backlight_timer) | 84 | /* else if(backlight_timer) */ |
85 | else | ||
66 | { | 86 | { |
67 | #ifdef HAVE_RTC | 87 | #ifdef HAVE_RTC |
68 | /* Enable square wave */ | 88 | /* Enable square wave */ |
@@ -105,14 +125,28 @@ void backlight_off(void) | |||
105 | queue_post(&backlight_queue, BACKLIGHT_OFF, NULL); | 125 | queue_post(&backlight_queue, BACKLIGHT_OFF, NULL); |
106 | } | 126 | } |
107 | 127 | ||
108 | void backlight_time(int value) | 128 | void backlight_set_timeout(int seconds) |
129 | { | ||
130 | backlight_timeout = seconds; | ||
131 | backlight_on(); | ||
132 | } | ||
133 | |||
134 | void backlight_set_on_when_charging(bool yesno) | ||
109 | { | 135 | { |
110 | backlight_timeout = value; | 136 | backlight_on_when_charging = yesno; |
111 | backlight_on(); | 137 | backlight_on(); |
112 | } | 138 | } |
113 | 139 | ||
114 | void backlight_tick(void) | 140 | void backlight_tick(void) |
115 | { | 141 | { |
142 | #ifdef HAVE_CHARGE_CTRL | ||
143 | bool charger_is_inserted = charger_inserted(); | ||
144 | if( backlight_on_when_charging && (charger_was_inserted != charger_is_inserted) ) | ||
145 | { | ||
146 | backlight_on(); | ||
147 | } | ||
148 | charger_was_inserted = charger_is_inserted; | ||
149 | #endif | ||
116 | if(backlight_timer) | 150 | if(backlight_timer) |
117 | { | 151 | { |
118 | backlight_timer--; | 152 | backlight_timer--; |
diff --git a/firmware/backlight.h b/firmware/backlight.h index dca1f214f3..77049e3ce8 100644 --- a/firmware/backlight.h +++ b/firmware/backlight.h | |||
@@ -23,6 +23,7 @@ void backlight_init(void); | |||
23 | void backlight_on(void); | 23 | void backlight_on(void); |
24 | void backlight_off(void); | 24 | void backlight_off(void); |
25 | void backlight_tick(void); | 25 | void backlight_tick(void); |
26 | void backlight_time(int seconds); | 26 | void backlight_set_timeout(int seconds); |
27 | void backlight_set_on_when_charging(bool yesno); | ||
27 | 28 | ||
28 | #endif | 29 | #endif |
diff --git a/uisimulator/common/stubs.c b/uisimulator/common/stubs.c index 3534497e45..98e1f75182 100644 --- a/uisimulator/common/stubs.c +++ b/uisimulator/common/stubs.c | |||
@@ -123,3 +123,8 @@ void lcd_set_contrast( int x ) | |||
123 | { | 123 | { |
124 | (void)x; | 124 | (void)x; |
125 | } | 125 | } |
126 | |||
127 | void backlight_set_timeout(int seconds) | ||
128 | { | ||
129 | (void)seconds; | ||
130 | } | ||