aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components/Lcd.py
blob: eb3e3df18f3e1bc7225ae5acd02933f4526e7944 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
from config import config, ConfigSubsection, ConfigSlider, ConfigYesNo, ConfigNothing

from enigma import eDBoxLCD

class LCD:
	def __init__(self):
		pass

	def setBright(self, value):
		value *= 255
		value /= 10
		if value > 255:
			value = 255
		eDBoxLCD.getInstance().setLCDBrightness(value)

	def setContrast(self, value):
		value *= 63
		value /= 20
		if value > 63:
			value = 63
		eDBoxLCD.getInstance().setLCDContrast(value)

	def setInverted(self, value):
		if value:
			value = 255
		eDBoxLCD.getInstance().setInverted(value)

	def isOled(self):
		return eDBoxLCD.getInstance().isOled()

def InitLcd():

	def setLCDbright(configElement):
		ilcd.setBright(configElement.value);

	def setLCDcontrast(configElement):
		ilcd.setContrast(configElement.value);

	def setLCDinverted(configElement):
		ilcd.setInverted(configElement.value);

	ilcd = LCD()

	config.lcd = ConfigSubsection();

	config.lcd.bright = ConfigSlider(default=10, limits=(0, 10))
	config.lcd.bright.addNotifier(setLCDbright);
	config.lcd.bright.apply = lambda : setLCDbright(config.lcd.bright)

	if not ilcd.isOled():
		config.lcd.contrast = ConfigSlider(default=5, limits=(0, 20))
		config.lcd.contrast.addNotifier(setLCDcontrast);
	else:
		config.lcd.contrast = ConfigNothing()

	config.lcd.standby = ConfigSlider(default=0, limits=(0, 10))
	config.lcd.standby.apply = lambda : setLCDbright(config.lcd.standby)

	config.lcd.invert = ConfigYesNo(default=False)
	config.lcd.invert.addNotifier(setLCDinverted);