dont show display contrast setting in display setup when a oled is detected
[enigma2.git] / lib / python / Components / Lcd.py
index 552d548..eb3e3df 100644 (file)
@@ -1,36 +1,34 @@
-from config import config                              #global config instance
-from config import ConfigSlider
-from config import configSelection
-from config import ConfigSubsection
-from config import configElement
+from config import config, ConfigSubsection, ConfigSlider, ConfigYesNo, ConfigNothing
 
-from enigma import *
+from enigma import eDBoxLCD
 
 class LCD:
        def __init__(self):
                pass
 
        def setBright(self, value):
-               eDBoxLCD.getInstance().setLCDBrightness(value * 20)
-               pass
+               value *= 255
+               value /= 10
+               if value > 255:
+                       value = 255
+               eDBoxLCD.getInstance().setLCDBrightness(value)
 
        def setContrast(self, value):
+               value *= 63
+               value /= 20
+               if value > 63:
+                       value = 63
                eDBoxLCD.getInstance().setLCDContrast(value)
-               pass
 
        def setInverted(self, value):
                if value:
                        value = 255
                eDBoxLCD.getInstance().setInverted(value)
 
-def InitLcd():
-       config.lcd = ConfigSubsection();
-       config.lcd.bright = configElement("config.lcd.bright", ConfigSlider, 10, "")
-       config.lcd.contrast = configElement("config.lcd.contrast", ConfigSlider, 10, "")
-       config.lcd.standby = configElement("config.lcd.standby", ConfigSlider, 0, "")
-       config.lcd.invert = configElement("config.lcd.invert", configSelection, 0, (("disable", _("Disable")), ("enable", _("Enable"))))
+       def isOled(self):
+               return eDBoxLCD.getInstance().isOled()
 
-       ilcd = LCD()
+def InitLcd():
 
        def setLCDbright(configElement):
                ilcd.setBright(configElement.value);
@@ -41,9 +39,22 @@ def InitLcd():
        def setLCDinverted(configElement):
                ilcd.setInverted(configElement.value);
 
+       ilcd = LCD()
+
+       config.lcd = ConfigSubsection();
+
+       config.lcd.bright = ConfigSlider(default=10, limits=(0, 10))
        config.lcd.bright.addNotifier(setLCDbright);
-       config.lcd.contrast.addNotifier(setLCDcontrast);
-       config.lcd.invert.addNotifier(setLCDinverted);
-       
+       config.lcd.bright.apply = lambda : setLCDbright(config.lcd.bright)
 
-       
+       if not ilcd.isOled():
+               config.lcd.contrast = ConfigSlider(default=5, limits=(0, 20))
+               config.lcd.contrast.addNotifier(setLCDcontrast);
+       else:
+               config.lcd.contrast = ConfigNothing()
+
+       config.lcd.standby = ConfigSlider(default=0, limits=(0, 10))
+       config.lcd.standby.apply = lambda : setLCDbright(config.lcd.standby)
+
+       config.lcd.invert = ConfigYesNo(default=False)
+       config.lcd.invert.addNotifier(setLCDinverted);