fix and simplify PluginList
[enigma2.git] / lib / python / Components / Lcd.py
1 from config import config, ConfigSubsection, ConfigSlider, ConfigYesNo, ConfigNothing
2
3 from enigma import eDBoxLCD
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
33         def setLCDbright(configElement):
34                 ilcd.setBright(configElement.value);
35
36         def setLCDcontrast(configElement):
37                 ilcd.setContrast(configElement.value);
38
39         def setLCDinverted(configElement):
40                 ilcd.setInverted(configElement.value);
41
42         ilcd = LCD()
43
44         config.lcd = ConfigSubsection();
45
46         config.lcd.bright = ConfigSlider(default=10, limits=(0, 10))
47         config.lcd.bright.addNotifier(setLCDbright);
48         config.lcd.bright.apply = lambda : setLCDbright(config.lcd.bright)
49
50         if not ilcd.isOled():
51                 config.lcd.contrast = ConfigSlider(default=5, limits=(0, 20))
52                 config.lcd.contrast.addNotifier(setLCDcontrast);
53         else:
54                 config.lcd.contrast = ConfigNothing()
55
56         config.lcd.standby = ConfigSlider(default=0, limits=(0, 10))
57         config.lcd.standby.apply = lambda : setLCDbright(config.lcd.standby)
58
59         config.lcd.invert = ConfigYesNo(default=False)
60         config.lcd.invert.addNotifier(setLCDinverted);