diff options
author | Hristo Kovachev <bger@rockbox.org> | 2005-12-22 10:43:36 +0000 |
---|---|---|
committer | Hristo Kovachev <bger@rockbox.org> | 2005-12-22 10:43:36 +0000 |
commit | 9b83c6c4bddca41411d31b8aab17ecc577b37eb4 (patch) | |
tree | 3311cff5a451e4462e02feffdfe4ddc610eeb6e5 | |
parent | 9d67765cae62e873c3d004bf9bcb68947f1568f6 (diff) | |
download | rockbox-9b83c6c4bddca41411d31b8aab17ecc577b37eb4.tar.gz rockbox-9b83c6c4bddca41411d31b8aab17ecc577b37eb4.zip |
Patch No 1387627 by Peter D'Hoye: Backlight Brightness setting for H300
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@8280 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | apps/lang/english.lang | 7 | ||||
-rw-r--r-- | apps/settings.c | 7 | ||||
-rw-r--r-- | apps/settings.h | 9 | ||||
-rw-r--r-- | apps/settings_menu.c | 13 | ||||
-rw-r--r-- | firmware/backlight.c | 14 | ||||
-rw-r--r-- | firmware/drivers/pcf50606.c | 21 | ||||
-rw-r--r-- | firmware/export/backlight.h | 4 | ||||
-rw-r--r-- | firmware/export/config-h300.h | 2 | ||||
-rw-r--r-- | firmware/export/pcf50606.h | 1 |
9 files changed, 77 insertions, 1 deletions
diff --git a/apps/lang/english.lang b/apps/lang/english.lang index 1f0ef87ca4..08060fffd6 100644 --- a/apps/lang/english.lang +++ b/apps/lang/english.lang | |||
@@ -3550,3 +3550,10 @@ desc: in radio screen / menu | |||
3550 | eng: "Mode:" | 3550 | eng: "Mode:" |
3551 | voice: "" | 3551 | voice: "" |
3552 | new: | 3552 | new: |
3553 | |||
3554 | id: LANG_BRIGHTNESS | ||
3555 | desc: in settings_menu | ||
3556 | eng: "Brightness" | ||
3557 | voice: "Brightness" | ||
3558 | new: | ||
3559 | |||
diff --git a/apps/settings.c b/apps/settings.c index 22bfc9b60f..118692afe4 100644 --- a/apps/settings.c +++ b/apps/settings.c | |||
@@ -488,6 +488,10 @@ static const struct bit_entry hd_bits[] = | |||
488 | #endif | 488 | #endif |
489 | {4, S_O(default_codepage), 0, "default codepage", "iso8859-1,iso8859-7,iso8859-8,cp1251,iso8859-11,iso8859-6,iso8859-9,iso8859-2,sjis,gb2312,ksx1001,big5,utf-8" }, | 489 | {4, S_O(default_codepage), 0, "default codepage", "iso8859-1,iso8859-7,iso8859-8,cp1251,iso8859-11,iso8859-6,iso8859-9,iso8859-2,sjis,gb2312,ksx1001,big5,utf-8" }, |
490 | 490 | ||
491 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
492 | {4, S_O(brightness), 9, "brightness", "2,3,4,5,6,7,8,9,10,11,12,13,14,15"}, | ||
493 | #endif | ||
494 | |||
491 | /* If values are just added to the end, no need to bump the version. */ | 495 | /* If values are just added to the end, no need to bump the version. */ |
492 | /* new stuff to be added at the end */ | 496 | /* new stuff to be added at the end */ |
493 | 497 | ||
@@ -892,6 +896,9 @@ void settings_apply(void) | |||
892 | backlight_set_fade_out(global_settings.backlight_fade_out); | 896 | backlight_set_fade_out(global_settings.backlight_fade_out); |
893 | #endif | 897 | #endif |
894 | #endif | 898 | #endif |
899 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
900 | backlight_set_brightness(global_settings.brightness); | ||
901 | #endif | ||
895 | ata_spindown(global_settings.disk_spindown); | 902 | ata_spindown(global_settings.disk_spindown); |
896 | #if (CONFIG_CODEC == MAS3507D) && !defined(SIMULATOR) | 903 | #if (CONFIG_CODEC == MAS3507D) && !defined(SIMULATOR) |
897 | dac_line_in(global_settings.line_in); | 904 | dac_line_in(global_settings.line_in); |
diff --git a/apps/settings.h b/apps/settings.h index 7378f1daeb..870d9efdd7 100644 --- a/apps/settings.h +++ b/apps/settings.h | |||
@@ -381,6 +381,10 @@ struct user_settings | |||
381 | #ifdef HAVE_REMOTE_LCD | 381 | #ifdef HAVE_REMOTE_LCD |
382 | unsigned char rwps_file[MAX_FILENAME+1]; /* last remote-wps */ | 382 | unsigned char rwps_file[MAX_FILENAME+1]; /* last remote-wps */ |
383 | #endif | 383 | #endif |
384 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
385 | int brightness; /* iriver h300: backlight PWM value: 2..15 | ||
386 | (0 and 1 are black) */ | ||
387 | #endif | ||
384 | }; | 388 | }; |
385 | 389 | ||
386 | enum optiontype { INT, BOOL }; | 390 | enum optiontype { INT, BOOL }; |
@@ -442,6 +446,11 @@ extern const char rec_base_directory[]; | |||
442 | #endif | 446 | #endif |
443 | #define MIN_CONTRAST_SETTING 5 | 447 | #define MIN_CONTRAST_SETTING 5 |
444 | 448 | ||
449 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
450 | #define MIN_BRIGHTNESS_SETTING 2 | ||
451 | #define MAX_BRIGHTNESS_SETTING 15 | ||
452 | #endif | ||
453 | |||
445 | /* argument bits for settings_load() */ | 454 | /* argument bits for settings_load() */ |
446 | #define SETTINGS_RTC 1 /* only the settings from the RTC nonvolatile RAM */ | 455 | #define SETTINGS_RTC 1 /* only the settings from the RTC nonvolatile RAM */ |
447 | #define SETTINGS_HD 2 /* only the settings fron the disk sector */ | 456 | #define SETTINGS_HD 2 /* only the settings fron the disk sector */ |
diff --git a/apps/settings_menu.c b/apps/settings_menu.c index fc5d75e431..5338be34a3 100644 --- a/apps/settings_menu.c +++ b/apps/settings_menu.c | |||
@@ -214,6 +214,16 @@ static bool backlight_fade_out(void) | |||
214 | #endif | 214 | #endif |
215 | #endif /* CONFIG_BACKLIGHT */ | 215 | #endif /* CONFIG_BACKLIGHT */ |
216 | 216 | ||
217 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
218 | static bool brightness(void) | ||
219 | { | ||
220 | return set_int( str(LANG_BRIGHTNESS), "", UNIT_INT, | ||
221 | &global_settings.brightness, | ||
222 | backlight_set_brightness, 1, MIN_BRIGHTNESS_SETTING, | ||
223 | MAX_BRIGHTNESS_SETTING, NULL ); | ||
224 | } | ||
225 | #endif | ||
226 | |||
217 | #ifdef HAVE_REMOTE_LCD | 227 | #ifdef HAVE_REMOTE_LCD |
218 | 228 | ||
219 | static bool remote_backlight_timer(void) | 229 | static bool remote_backlight_timer(void) |
@@ -1525,6 +1535,9 @@ static bool lcd_settings_menu(void) | |||
1525 | { ID2P(LANG_BACKLIGHT_FADE_IN), backlight_fade_in }, | 1535 | { ID2P(LANG_BACKLIGHT_FADE_IN), backlight_fade_in }, |
1526 | { ID2P(LANG_BACKLIGHT_FADE_OUT), backlight_fade_out }, | 1536 | { ID2P(LANG_BACKLIGHT_FADE_OUT), backlight_fade_out }, |
1527 | #endif | 1537 | #endif |
1538 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
1539 | { ID2P(LANG_BRIGHTNESS), brightness }, | ||
1540 | #endif | ||
1528 | #endif /* CONFIG_BACKLIGHT */ | 1541 | #endif /* CONFIG_BACKLIGHT */ |
1529 | { ID2P(LANG_CONTRAST), contrast }, | 1542 | { ID2P(LANG_CONTRAST), contrast }, |
1530 | #ifdef HAVE_LCD_BITMAP | 1543 | #ifdef HAVE_LCD_BITMAP |
diff --git a/firmware/backlight.c b/firmware/backlight.c index 291c5da8e7..d118830721 100644 --- a/firmware/backlight.c +++ b/firmware/backlight.c | |||
@@ -30,6 +30,10 @@ | |||
30 | #include "timer.h" | 30 | #include "timer.h" |
31 | #include "backlight.h" | 31 | #include "backlight.h" |
32 | 32 | ||
33 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
34 | #include "pcf50606.h" /* iRiver brightness */ | ||
35 | #endif | ||
36 | |||
33 | #if CONFIG_BACKLIGHT == BL_IRIVER_H300 | 37 | #if CONFIG_BACKLIGHT == BL_IRIVER_H300 |
34 | #include "lcd.h" /* for lcd_enable() */ | 38 | #include "lcd.h" /* for lcd_enable() */ |
35 | #endif | 39 | #endif |
@@ -538,3 +542,13 @@ void remote_backlight_set_timeout(int index) {(void)index;} | |||
538 | #endif | 542 | #endif |
539 | #endif /* #ifdef CONFIG_BACKLIGHT */ | 543 | #endif /* #ifdef CONFIG_BACKLIGHT */ |
540 | 544 | ||
545 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
546 | void backlight_set_brightness(int val) | ||
547 | { | ||
548 | /* set H300 brightness by changing the PWM | ||
549 | accepts 0..15 but note that 0 and 1 give a black display! */ | ||
550 | unsigned char ucVal = (unsigned char)(val & 0x0F); | ||
551 | pcf50606_set_bl_pwm(ucVal); | ||
552 | } | ||
553 | #endif | ||
554 | |||
diff --git a/firmware/drivers/pcf50606.c b/firmware/drivers/pcf50606.c index b99b2e9e88..cb05d25345 100644 --- a/firmware/drivers/pcf50606.c +++ b/firmware/drivers/pcf50606.c | |||
@@ -44,6 +44,7 @@ | |||
44 | /* delay loop to achieve 400kHz at 120MHz CPU frequency */ | 44 | /* delay loop to achieve 400kHz at 120MHz CPU frequency */ |
45 | #define DELAY do { int _x; for(_x=0;_x<22;_x++);} while(0) | 45 | #define DELAY do { int _x; for(_x=0;_x<22;_x++);} while(0) |
46 | 46 | ||
47 | void pcf50606_set_bl_pwm(unsigned char ucVal); | ||
47 | 48 | ||
48 | static void pcf50606_i2c_start(void) | 49 | static void pcf50606_i2c_start(void) |
49 | { | 50 | { |
@@ -281,5 +282,23 @@ void pcf50606_init(void) | |||
281 | set_voltages(); | 282 | set_voltages(); |
282 | 283 | ||
283 | /* Backlight PWM = 512Hz 50/50 */ | 284 | /* Backlight PWM = 512Hz 50/50 */ |
284 | pcf50606_write(0x35, 0x13); | 285 | /*pcf50606_write(0x35, 0x13);*/ |
286 | pcf50606_set_bl_pwm(9); | ||
287 | } | ||
288 | |||
289 | void pcf50606_set_bl_pwm(unsigned char ucVal) | ||
290 | { | ||
291 | /* set the backlight PWM */ | ||
292 | /* range is 0 - 15 */ | ||
293 | |||
294 | /* limit incoming value */ | ||
295 | ucVal = ucVal & 0x0F; | ||
296 | |||
297 | /* shift one bit left */ | ||
298 | ucVal = ucVal << 1; | ||
299 | ucVal = ucVal | 0x01; | ||
300 | |||
301 | /* 0x00 = 512Hz */ | ||
302 | ucVal = ucVal | 0x00; | ||
303 | pcf50606_write(0x35, ucVal); | ||
285 | } | 304 | } |
diff --git a/firmware/export/backlight.h b/firmware/export/backlight.h index 9c3f5aa90b..f4c62a2028 100644 --- a/firmware/export/backlight.h +++ b/firmware/export/backlight.h | |||
@@ -49,3 +49,7 @@ void sim_backlight(int value); | |||
49 | void sim_remote_backlight(int value); | 49 | void sim_remote_backlight(int value); |
50 | #endif | 50 | #endif |
51 | #endif | 51 | #endif |
52 | |||
53 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
54 | void backlight_set_brightness(int val); | ||
55 | #endif | ||
diff --git a/firmware/export/config-h300.h b/firmware/export/config-h300.h index 20e27c505b..54a2ef543f 100644 --- a/firmware/export/config-h300.h +++ b/firmware/export/config-h300.h | |||
@@ -100,4 +100,6 @@ | |||
100 | #define BOOTFILE_EXT "iriver" | 100 | #define BOOTFILE_EXT "iriver" |
101 | #define BOOTFILE "rockbox." BOOTFILE_EXT | 101 | #define BOOTFILE "rockbox." BOOTFILE_EXT |
102 | 102 | ||
103 | #define HAVE_BACKLIGHT_BRIGHTNESS | ||
104 | |||
103 | #endif | 105 | #endif |
diff --git a/firmware/export/pcf50606.h b/firmware/export/pcf50606.h index fd180bfaee..daacbac725 100644 --- a/firmware/export/pcf50606.h +++ b/firmware/export/pcf50606.h | |||
@@ -25,6 +25,7 @@ int pcf50606_write_multiple(int address, const unsigned char* buf, int count); | |||
25 | int pcf50606_write(int address, unsigned char val); | 25 | int pcf50606_write(int address, unsigned char val); |
26 | int pcf50606_read_multiple(int address, unsigned char* buf, int count); | 26 | int pcf50606_read_multiple(int address, unsigned char* buf, int count); |
27 | int pcf50606_read(int address); | 27 | int pcf50606_read(int address); |
28 | void pcf50606_set_bl_pwm(unsigned char ucVal); | ||
28 | #endif | 29 | #endif |
29 | 30 | ||
30 | #endif | 31 | #endif |