Merge branch 'bug_293_indicate_unhandled_key' into experimental
[enigma2.git] / lib / python / Components / Lcd.py
index b043f393a636ac5464916ffe9ce517ddd3df074d..7d27c097ee9fd2c98a68c977a7711253f25d82be 100644 (file)
@@ -1,6 +1,6 @@
-from config import config, ConfigSubsection, ConfigSlider, ConfigYesNo
-
+from config import config, ConfigSubsection, ConfigSlider, ConfigYesNo, ConfigNothing
 from enigma import eDBoxLCD
+from Components.SystemInfo import SystemInfo
 
 class LCD:
        def __init__(self):
@@ -25,24 +25,50 @@ class LCD:
                        value = 255
                eDBoxLCD.getInstance().setInverted(value)
 
+       def isOled(self):
+               return eDBoxLCD.getInstance().isOled()
+
 def InitLcd():
+       detected = eDBoxLCD.getInstance().detected()
+       SystemInfo["Display"] = detected
        config.lcd = ConfigSubsection();
-       config.lcd.bright = ConfigSlider(default=10, limits=(0, 10))
-       config.lcd.contrast = ConfigSlider(default=5, limits=(0, 20))
-       config.lcd.standby = ConfigSlider(default=0, limits=(0, 10))
-       config.lcd.invert = ConfigYesNo(default=False)
+       if detected:
+               def setLCDbright(configElement):
+                       ilcd.setBright(configElement.value);
+
+               def setLCDcontrast(configElement):
+                       ilcd.setContrast(configElement.value);
+
+               def setLCDinverted(configElement):
+                       ilcd.setInverted(configElement.value);
+
+               standby_default = 0
 
-       ilcd = LCD()
+               ilcd = LCD()
 
-       def setLCDbright(configElement):
-               ilcd.setBright(configElement.value);
+               if not ilcd.isOled():
+                       config.lcd.contrast = ConfigSlider(default=5, limits=(0, 20))
+                       config.lcd.contrast.addNotifier(setLCDcontrast);
+               else:
+                       config.lcd.contrast = ConfigNothing()
+                       standby_default = 1
 
-       def setLCDcontrast(configElement):
-               ilcd.setContrast(configElement.value);
+               config.lcd.standby = ConfigSlider(default=standby_default, limits=(0, 10))
+               config.lcd.standby.addNotifier(setLCDbright);
+               config.lcd.standby.apply = lambda : setLCDbright(config.lcd.standby)
 
-       def setLCDinverted(configElement):
-               ilcd.setInverted(configElement.value);
+               config.lcd.bright = ConfigSlider(default=5, limits=(0, 10))
+               config.lcd.bright.addNotifier(setLCDbright);
+               config.lcd.bright.apply = lambda : setLCDbright(config.lcd.bright)
+               config.lcd.bright.callNotifiersOnSaveAndCancel = True
 
-       config.lcd.bright.addNotifier(setLCDbright);
-       config.lcd.contrast.addNotifier(setLCDcontrast);
-       config.lcd.invert.addNotifier(setLCDinverted);
+               config.lcd.invert = ConfigYesNo(default=False)
+               config.lcd.invert.addNotifier(setLCDinverted);
+       else:
+               def doNothing():
+                       pass
+               config.lcd.contrast = ConfigNothing()
+               config.lcd.bright = ConfigNothing()
+               config.lcd.standby = ConfigNothing()
+               config.lcd.bright.apply = lambda : doNothing()
+               config.lcd.standby.apply = lambda : doNothing()