deliver service events only to last created class which is based on
[enigma2.git] / lib / python / Components / Lcd.py
index c14a8f8688dc031418f40965f850dfe94da64b48..0471843cb7c428fe2150d299fb9dd8af620f4fab 100644 (file)
@@ -1,49 +1,69 @@
-from config import config                              #global config instance
-from config import ConfigSlider
-from config import configSelection
-from config import ConfigSubsection
-from config import configElement
-
-from enigma import *
+from config import config, ConfigSubsection, ConfigSlider, ConfigYesNo, ConfigNothing
+from enigma import eDBoxLCD
+from Components.SystemInfo import SystemInfo
 
 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 isOled(self):
+               return eDBoxLCD.getInstance().isOled()
+
 def InitLcd():
+       detected = eDBoxLCD.getInstance().detected()
+       SystemInfo["Display"] = detected
        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, (("enable", _("Enable")), ("disable", _("Disable"))))
+       if detected:
+               def setLCDbright(configElement):
+                       ilcd.setBright(configElement.value);
+
+               def setLCDcontrast(configElement):
+                       ilcd.setContrast(configElement.value);
 
-       ilcd = LCD()
+               def setLCDinverted(configElement):
+                       ilcd.setInverted(configElement.value);
 
-       def setLCDbright(configElement):
-               ilcd.setBright(configElement.value);
+               ilcd = LCD()
 
-       def setLCDcontrast(configElement):
-               ilcd.setContrast(configElement.value);
+               config.lcd.bright = ConfigSlider(default=10, limits=(0, 10))
+               config.lcd.bright.addNotifier(setLCDbright);
+               config.lcd.bright.apply = lambda : setLCDbright(config.lcd.bright)
 
-       def setLCDinverted(configElement):
-               ilcd.setInverted(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()
 
-       config.lcd.bright.addNotifier(setLCDbright);
-       config.lcd.contrast.addNotifier(setLCDcontrast);
-       config.lcd.invert.addNotifier(setLCDinverted);
-       
+               config.lcd.standby = ConfigSlider(default=0, limits=(0, 10))
+               config.lcd.standby.apply = lambda : setLCDbright(config.lcd.standby)
 
-       
\ No newline at end of file
+               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()