po/Makefile.am: remove not existing Networkwizard
[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.standby = ConfigSlider(default=0, limits=(0, 10))
48                 config.lcd.standby.addNotifier(setLCDbright);
49                 config.lcd.standby.apply = lambda : setLCDbright(config.lcd.standby)
50
51                 config.lcd.bright = ConfigSlider(default=5, limits=(0, 10))
52                 config.lcd.bright.addNotifier(setLCDbright);
53                 config.lcd.bright.apply = lambda : setLCDbright(config.lcd.bright)
54                 config.lcd.bright.callNotifiersOnSaveAndCancel = True
55
56                 if not ilcd.isOled():
57                         config.lcd.contrast = ConfigSlider(default=5, limits=(0, 20))
58                         config.lcd.contrast.addNotifier(setLCDcontrast);
59                 else:
60                         config.lcd.contrast = ConfigNothing()
61
62                 config.lcd.invert = ConfigYesNo(default=False)
63                 config.lcd.invert.addNotifier(setLCDinverted);
64         else:
65                 def doNothing():
66                         pass
67                 config.lcd.contrast = ConfigNothing()
68                 config.lcd.bright = ConfigNothing()
69                 config.lcd.standby = ConfigNothing()
70                 config.lcd.bright.apply = lambda : doNothing()
71                 config.lcd.standby.apply = lambda : doNothing()