1 from Screens.Screen import Screen
2 from Components.ConfigList import ConfigListScreen
3 from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection, ConfigInteger
4 from Components.ActionMap import ActionMap,NumberActionMap
5 from Screens.MessageBox import MessageBox
6 from Components.Sources.StaticText import StaticText
7 from Plugins.Plugin import PluginDescriptor
8 from Plugins.SystemPlugins.ManualFancontrol.InstandbyOn import instandbyon
9 import NavigationInstance
10 from enigma import eTimer
12 class ManualFancontrol(Screen,ConfigListScreen):
14 <screen position="center,center" size="560,300" title="Fancontrol Settings in Standby mode" >
15 <ePixmap pixmap="skin_default/buttons/red.png" position="110,10" size="140,40" alphatest="on" />
16 <ePixmap pixmap="skin_default/buttons/green.png" position="310,10" size="140,40" alphatest="on" />
18 <widget source="key_red" render="Label" position="110,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" foregroundColor="#ffffff" transparent="1" />
19 <widget source="key_green" render="Label" position="310,10" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" foregroundColor="#ffffff" transparent="1" />
21 <widget name="config" zPosition="2" position="5,70" size="550,200" scrollbarMode="showOnDemand" transparent="1" />
22 <widget source="current" render="Label" position="150,270" zPosition="1" size="280,30" font="Regular;20" halign="center" valign="center" />
26 def __init__(self,session):
27 Screen.__init__(self,session)
28 self.session = session
29 self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
32 "cancel": self.keyCancel,
33 "red": self.keyCancel,
34 "green": self.keySave,
37 ConfigListScreen.__init__(self, self.list,session = self.session)
38 self["key_red"] = StaticText(_("Cancel"))
39 self["key_green"] = StaticText(_("Save"))
40 self["current"] = StaticText(_(" "))
42 self.oldfanoffmode = instandbyon.fanoffmode
43 if instandbyon.fanoffmode is 'ON' :
44 instandbyon.checkStatusLoopStop()
45 self.checkFanTimer = eTimer()
46 self.checkFanTimer.callback.append(self.fan_pwm_error)
47 self.onLayoutFinish.append(self.checkFan)
50 if not instandbyon.check_fan_pwm():
51 self.checkFanTimer.start(10,True)
53 def fan_pwm_error(self):
54 self.session.openWithCallback(self.close, MessageBox, _("Can not open 'fan_pwm'"), MessageBox.TYPE_ERROR)
56 def displayCurrentValue(self):
57 currrent_val = self["config"].getCurrent()[0]+" : "+str(self["config"].getCurrent()[1].value)
58 self["current"].setText(_(currrent_val))
61 def selectionChanged(self):
62 if self["config"].getCurrent() == self.pwmEntry:
63 instandbyon.setPWM(self["config"].getCurrent()[1].value)
66 oldpwmvalue=config.plugins.manualfancontrols.pwmvalue.value
67 ConfigListScreen.keyLeft(self)
68 if self["config"].getCurrent() == self.pwmEntry and oldpwmvalue == 5:
71 self.displayCurrentValue()
72 self.selectionChanged()
75 oldpwmvalue=config.plugins.manualfancontrols.pwmvalue.value
76 ConfigListScreen.keyRight(self)
77 if self["config"].getCurrent() == self.pwmEntry and oldpwmvalue == 0:
79 while self["config"].getCurrent() != self.pwmEntry:
80 self["config"].setCurrentIndex(self["config"].getCurrentIndex()+1)
82 self.displayCurrentValue()
83 self.selectionChanged()
85 def createSetup(self):
87 if config.plugins.manualfancontrols.pwmvalue.value > 0:
88 self.list.append( self.standbyEntry )
89 self.list.append( self.pwmEntry )
90 self.list.append( self.periodEntry )
91 self["config"].list = self.list
92 self["config"].l.setList(self.list)
94 def configSetup(self):
95 self.standbyEntry = getConfigListEntry(_("FanOFF InStanby"), config.plugins.manualfancontrols.standbymode)
96 self.pwmEntry = getConfigListEntry(_("PWM value"), config.plugins.manualfancontrols.pwmvalue)
97 self.periodEntry = getConfigListEntry(_("Status Check Period"), config.plugins.manualfancontrols.checkperiod)
98 if not self.displayCurrentValue in self["config"].onSelectionChanged:
99 self["config"].onSelectionChanged.append(self.displayCurrentValue)
103 if instandbyon.fanoffmode is 'OFF' and config.plugins.manualfancontrols.pwmvalue.value == 0:
104 # print "[ManualFancontrol] instandbyon.fanoffmode 'OFF' -> 'ON'"
105 instandbyon.fanoffmode = 'ON'
106 instandbyon.addRecordEventCB()
107 instandbyon.checkStatusLoopStart()
108 elif instandbyon.fanoffmode is 'ON' and config.plugins.manualfancontrols.pwmvalue.value != 0:
109 # print "[ManualFancontrol] instandbyon.fanoffmode 'ON' -> 'OFF'"
110 instandbyon.fanoffmode = 'OFF'
111 instandbyon.removeRecordEventCB()
112 # instandbyon.checkStatusLoopStop() # stoped at init
113 elif self.oldfanoffmode is 'ON' :
114 instandbyon.checkStatusLoopStart()
115 instandbyon.checkStstus()
116 ConfigListScreen.keySave(self)
118 def cancelConfirm(self, result):
121 for x in self["config"].list:
123 instandbyon.checkStstus()
124 self.oldfanoffmode = instandbyon.fanoffmode
125 if self.oldfanoffmode is 'ON' :
126 instandbyon.checkStatusLoopStart()
130 if self["config"].isChanged():
131 self.session.openWithCallback(self.cancelConfirm, MessageBox, _("Really close without saving settings?"))
133 instandbyon.checkStstus()
134 if self.oldfanoffmode is 'ON' :
135 instandbyon.checkStatusLoopStart()
138 def main(session, **kwargs):
139 session.open(ManualFancontrol)
141 def Plugins(**kwargs):
142 return [PluginDescriptor(name=_("Manual Fan control"), description="setup Fancontol inStandby mode", where = PluginDescriptor.WHERE_PLUGINMENU, needsRestart = True, fnc=main)]