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 name="ManualFancontrol" position="center,center" size="560,300" title="Fancontrol Settings in Standby mode" >
14 <ePixmap pixmap="Vu_HD/buttons/red.png" position="10,10" size="25,25" alphatest="on" />
15 <ePixmap pixmap="Vu_HD/buttons/green.png" position="290,10" size="25,25" alphatest="on" />
16 <widget source="key_red" render="Label" position="40,10" zPosition="1" size="140,25" font="Regular;20" halign="center" valign="center" transparent="1" />
17 <widget source="key_green" render="Label" position="320,10" zPosition="1" size="140,25" font="Regular;20" halign="center" valign="center" transparent="1" />
18 <widget name="config" zPosition="2" position="5,50" size="550,200" scrollbarMode="showOnDemand" transparent="1" />
19 <widget source="current" render="Label" position="150,270" zPosition="1" size="280,30" font="Regular;20" halign="center" valign="center" transparent="1" />
22 def __init__(self,session):
23 Screen.__init__(self,session)
24 self.session = session
25 self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
28 "cancel": self.keyCancel,
29 "red": self.keyCancel,
30 "green": self.keySave,
33 ConfigListScreen.__init__(self, self.list,session = self.session)
34 self["key_red"] = StaticText(_("Cancel"))
35 self["key_green"] = StaticText(_("Save"))
36 self["current"] = StaticText(_(" "))
39 def isRecording(self):
40 recordings = NavigationInstance.instance.getRecordings()
46 def displayCurrentValue(self):
47 currrent_val = self["config"].getCurrent()[0]+" : "+str(self["config"].getCurrent()[1].value)
48 self["current"].setText(_(currrent_val))
51 def selectionChanged(self):
52 if self["config"].getCurrent() == self.pwmEntry:
53 instandbyon.setPWM(self["config"].getCurrent()[1].value)
56 oldpwmvalue=config.plugins.simplefancontrols.pwmvalue.value
57 ConfigListScreen.keyLeft(self)
58 if self["config"].getCurrent() == self.pwmEntry and oldpwmvalue == 5:
61 self.displayCurrentValue()
62 self.selectionChanged()
65 oldpwmvalue=config.plugins.simplefancontrols.pwmvalue.value
66 ConfigListScreen.keyRight(self)
67 if self["config"].getCurrent() == self.pwmEntry and oldpwmvalue == 0:
69 while self["config"].getCurrent() != self.pwmEntry:
70 self["config"].setCurrentIndex(self["config"].getCurrentIndex()+1)
72 self.displayCurrentValue()
73 self.selectionChanged()
75 def createSetup(self):
77 if config.plugins.simplefancontrols.pwmvalue.value > 0:
78 self.list.append( self.standbyEntry )
79 self.list.append( self.pwmEntry )
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.simplefancontrols.standbymode)
85 self.pwmEntry = getConfigListEntry(_("PWM value"), config.plugins.simplefancontrols.pwmvalue)
86 if not self.displayCurrentValue in self["config"].onSelectionChanged:
87 self["config"].onSelectionChanged.append(self.displayCurrentValue)
91 if self["config"].getCurrent() == self.pwmEntry and config.plugins.simplefancontrols.pwmvalue.value == 0:
95 if instandbyon.fanoffmode is 'OFF' and config.plugins.simplefancontrols.pwmvalue.value == 0:
96 instandbyon.appendRecordEventCallback()
97 instandbyon.fanoffmode = 'ON'
98 print "<SimpleFancontrol> instandbyon.fanoffmode 'OFF' -> 'ON'"
100 elif instandbyon.fanoffmode is 'ON' and config.plugins.simplefancontrols.pwmvalue.value != 0:
101 instandbyon.removeRecordEventCallback()
102 instandbyon.fanoffmode = 'OFF'
103 print "<SimpleFancontrol> instandbyon.fanoffmode 'ON' -> 'OFF'"
104 if instandbyon.fanoffmode == 'ON' and self.isRecording() and instandbyon.getPWM() != instandbyon.default_pwm_value_onRecordings:
105 instandbyon.setPWM(instandbyon.default_pwm_value_onRecordings)
106 ConfigListScreen.keySave(self)
108 def cancelConfirm(self, result):
111 for x in self["config"].list:
113 if instandbyon.fanoffmode == 'ON' and self.isRecording():
114 if instandbyon.getPWM() != instandbyon.default_pwm_value_onRecordings:
115 instandbyon.setPWM(instandbyon.default_pwm_value_onRecordings)
119 instandbyon.setPWM(config.plugins.simplefancontrols.pwmvalue.value)
123 if self["config"].isChanged():
124 self.session.openWithCallback(self.cancelConfirm, MessageBox, _("Really close without saving settings?"))
126 if instandbyon.fanoffmode == 'ON' and self.isRecording() and instandbyon.getPWM() != instandbyon.default_pwm_value_onRecordings:
127 instandbyon.setPWM(instandbyon.default_pwm_value_onRecordings)
130 def main(session, **kwargs):
131 session.open(ManualFancontrol)
133 def Plugins(**kwargs):
134 return [PluginDescriptor(name=_("Manual Fan control"), description="setup Fancontol inStandby mode", where = PluginDescriptor.WHERE_PLUGINMENU, needsRestart = True, fnc=main)]