summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--apps/lang/english.lang7
-rw-r--r--apps/settings.c7
-rw-r--r--apps/settings.h9
-rw-r--r--apps/settings_menu.c13
-rw-r--r--firmware/backlight.c14
-rw-r--r--firmware/drivers/pcf50606.c21
-rw-r--r--firmware/export/backlight.h4
-rw-r--r--firmware/export/config-h300.h2
-rw-r--r--firmware/export/pcf50606.h1
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
eng: "Mode:"
voice: ""
new:
+
+id: LANG_BRIGHTNESS
+desc: in settings_menu
+eng: "Brightness"
+voice: "Brightness"
+new:
+
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[] =
#endif
{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" },
+#ifdef HAVE_BACKLIGHT_BRIGHTNESS
+ {4, S_O(brightness), 9, "brightness", "2,3,4,5,6,7,8,9,10,11,12,13,14,15"},
+#endif
+
/* If values are just added to the end, no need to bump the version. */
/* new stuff to be added at the end */
@@ -892,6 +896,9 @@ void settings_apply(void)
backlight_set_fade_out(global_settings.backlight_fade_out);
#endif
#endif
+#ifdef HAVE_BACKLIGHT_BRIGHTNESS
+ backlight_set_brightness(global_settings.brightness);
+#endif
ata_spindown(global_settings.disk_spindown);
#if (CONFIG_CODEC == MAS3507D) && !defined(SIMULATOR)
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
#ifdef HAVE_REMOTE_LCD
unsigned char rwps_file[MAX_FILENAME+1]; /* last remote-wps */
#endif
+#ifdef HAVE_BACKLIGHT_BRIGHTNESS
+ int brightness; /* iriver h300: backlight PWM value: 2..15
+ (0 and 1 are black) */
+#endif
};
enum optiontype { INT, BOOL };
@@ -442,6 +446,11 @@ extern const char rec_base_directory[];
#endif
#define MIN_CONTRAST_SETTING 5
+#ifdef HAVE_BACKLIGHT_BRIGHTNESS
+#define MIN_BRIGHTNESS_SETTING 2
+#define MAX_BRIGHTNESS_SETTING 15
+#endif
+
/* argument bits for settings_load() */
#define SETTINGS_RTC 1 /* only the settings from the RTC nonvolatile RAM */
#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)
#endif
#endif /* CONFIG_BACKLIGHT */
+#ifdef HAVE_BACKLIGHT_BRIGHTNESS
+static bool brightness(void)
+{
+ return set_int( str(LANG_BRIGHTNESS), "", UNIT_INT,
+ &global_settings.brightness,
+ backlight_set_brightness, 1, MIN_BRIGHTNESS_SETTING,
+ MAX_BRIGHTNESS_SETTING, NULL );
+}
+#endif
+
#ifdef HAVE_REMOTE_LCD
static bool remote_backlight_timer(void)
@@ -1525,6 +1535,9 @@ static bool lcd_settings_menu(void)
{ ID2P(LANG_BACKLIGHT_FADE_IN), backlight_fade_in },
{ ID2P(LANG_BACKLIGHT_FADE_OUT), backlight_fade_out },
#endif
+#ifdef HAVE_BACKLIGHT_BRIGHTNESS
+ { ID2P(LANG_BRIGHTNESS), brightness },
+#endif
#endif /* CONFIG_BACKLIGHT */
{ ID2P(LANG_CONTRAST), contrast },
#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 @@
#include "timer.h"
#include "backlight.h"
+#ifdef HAVE_BACKLIGHT_BRIGHTNESS
+#include "pcf50606.h" /* iRiver brightness */
+#endif
+
#if CONFIG_BACKLIGHT == BL_IRIVER_H300
#include "lcd.h" /* for lcd_enable() */
#endif
@@ -538,3 +542,13 @@ void remote_backlight_set_timeout(int index) {(void)index;}
#endif
#endif /* #ifdef CONFIG_BACKLIGHT */
+#ifdef HAVE_BACKLIGHT_BRIGHTNESS
+void backlight_set_brightness(int val)
+{
+ /* set H300 brightness by changing the PWM
+ accepts 0..15 but note that 0 and 1 give a black display! */
+ unsigned char ucVal = (unsigned char)(val & 0x0F);
+ pcf50606_set_bl_pwm(ucVal);
+}
+#endif
+
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 @@
/* delay loop to achieve 400kHz at 120MHz CPU frequency */
#define DELAY do { int _x; for(_x=0;_x<22;_x++);} while(0)
+void pcf50606_set_bl_pwm(unsigned char ucVal);
static void pcf50606_i2c_start(void)
{
@@ -281,5 +282,23 @@ void pcf50606_init(void)
set_voltages();
/* Backlight PWM = 512Hz 50/50 */
- pcf50606_write(0x35, 0x13);
+ /*pcf50606_write(0x35, 0x13);*/
+ pcf50606_set_bl_pwm(9);
+}
+
+void pcf50606_set_bl_pwm(unsigned char ucVal)
+{
+ /* set the backlight PWM */
+ /* range is 0 - 15 */
+
+ /* limit incoming value */
+ ucVal = ucVal & 0x0F;
+
+ /* shift one bit left */
+ ucVal = ucVal << 1;
+ ucVal = ucVal | 0x01;
+
+ /* 0x00 = 512Hz */
+ ucVal = ucVal | 0x00;
+ pcf50606_write(0x35, ucVal);
}
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);
void sim_remote_backlight(int value);
#endif
#endif
+
+#ifdef HAVE_BACKLIGHT_BRIGHTNESS
+void backlight_set_brightness(int val);
+#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 @@
#define BOOTFILE_EXT "iriver"
#define BOOTFILE "rockbox." BOOTFILE_EXT
+#define HAVE_BACKLIGHT_BRIGHTNESS
+
#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);
int pcf50606_write(int address, unsigned char val);
int pcf50606_read_multiple(int address, unsigned char* buf, int count);
int pcf50606_read(int address);
+void pcf50606_set_bl_pwm(unsigned char ucVal);
#endif
#endif