diff options
| author | thedoc <thedoc@atom.(none)> | 2009-12-11 13:01:26 +0100 |
|---|---|---|
| committer | thedoc <thedoc@atom.(none)> | 2009-12-11 13:01:26 +0100 |
| commit | 28dcf6be0ee22fedd728fef11ccff484f8a851e8 (patch) | |
| tree | 6fe8005db1e02409975316859c7a407a489f1f50 /lib/python/Components/FanControl.py | |
| parent | f239e0373a40522e9d3121bbe656e91fb6179099 (diff) | |
| parent | 74378b3ebe7dc0548cb4e4b6a0d54b0e871c0264 (diff) | |
| download | enigma2-28dcf6be0ee22fedd728fef11ccff484f8a851e8.tar.gz enigma2-28dcf6be0ee22fedd728fef11ccff484f8a851e8.zip | |
Merge branch 'fantempplugin' into experimental
Diffstat (limited to 'lib/python/Components/FanControl.py')
| -rw-r--r-- | lib/python/Components/FanControl.py | 74 |
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 |
