fix resolve key for ConfigSubDict / ConfigSublist
[enigma2.git] / lib / python / Components / Lcd.py
1 from config import config, ConfigSubsection, ConfigSlider, ConfigYesNo
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 InitLcd():
29         config.lcd = ConfigSubsection();
30         config.lcd.bright = ConfigSlider(default=10, limits=(0, 10))
31         config.lcd.contrast = ConfigSlider(default=5, limits=(0, 20))
32         config.lcd.standby = ConfigSlider(default=0, limits=(0, 10))
33         config.lcd.invert = ConfigYesNo(default=False)
34
35         ilcd = LCD()
36
37         def setLCDbright(configElement):
38                 ilcd.setBright(configElement.value);
39
40         def setLCDcontrast(configElement):
41                 ilcd.setContrast(configElement.value);
42
43         def setLCDinverted(configElement):
44                 ilcd.setInverted(configElement.value);
45
46         config.lcd.bright.addNotifier(setLCDbright);
47         config.lcd.contrast.addNotifier(setLCDcontrast);
48         config.lcd.invert.addNotifier(setLCDinverted);