aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components/FanControl.py
diff options
context:
space:
mode:
authorghost <andreas.monzner@multimedia-labs.de>2010-01-05 19:01:59 +0100
committerghost <andreas.monzner@multimedia-labs.de>2010-01-05 19:01:59 +0100
commitc352487661e7927d0068ef8fa69765055ff488d8 (patch)
tree90066f095c2fddcba46511358c7ae1d40e992ee3 /lib/python/Components/FanControl.py
parent8c0e6b4a527f5666195683b7cc28c278a636da0d (diff)
parent48070d1e3868f6c7e5d61002f2b707249be5d016 (diff)
downloadenigma2-c352487661e7927d0068ef8fa69765055ff488d8.tar.gz
enigma2-c352487661e7927d0068ef8fa69765055ff488d8.zip
Merge remote branch 'remotes/origin/fantempplugin'
Diffstat (limited to 'lib/python/Components/FanControl.py')
-rw-r--r--lib/python/Components/FanControl.py74
1 files changed, 74 insertions, 0 deletions
diff --git a/lib/python/Components/FanControl.py b/lib/python/Components/FanControl.py
new file mode 100644
index 00000000..cc133ac0
--- /dev/null
+++ b/lib/python/Components/FanControl.py
@@ -0,0 +1,74 @@
+import os
+
+from Components.config import config, ConfigSubList, ConfigSubsection, ConfigSlider
+from Tools.BoundFunction import boundFunction
+
+class FanControl:
+ # ATM there's only support for one fan
+ def __init__(self):
+ if os.path.exists("/proc/stb/fp/fan_vlt") or os.path.exists("/proc/stb/fp/fan_pwm") or os.path.exists("/proc/stb/fp/fan_speed"):
+ self.fancount = 1
+ else:
+ self.fancount = 0
+ self.createConfig()
+
+ def createConfig(self):
+ def setVlt(fancontrol, fanid, configElement):
+ fancontrol.setVoltage(fanid, configElement.value)
+ def setPWM(fancontrol, fanid, configElement):
+ fancontrol.setPWM(fanid, configElement.value)
+
+ config.fans = ConfigSubList()
+ for fanid in range(self.getFanCount()):
+ fan = ConfigSubsection()
+ fan.vlt = ConfigSlider(default = 16, increment = 5, limits = (0, 255))
+ fan.pwm = 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]
+
+ def getFanCount(self):
+ return self.fancount
+
+ def hasRPMSensor(self, fanid):
+ return os.path.exists("/proc/stb/fp/fan_speed")
+
+ def hasFanControl(self, fanid):
+ return os.path.exists("/proc/stb/fp/fan_vlt") or os.path.exists("/proc/stb/fp/fan_pwm")
+
+ def getFanSpeed(self, fanid):
+ f = open("/proc/stb/fp/fan_speed", "r")
+ value = int(f.readline().strip()[:-4])
+ f.close()
+ return value
+
+ def getVoltage(self, fanid):
+ f = open("/proc/stb/fp/fan_vlt", "r")
+ value = int(f.readline().strip(), 16)
+ f.close()
+ return value
+
+ def setVoltage(self, fanid, value):
+ if value > 255:
+ return
+ f = open("/proc/stb/fp/fan_vlt", "w")
+ f.write("%x" % value)
+ f.close()
+
+ def getPWM(self, fanid):
+ f = open("/proc/stb/fp/fan_pwm", "r")
+ value = int(f.readline().strip(), 16)
+ f.close()
+ return value
+
+ def setPWM(self, fanid, value):
+ if value > 255:
+ return
+ f = open("/proc/stb/fp/fan_pwm", "w")
+ f.write("%x" % value)
+ f.close()
+
+fancontrol = FanControl() \ No newline at end of file