3 from Components.config import config, ConfigSubList, ConfigSubsection, ConfigSlider
4 from Tools.BoundFunction import boundFunction
7 # ATM there's only support for one fan
9 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"):
15 def createConfig(self):
16 def setVlt(fancontrol, fanid, configElement):
17 fancontrol.setVoltage(fanid, configElement.value)
18 def setPWM(fancontrol, fanid, configElement):
19 fancontrol.setPWM(fanid, configElement.value)
21 config.fans = ConfigSubList()
22 for fanid in range(self.getFanCount()):
23 fan = ConfigSubsection()
24 fan.vlt = ConfigSlider(default = 16, increment = 5, limits = (0, 255))
25 fan.pwm = ConfigSlider(default = 0, increment = 5, limits = (0, 255))
26 fan.vlt.addNotifier(boundFunction(setVlt, self, fanid))
27 fan.pwm.addNotifier(boundFunction(setPWM, self, fanid))
28 config.fans.append(fan)
30 def getConfig(self, fanid):
31 return config.fans[fanid]
33 def getFanCount(self):
36 def hasRPMSensor(self, fanid):
37 return os.path.exists("/proc/stb/fp/fan_speed")
39 def hasFanControl(self, fanid):
40 return os.path.exists("/proc/stb/fp/fan_vlt") or os.path.exists("/proc/stb/fp/fan_pwm")
42 def getFanSpeed(self, fanid):
43 f = open("/proc/stb/fp/fan_speed", "r")
44 value = int(f.readline().strip()[:-4])
48 def getVoltage(self, fanid):
49 f = open("/proc/stb/fp/fan_vlt", "r")
50 value = int(f.readline().strip(), 16)
54 def setVoltage(self, fanid, value):
57 f = open("/proc/stb/fp/fan_vlt", "w")
61 def getPWM(self, fanid):
62 f = open("/proc/stb/fp/fan_pwm", "r")
63 value = int(f.readline().strip(), 16)
67 def setPWM(self, fanid, value):
70 f = open("/proc/stb/fp/fan_pwm", "w")
74 fancontrol = FanControl()