fix non working fix
[enigma2.git] / lib / python / Components / Lcd.py
1 from config import config, ConfigSubsection, ConfigSlider, ConfigYesNo, ConfigNothing
2 from enigma import eDBoxLCD
3 from Components.SystemInfo import SystemInfo
4
5 class LCD:
6         def __init__(self):
7                 pass
8
9         def setBright(self, value):
10                 value *= 255
11                 value /= 10
12                 if value > 255:
13                         value = 255
14                 eDBoxLCD.getInstance().setLCDBrightness(value)
15
16         def setContrast(self, value):
17                 value *= 63
18                 value /= 20
19                 if value > 63:
20                         value = 63
21                 eDBoxLCD.getInstance().setLCDContrast(value)
22
23         def setInverted(self, value):
24                 if value:
25                         value = 255
26                 eDBoxLCD.getInstance().setInverted(value)
27
28         def isOled(self):
29                 return eDBoxLCD.getInstance().isOled()
30
31 def InitLcd():
32         detected = eDBoxLCD.getInstance().detected()
33         SystemInfo["Display"] = detected
34         config.lcd = ConfigSubsection();
35         if detected:
36                 def setLCDbright(configElement):
37                         ilcd.setBright(configElement.value);
38
39                 def setLCDcontrast(configElement):
40                         ilcd.setContrast(configElement.value);
41
42                 def setLCDinverted(configElement):
43                         ilcd.setInverted(configElement.value);
44
45                 ilcd = LCD()
46
47                 config.lcd.bright = ConfigSlider(default=10, limits=(0, 10))
48                 config.lcd.bright.addNotifier(setLCDbright);
49                 config.lcd.bright.apply = lambda : setLCDbright(config.lcd.bright)
50
51                 if not ilcd.isOled():
52                         config.lcd.contrast = ConfigSlider(default=5, limits=(0, 20))
53                         config.lcd.contrast.addNotifier(setLCDcontrast);
54                 else:
55                         config.lcd.contrast = ConfigNothing()
56
57                 config.lcd.standby = ConfigSlider(default=0, limits=(0, 10))
58                 config.lcd.standby.apply = lambda : setLCDbright(config.lcd.standby)
59
60                 config.lcd.invert = ConfigYesNo(default=False)
61                 config.lcd.invert.addNotifier(setLCDinverted);
62         else:
63                 def doNothing():
64                         pass
65                 config.lcd.contrast = ConfigNothing()
66                 config.lcd.bright = ConfigNothing()
67                 config.lcd.standby = ConfigNothing()
68                 config.lcd.bright.apply = lambda : doNothing()
69                 config.lcd.standby.apply = lambda : doNothing()