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
11 class ManualFancontrol(Screen,ConfigListScreen):
13 <screen position="center,center" size="560,300" title="Fancontrol Settings in Standby mode" >
14 <ePixmap pixmap="skin_default/buttons/red.png" position="110,10" size="140,40" alphatest="on" />
15 <ePixmap pixmap="skin_default/buttons/green.png" position="310,10" size="140,40" alphatest="on" />
17 <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" />
18 <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" />
20 <widget name="config" zPosition="2" position="5,70" size="550,200" scrollbarMode="showOnDemand" transparent="1" />
21 <widget source="current" render="Label" position="150,270" zPosition="1" size="280,30" font="Regular;20" halign="center" valign="center" />
25 def __init__(self,session):
26 Screen.__init__(self,session)
27 self.session = session
28 self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
31 "cancel": self.keyCancel,
32 "red": self.keyCancel,
33 "green": self.keySave,
36 ConfigListScreen.__init__(self, self.list,session = self.session)
37 self["key_red"] = StaticText(_("Cancel"))
38 self["key_green"] = StaticText(_("Save"))
39 self["current"] = StaticText(_(" "))
41 self.oldfanoffmode = instandbyon.fanoffmode
42 if instandbyon.fanoffmode is 'ON' :
43 instandbyon.checkStatusLoopStop()
45 def displayCurrentValue(self):
46 currrent_val = self["config"].getCurrent()[0]+" : "+str(self["config"].getCurrent()[1].value)
47 self["current"].setText(_(currrent_val))
50 def selectionChanged(self):
51 if self["config"].getCurrent() == self.pwmEntry:
52 instandbyon.setPWM(self["config"].getCurrent()[1].value)
55 oldpwmvalue=config.plugins.manualfancontrols.pwmvalue.value
56 ConfigListScreen.keyLeft(self)
57 if self["config"].getCurrent() == self.pwmEntry and oldpwmvalue == 5:
60 self.displayCurrentValue()
61 self.selectionChanged()
64 oldpwmvalue=config.plugins.manualfancontrols.pwmvalue.value
65 ConfigListScreen.keyRight(self)
66 if self["config"].getCurrent() == self.pwmEntry and oldpwmvalue == 0:
68 while self["config"].getCurrent() != self.pwmEntry:
69 self["config"].setCurrentIndex(self["config"].getCurrentIndex()+1)
71 self.displayCurrentValue()
72 self.selectionChanged()
74 def createSetup(self):
76 if config.plugins.manualfancontrols.pwmvalue.value > 0:
77 self.list.append( self.standbyEntry )
78 self.list.append( self.pwmEntry )
79 self.list.append( self.periodEntry )
80 self["config"].list = self.list
81 self["config"].l.setList(self.list)
83 def configSetup(self):
84 self.standbyEntry = getConfigListEntry(_("FanOFF InStanby"), config.plugins.manualfancontrols.standbymode)
85 self.pwmEntry = getConfigListEntry(_("PWM value"), config.plugins.manualfancontrols.pwmvalue)
86 self.periodEntry = getConfigListEntry(_("Status Check Period"), config.plugins.manualfancontrols.checkperiod)
87 if not self.displayCurrentValue in self["config"].onSelectionChanged:
88 self["config"].onSelectionChanged.append(self.displayCurrentValue)
92 if instandbyon.fanoffmode is 'OFF' and config.plugins.manualfancontrols.pwmvalue.value == 0:
93 print "<SimpleFancontrol> instandbyon.fanoffmode 'OFF' -> 'ON'"
94 instandbyon.fanoffmode = 'ON'
95 instandbyon.addRecordEventCB()
96 instandbyon.checkStatusLoopStart()
97 elif instandbyon.fanoffmode is 'ON' and config.plugins.manualfancontrols.pwmvalue.value != 0:
98 print "<SimpleFancontrol> instandbyon.fanoffmode 'ON' -> 'OFF'"
99 instandbyon.fanoffmode = 'OFF'
100 instandbyon.removeRecordEventCB()
101 # instandbyon.checkStatusLoopStop() # stoped at init
102 elif self.oldfanoffmode is 'ON' :
103 instandbyon.checkStatusLoopStart()
104 instandbyon.checkStstus()
105 ConfigListScreen.keySave(self)
107 def cancelConfirm(self, result):
110 for x in self["config"].list:
112 instandbyon.checkStstus()
113 self.oldfanoffmode = instandbyon.fanoffmode
114 if self.oldfanoffmode is 'ON' :
115 instandbyon.checkStatusLoopStart()
119 if self["config"].isChanged():
120 self.session.openWithCallback(self.cancelConfirm, MessageBox, _("Really close without saving settings?"))
122 instandbyon.checkStstus()
123 if self.oldfanoffmode is 'ON' :
124 instandbyon.checkStatusLoopStart()
127 def main(session, **kwargs):
128 session.open(ManualFancontrol)
130 def Plugins(**kwargs):
131 return [PluginDescriptor(name=_("Manual Fan control"), description="setup Fancontol inStandby mode", where = PluginDescriptor.WHERE_PLUGINMENU, needsRestart = True, fnc=main)]