1 from Screens.Screen import Screen
2 from Components.ConfigList import ConfigListScreen
3 from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSlider
4 from Components.ActionMap import ActionMap
5 from Components.Sources.StaticText import StaticText
6 from Components.Label import Label
7 from Plugins.Plugin import PluginDescriptor
8 from Screens.MessageBox import MessageBox
9 from Tools.Directories import fileExists
10 from enigma import eTimer
11 from enigma import eDBoxLCD
12 from ledsetup import LEDUpdate
14 config.plugins.brightnesssetup = ConfigSubsection()
15 config.plugins.brightnesssetup.brightness = ConfigSlider(default = 1, increment = 1, limits = (0,15))
16 config.plugins.brightnesssetup.brightnessstandby = ConfigSlider(default = 1, increment = 1, limits = (0,15))
17 config.plugins.brightnesssetup.brightnessdeepstandby = ConfigSlider(default = 5, increment = 1, limits = (0,15))
18 config.plugins.brightnesssetup.blinkingtime = ConfigSlider(default = 5, increment = 1, limits = (0,15))
25 class LEDBrightnessSetupStandby:
28 config.misc.standbyCounter.addNotifier(self.standbyBegin, initial_call = False)
30 def standbyBegin(self, configElement):
31 from Screens.Standby import inStandby
32 inStandby.onClose.append(self.StandbyEnd)
33 brightness = int(config.plugins.brightnesssetup.brightnessstandby.value)
34 eDBoxLCD.getInstance().setLED(brightness ,LEDOption.BRIGHTNESS)
37 brightness = int(config.plugins.brightnesssetup.brightness.value)
38 eDBoxLCD.getInstance().setLED(brightness ,LEDOption.BRIGHTNESS)
40 def initLEDSetup(self):
41 brightness = int(config.plugins.brightnesssetup.brightness.value)
42 brightnessstandby = int(config.plugins.brightnesssetup.brightnessdeepstandby.value)
43 blinkingtime = int(config.plugins.brightnesssetup.blinkingtime.value)
44 eDBoxLCD.getInstance().setLED(brightness ,LEDOption.BRIGHTNESS)
45 eDBoxLCD.getInstance().setLED(brightnessstandby ,LEDOption.DEEPSTANDBY)
46 eDBoxLCD.getInstance().setLED(blinkingtime ,LEDOption.BLINKINGTIME)
48 class LEDBrightnessSetup(Screen,ConfigListScreen):
50 <screen name="LEDBrightnessSetup" position="center,center" size="560,300" title="LED Brightness Setup">
51 <ePixmap pixmap="Vu_HD/buttons/red.png" position="10,10" size="25,25" alphatest="on" />
52 <ePixmap pixmap="Vu_HD/buttons/green.png" position="195,10" size="25,25" alphatest="on" />
53 <ePixmap pixmap="Vu_HD/buttons/yellow.png" position="380,10" size="25,25" alphatest="on" />
54 <widget source="key_red" render="Label" position="30,10" zPosition="1" size="140,25" font="Regular;20" halign="center" valign="center" transparent="1" />
55 <widget source="key_green" render="Label" position="215,10" zPosition="1" size="140,25" font="Regular;20" halign="center" valign="center" transparent="1" />
56 <widget source="key_yellow" render="Label" position="400,10" zPosition="1" size="140,25" font="Regular;20" halign="center" valign="center" transparent="1" />
57 <widget name="config" zPosition="2" position="5,50" size="550,200" scrollbarMode="showOnDemand" transparent="1"/>
58 <widget name="current_entry" position="130,240" size="300,30" font="Regular;18" halign="center" valign="center"/>
61 def __init__(self,session):
62 Screen.__init__(self,session)
63 self.session = session
64 self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
67 "cancel": self.keyCancel,
68 "red": self.keyCancel,
69 "green": self.keySave,
70 "yellow": self.keyDefault,
73 ConfigListScreen.__init__(self, self.list,session = self.session)
74 self["key_red"] = StaticText(_("Cancel"))
75 self["key_green"] = StaticText(_("Ok"))
76 self["key_yellow"] = StaticText(_("Defalut"))
77 self["current_entry"]=Label("")
79 self.onLayoutFinish.append(self.checkModel)
80 self.checkModelTimer = eTimer()
81 self.checkModelTimer.callback.append(self.invalidmodel)
82 if not self.displayText in self["config"].onSelectionChanged:
83 self["config"].onSelectionChanged.append(self.displayText)
85 def displayText(self):
86 if self["config"].getCurrent() == self.brightness:
87 self["current_entry"].setText("Touch LED Brightness at Normal state")
88 elif self["config"].getCurrent() == self.brightness_standby:
89 self["current_entry"].setText("Touch LED Brightness at Standby")
90 elif self["config"].getCurrent() == self.brightness_deepstandby:
91 self["current_entry"].setText("Touch LED Brightness at Deep Standby")
92 elif self["config"].getCurrent() == self.blinkingtime:
93 self["current_entry"].setText("Touch LED Blinking time")
94 self.setCurrentValue()
97 if fileExists("/proc/stb/info/vumodel"):
98 vumodel = open("/proc/stb/info/vumodel")
99 info=vumodel.read().strip()
108 def checkModel(self):
109 if not self.getModel():
110 self.checkModelTimer.start(100,True)
112 def invalidmodel(self):
113 self.session.openWithCallback(self.close, MessageBox, _("This Plugin only support for ULTIMO"), MessageBox.TYPE_ERROR, timeout = 30)
115 def createSetup(self):
117 self.brightness = getConfigListEntry(_("Normal state"), config.plugins.brightnesssetup.brightness)
118 self.brightness_standby = getConfigListEntry(_("Standby"), config.plugins.brightnesssetup.brightnessstandby)
119 self.brightness_deepstandby = getConfigListEntry(_("Deep Standby"), config.plugins.brightnesssetup.brightnessdeepstandby)
120 self.blinkingtime = getConfigListEntry(_("Blinking time"), config.plugins.brightnesssetup.blinkingtime)
121 self.list.append( self.brightness )
122 self.list.append( self.brightness_standby )
123 self.list.append( self.brightness_deepstandby )
124 self.list.append( self.blinkingtime )
125 self["config"].list = self.list
126 self["config"].l.setList(self.list)
128 def setCurrentValue(self):
129 if self["config"].getCurrent() == self.blinkingtime:
130 eDBoxLCD.getInstance().setLED(1 ,LEDOption.BRIGHTNESS)
131 eDBoxLCD.getInstance().setLED(self["config"].getCurrent()[1].value ,LEDOption.BLINKINGTIME)
133 eDBoxLCD.getInstance().setLED(self["config"].getCurrent()[1].value ,LEDOption.BRIGHTNESS)
136 ConfigListScreen.keyLeft(self)
137 self.setCurrentValue()
140 ConfigListScreen.keyRight(self)
141 self.setCurrentValue()
143 def saveLEDSetup(self):
144 brightness = config.plugins.brightnesssetup.brightness.value
145 brightnessstandby = config.plugins.brightnesssetup.brightnessdeepstandby.value
146 blinkingtime = config.plugins.brightnesssetup.blinkingtime.value
147 eDBoxLCD.getInstance().setLED(brightness ,LEDOption.BRIGHTNESS)
148 eDBoxLCD.getInstance().setLED(brightnessstandby ,LEDOption.DEEPSTANDBY)
149 eDBoxLCD.getInstance().setLED(blinkingtime ,LEDOption.BLINKINGTIME)
152 if self["config"].isChanged():
154 ConfigListScreen.keySave(self)
156 def keyDefault(self):
157 config.plugins.brightnesssetup.brightness.setValue(1)
158 config.plugins.brightnesssetup.brightnessstandby.setValue(1)
159 config.plugins.brightnesssetup.brightnessdeepstandby.setValue(5)
160 config.plugins.brightnesssetup.blinkingtime.setValue(5)
161 for entry in self["config"].getList():
162 self["config"].l.invalidateEntry(self["config"].getList().index(entry))
164 def cancelConfirm(self, result):
167 for x in self["config"].list:
172 def main(session, **kwargs):
173 session.open(LEDBrightnessSetup)
175 def Plugins(**kwargs):
176 return [PluginDescriptor(name=_("LED Brightness Setup"), description="Setup LED brightness and blink interval", where = PluginDescriptor.WHERE_PLUGINMENU, needsRestart = False, fnc=main)]
178 ledbrightnesssetupstandby = LEDBrightnessSetupStandby()