add possibility to separately set fan voltage and fan pwm for standby and normal run
[enigma2.git] / lib / python / Plugins / SystemPlugins / TempFanControl / plugin.py
index b5762529f332a541893bae3f3e0a401a420bf2bc..c8af9cdde9c851e4be2a3b6fee3c15b03c5d426c 100644 (file)
@@ -12,8 +12,17 @@ from Components.FanControl import fancontrol
 
 class TempFanControl(Screen, ConfigListScreen):
        skin = """
-               <screen position="100,100" size="550,400" title="Fan Control" >
-                       <!--widget name="text" position="0,0" size="550,400" font="Regular;15" /-->
+               <screen position="center,center" size="570,420" title="Fan Control" >
+                       <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />
+                       <widget source="red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
+                       <widget source="green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
+                       <widget source="yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
+                       <widget source="blue" render="Label" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />
+                       
+                       <widget name="config" position="10,50" size="550,120" scrollbarMode="showOnDemand" />
                        
                        <widget source="SensorTempText0" render="Label" position="10,150" zPosition="1" size="90,40" font="Regular;20" halign="left" valign="top" backgroundColor="#9f1313" transparent="1" />
                        <widget source="SensorTemp0" render="Label" position="100,150" zPosition="1" size="100,20" font="Regular;19" halign="right">
@@ -80,9 +89,8 @@ class TempFanControl(Screen, ConfigListScreen):
                        <widget source="SensorFan7" render="Label" position="380,290" zPosition="1" size="150,20" font="Regular;19" halign="right">
                                <convert type="SensorToText"></convert>
                        </widget>
-                       <widget name="config" position="10,10" size="500,225" scrollbarMode="showOnDemand" />
                </screen>"""
-       
+
        def __init__(self, session, args = None):
                Screen.__init__(self, session)
                
@@ -91,6 +99,11 @@ class TempFanControl(Screen, ConfigListScreen):
                fanlist = sensors.getSensorsList(sensors.TYPE_FAN_RPM)
                fancount = len(fanlist)
                
+               self["red"] = StaticText(_("Cancel"))
+               self["green"] = StaticText(_("OK"))
+               self["yellow"] = StaticText("")
+               self["blue"] = StaticText("")   
+               
                for count in range(8):
                        if count < tempcount:
                                id = templist[count]
@@ -112,29 +125,45 @@ class TempFanControl(Screen, ConfigListScreen):
                for count in range(fancontrol.getFanCount()):
                        self.list.append(getConfigListEntry(_("Fan %d Voltage") % (count + 1), fancontrol.getConfig(count).vlt))
                        self.list.append(getConfigListEntry(_("Fan %d PWM") % (count + 1), fancontrol.getConfig(count).pwm))
+                       self.list.append(getConfigListEntry(_("Standby Fan %d Voltage") % (count + 1), fancontrol.getConfig(count).vlt_standby))
+                       self.list.append(getConfigListEntry(_("Standby Fan %d PWM") % (count + 1), fancontrol.getConfig(count).pwm_standby))
+               
                ConfigListScreen.__init__(self, self.list, session = self.session)
                #self["config"].list = self.list
                #self["config"].setList(self.list)
                
-               self["actions"] = ActionMap(["OkCancelActions"], 
+               self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], 
                {
                        "ok": self.save,
-                       "cancel": self.revert
+                       "cancel": self.revert,
+                       "red": self.revert,
+                       "green": self.save
                }, -1)
-               
+
        def save(self):
-               fancontrol.getConfig(0).vlt.save()
-               fancontrol.getConfig(0).pwm.save()
+               for count in range(fancontrol.getFanCount()):
+                       fancontrol.getConfig(count).vlt.save()
+                       fancontrol.getConfig(count).pwm.save()
+                       fancontrol.getConfig(count).vlt_standby.save()
+                       fancontrol.getConfig(count).pwm_standby.save()
                self.close()
-               
+
        def revert(self):
-               fancontrol.getConfig(0).vlt.load()
-               fancontrol.getConfig(0).pwm.load()
+               for count in range(fancontrol.getFanCount()):
+                       fancontrol.getConfig(count).vlt.load()
+                       fancontrol.getConfig(count).pwm.load()
+                       fancontrol.getConfig(count).vlt_standby.load()
+                       fancontrol.getConfig(count).pwm_standby.load()
                self.close()
 
 def main(session, **kwargs):
        session.open(TempFanControl)
 
+def startMenu(menuid):
+       if menuid != "system":
+               return []
+       return [(_("Temperature and Fan control"), main, "tempfancontrol", 80)]
+
 def Plugins(**kwargs):
-       return PluginDescriptor(name = "Temperature and Fan control", description = _("Temperature and Fan control"), where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc = main)
-       
\ No newline at end of file
+       return PluginDescriptor(name = "Temperature and Fan control", description = _("Temperature and Fan control"), where = PluginDescriptor.WHERE_MENU, fnc = startMenu)
+