add possibility to separately set fan voltage and fan pwm for standby and normal run
authorghost <andreas.monzner@multimedia-labs.de>
Wed, 24 Mar 2010 10:29:50 +0000 (11:29 +0100)
committerghost <andreas.monzner@multimedia-labs.de>
Wed, 24 Mar 2010 10:31:10 +0000 (11:31 +0100)
when a recording starts in standby switch to normal mode and vice versa
this fixes bug #430 (thx to Dr.Best)

lib/python/Components/FanControl.py
lib/python/Plugins/SystemPlugins/TempFanControl/plugin.py

index cee0523..a993c39 100644 (file)
@@ -3,6 +3,9 @@ import os
 from Components.config import config, ConfigSubList, ConfigSubsection, ConfigSlider
 from Tools.BoundFunction import boundFunction
 
+import NavigationInstance
+from enigma import iRecordableService
+
 class FanControl:
        # ATM there's only support for one fan
        def __init__(self):
@@ -13,18 +16,42 @@ class FanControl:
                self.createConfig()
                config.misc.standbyCounter.addNotifier(self.standbyCounterChanged, initial_call = False)
 
-       def leaveStandby(self):
+       def setVoltage_PWM(self):
                for fanid in range(self.getFanCount()):
                        cfg = self.getConfig(fanid)
                        self.setVoltage(fanid, cfg.vlt.value)
                        self.setPWM(fanid, cfg.pwm.value)
+                       print "[FanControl]: setting fan values: fanid = %d, voltage = %d, pwm = %d" % (fanid, cfg.vlt.value, cfg.pwm.value)
+
+       def setVoltage_PWM_Standby(self):
+               for fanid in range(self.getFanCount()):
+                       cfg = self.getConfig(fanid)
+                       self.setVoltage(fanid, cfg.vlt_standby.value)
+                       self.setPWM(fanid, cfg.pwm_standby.value)
+                       print "[FanControl]: setting fan values (standby mode): fanid = %d, voltage = %d, pwm = %d" % (fanid, cfg.vlt_standby.value, cfg.pwm_standby.value)
+
+       def getRecordEvent(self, recservice, event):
+               recordings = len(NavigationInstance.instance.getRecordings())
+               if event == iRecordableService.evEnd:
+                       if recordings == 0:
+                               self.setVoltage_PWM_Standby()
+               elif event == iRecordableService.evStart:
+                       if recordings == 1:
+                               self.setVoltage_PWM()
+
+       def leaveStandby(self):
+               NavigationInstance.instance.record_event.remove(self.getRecordEvent)
+               recordings = NavigationInstance.instance.getRecordings()
+               if not recordings:
+                       self.setVoltage_PWM()
 
        def standbyCounterChanged(self, configElement):
                from Screens.Standby import inStandby
                inStandby.onClose.append(self.leaveStandby)
-               for fanid in range(self.getFanCount()):
-                       self.setVoltage(fanid, 0)
-                       self.setPWM(fanid, 0)
+               recordings = NavigationInstance.instance.getRecordings()
+               NavigationInstance.instance.record_event.append(self.getRecordEvent)
+               if not recordings:
+                       self.setVoltage_PWM_Standby()
 
        def createConfig(self):
                def setVlt(fancontrol, fanid, configElement):
@@ -35,12 +62,14 @@ class FanControl:
                config.fans = ConfigSubList()
                for fanid in range(self.getFanCount()):
                        fan = ConfigSubsection()
-                       fan.vlt = ConfigSlider(default = 16, increment = 5, limits = (0, 255))
+                       fan.vlt = ConfigSlider(default = 15, increment = 5, limits = (0, 255))
                        fan.pwm = ConfigSlider(default = 0, increment = 5, limits = (0, 255))
+                       fan.vlt_standby = ConfigSlider(default = 5, increment = 5, limits = (0, 255))
+                       fan.pwm_standby = ConfigSlider(default = 0, increment = 5, limits = (0, 255))
                        fan.vlt.addNotifier(boundFunction(setVlt, self, fanid))
                        fan.pwm.addNotifier(boundFunction(setPWM, self, fanid))
                        config.fans.append(fan)
-                       
+       
        def getConfig(self, fanid):
                return config.fans[fanid]
        
@@ -85,4 +114,4 @@ class FanControl:
                f.write("%x" % value)
                f.close()
        
-fancontrol = FanControl()
\ No newline at end of file
+fancontrol = FanControl()
index 38e343f..c8af9cd 100644 (file)
@@ -12,7 +12,7 @@ from Components.FanControl import fancontrol
 
 class TempFanControl(Screen, ConfigListScreen):
        skin = """
-               <screen position="90,100" size="570,420" title="Fan Control" >
+               <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" />
@@ -22,7 +22,7 @@ class TempFanControl(Screen, ConfigListScreen):
                        <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,90" scrollbarMode="showOnDemand" />
+                       <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">
@@ -90,7 +90,7 @@ class TempFanControl(Screen, ConfigListScreen):
                                <convert type="SensorToText"></convert>
                        </widget>
                </screen>"""
-       
+
        def __init__(self, session, args = None):
                Screen.__init__(self, session)
                
@@ -125,6 +125,9 @@ 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)
@@ -136,28 +139,31 @@ class TempFanControl(Screen, ConfigListScreen):
                        "red": self.revert,
                        "green": self.save
                }, -1)
-               
+
        def save(self):
                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):
                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_MENU, fnc = startMenu)
-       
\ No newline at end of file
+