cleanup lcd code
[enigma2.git] / lib / python / Components / Lcd.py
index 0471843cb7c428fe2150d299fb9dd8af620f4fab..dde158b6a16f4c1d97d697b312f12f239a7637bb 100644 (file)
@@ -28,6 +28,14 @@ class LCD:
        def isOled(self):
                return eDBoxLCD.getInstance().isOled()
 
+def leaveStandby():
+       config.lcd.bright.apply()
+
+def standbyCounterChanged(configElement):
+       from Screens.Standby import inStandby
+       inStandby.onClose.append(leaveStandby)
+       config.lcd.standby.apply()
+
 def InitLcd():
        detected = eDBoxLCD.getInstance().detected()
        SystemInfo["Display"] = detected
@@ -42,21 +50,26 @@ def InitLcd():
                def setLCDinverted(configElement):
                        ilcd.setInverted(configElement.value);
 
-               ilcd = LCD()
+               standby_default = 0
 
-               config.lcd.bright = ConfigSlider(default=10, limits=(0, 10))
-               config.lcd.bright.addNotifier(setLCDbright);
-               config.lcd.bright.apply = lambda : setLCDbright(config.lcd.bright)
+               ilcd = LCD()
 
                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
 
-               config.lcd.standby = ConfigSlider(default=0, limits=(0, 10))
+               config.lcd.standby = ConfigSlider(default=standby_default, limits=(0, 10))
+               config.lcd.standby.addNotifier(setLCDbright);
                config.lcd.standby.apply = lambda : setLCDbright(config.lcd.standby)
 
+               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.invert = ConfigYesNo(default=False)
                config.lcd.invert.addNotifier(setLCDinverted);
        else:
@@ -67,3 +80,6 @@ def InitLcd():
                config.lcd.standby = ConfigNothing()
                config.lcd.bright.apply = lambda : doNothing()
                config.lcd.standby.apply = lambda : doNothing()
+
+       config.misc.standbyCounter.addNotifier(standbyCounterChanged, initial_call = False)
+