New option: Invert display. Patch by Mark Hillebrand.


git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3355 a1c6a512-1295-4272-9138-f99709370657
diff --git a/apps/lang/english.lang b/apps/lang/english.lang
index a3b9848..62cf492 100644
--- a/apps/lang/english.lang
+++ b/apps/lang/english.lang
@@ -1404,3 +1404,8 @@
 desc: how to undo move 
 eng: "[ON] To Undo"
 new:
+
+id: LANG_INVERT
+desc: in settings_menu
+eng: "Invert"
+new:
diff --git a/apps/settings.c b/apps/settings.c
index 2bb2e97..7019319 100644
--- a/apps/settings.c
+++ b/apps/settings.c
@@ -82,7 +82,7 @@
 0x07    0x1b    <treble byte>
 0x08    0x1c    <loudness byte>
 0x09    0x1d    <bass boost byte>
-0x0a    0x1e    <contrast byte>
+0x0a    0x1e    <contrast (bit 0-5), invert bit (bit 6)>
 0x0b    0x1f    <backlight_on_when_charging, backlight_timeout>
 0x0c    0x20    <poweroff timer byte>
 0x0d    0x21    <resume settings byte>
@@ -297,7 +297,9 @@
     config_block[0x8] = (unsigned char)global_settings.loudness;
     config_block[0x9] = (unsigned char)global_settings.bass_boost;
     
-    config_block[0xa] = (unsigned char)global_settings.contrast;
+    config_block[0xa] = (unsigned char)
+      ((global_settings.contrast & 0x3f) |
+       (global_settings.invert ? 0x40 : 0));
 
     config_block[0xb] = (unsigned char)
         ((global_settings.backlight_on_when_charging?0x40:0) |
@@ -482,6 +484,7 @@
     set_battery_capacity(global_settings.battery_capacity);
 
 #ifdef HAVE_LCD_BITMAP
+    lcd_set_invert_display(global_settings.invert);
     settings_apply_pm_range();
     peak_meter_init_times(
         global_settings.peak_meter_release, global_settings.peak_meter_hold, 
@@ -550,7 +553,9 @@
             global_settings.bass_boost = config_block[0x9];
     
         if (config_block[0xa] != 0xFF) {
-            global_settings.contrast = config_block[0xa];
+            global_settings.contrast = config_block[0xa] & 0x3f;
+            global_settings.invert =
+                config_block[0xa] & 0x40 ? true : false;
             if ( global_settings.contrast < MIN_CONTRAST_SETTING )
                 global_settings.contrast = DEFAULT_CONTRAST_SETTING;
         }
@@ -1066,6 +1071,7 @@
     global_settings.rec_right_gain = 2; /* 0dB */
     global_settings.resume      = RESUME_ASK;
     global_settings.contrast    = DEFAULT_CONTRAST_SETTING;
+    global_settings.invert      = DEFAULT_INVERT_SETTING;
     global_settings.poweroff    = DEFAULT_POWEROFF_SETTING;
     global_settings.backlight_timeout   = DEFAULT_BACKLIGHT_TIMEOUT_SETTING;
     global_settings.backlight_on_when_charging   = 
@@ -1132,8 +1138,9 @@
             global_settings.loudness,
             global_settings.bass_boost );
 
-    DEBUGF( "contrast:\t%d\npoweroff:\t%d\nbacklight_timeout:\t%d\n",
+    DEBUGF( "contrast:\t%d\ninvert:\t%d\npoweroff:\t%d\nbacklight_timeout:\t%d\n",
             global_settings.contrast,
+            global_settings.invert,
             global_settings.poweroff,
             global_settings.backlight_timeout );
 #endif
diff --git a/apps/settings.h b/apps/settings.h
index 6f127e0..6c383f9 100644
--- a/apps/settings.h
+++ b/apps/settings.h
@@ -77,7 +77,8 @@
     
     /* device settings */
 
-    int contrast;   /* lcd contrast:         0-100 0=low 100=high            */
+    int contrast;   /* lcd contrast:          0-63 0=low 63=high            */
+    bool invert;    /* invert display */
     int poweroff;   /* power off timer */
     int backlight_timeout;  /* backlight off timeout:  0-18 0=never,
                                1=always,
@@ -189,6 +190,7 @@
 #define DEFAULT_CONTRAST_SETTING    38
 #endif
 #define MIN_CONTRAST_SETTING        5
+#define DEFAULT_INVERT_SETTING    false
 #define DEFAULT_POWEROFF_SETTING    0
 #define DEFAULT_BACKLIGHT_TIMEOUT_SETTING   5
 #define DEFAULT_BACKLIGHT_ON_WHEN_CHARGING_SETTING   0
diff --git a/apps/settings_menu.c b/apps/settings_menu.c
index e931fe6..d82053c 100644
--- a/apps/settings_menu.c
+++ b/apps/settings_menu.c
@@ -51,6 +51,15 @@
 
 #ifdef HAVE_LCD_BITMAP
 
+static bool invert(void)
+{
+    char* names[] = { str(LANG_SET_BOOL_NO), 
+                      str(LANG_SET_BOOL_YES) };
+
+    return set_option( str(LANG_INVERT), &global_settings.invert,
+                       names, 2, lcd_set_invert_display );
+}
+
 /**
  * Menu to configure the battery display on status bar
  */
@@ -724,6 +733,7 @@
         { str(LANG_BACKLIGHT_ON_WHEN_CHARGING), backlight_on_when_charging },
         { str(LANG_CONTRAST),        contrast        },  
 #ifdef HAVE_LCD_BITMAP
+        { str(LANG_INVERT),          invert },
         { str(LANG_PM_MENU),         peak_meter_menu },  
         { str(LANG_VOLUME_DISPLAY),  volume_type },
         { str(LANG_BATTERY_DISPLAY), battery_type },
diff --git a/firmware/drivers/lcd-recorder.c b/firmware/drivers/lcd-recorder.c
index 26112e3..6665ea8 100644
--- a/firmware/drivers/lcd-recorder.c
+++ b/firmware/drivers/lcd-recorder.c
@@ -194,6 +194,14 @@
     lcd_write(true, val);
 }
 
+void lcd_set_invert_display(bool yesno)
+{
+    if (yesno) 
+        lcd_write(true, LCD_SET_REVERSE_DISPLAY);
+    else 
+        lcd_write(true, LCD_SET_NORMAL_DISPLAY);
+}
+
 /**
  * Rolls up the lcd display by the specified amount of lines.
  * Lines that are rolled out over the top of the screen are
diff --git a/firmware/export/lcd.h b/firmware/export/lcd.h
index 6149dc3..74bbcc3 100644
--- a/firmware/export/lcd.h
+++ b/firmware/export/lcd.h
@@ -122,7 +122,7 @@
 extern void lcd_clearpixel(int x, int y);
 extern void lcd_invertpixel(int x, int y);
 extern void lcd_roll(int pixels);
-
+extern void lcd_set_invert_display(bool yesno);
 extern void lcd_bidir_scroll(int threshold);
 extern void lcd_scroll_step(int pixels);
 extern void lcd_setfont(int font);