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"):
14 config.misc.standbyCounter.addNotifier(self.standbyCounterChanged, initial_call = False)
16 def leaveStandby(self):
17 for fanid in range(self.getFanCount()):
18 cfg = self.getConfig(fanid)
19 self.setVoltage(fanid, cfg.vlt.value)
20 self.setPWM(fanid, cfg.pwm.value)
22 def standbyCounterChanged(self, configElement):
23 from Screens.Standby import inStandby
24 inStandby.onClose.append(self.leaveStandby)
25 for fanid in range(self.getFanCount()):
26 self.setVoltage(fanid, 0)
29 def createConfig(self):
30 def setVlt(fancontrol, fanid, configElement):
31 fancontrol.setVoltage(fanid, configElement.value)
32 def setPWM(fancontrol, fanid, configElement):
33 fancontrol.setPWM(fanid, configElement.value)
35 config.fans = ConfigSubList()
36 for fanid in range(self.getFanCount()):
37 fan = ConfigSubsection()
38 fan.vlt = ConfigSlider(default = 16, increment = 5, limits = (0, 255))
39 fan.pwm = ConfigSlider(default = 0, increment = 5, limits = (0, 255))
40 fan.vlt.addNotifier(boundFunction(setVlt, self, fanid))
41 fan.pwm.addNotifier(boundFunction(setPWM, self, fanid))
42 config.fans.append(fan)
44 def getConfig(self, fanid):
45 return config.fans[fanid]
47 def getFanCount(self):
50 def hasRPMSensor(self, fanid):
51 return os.path.exists("/proc/stb/fp/fan_speed")
53 def hasFanControl(self, fanid):
54 return os.path.exists("/proc/stb/fp/fan_vlt") or os.path.exists("/proc/stb/fp/fan_pwm")
56 def getFanSpeed(self, fanid):
57 f = open("/proc/stb/fp/fan_speed", "r")
58 value = int(f.readline().strip()[:-4])
62 def getVoltage(self, fanid):
63 f = open("/proc/stb/fp/fan_vlt", "r")
64 value = int(f.readline().strip(), 16)
68 def setVoltage(self, fanid, value):
71 f = open("/proc/stb/fp/fan_vlt", "w")
75 def getPWM(self, fanid):
76 f = open("/proc/stb/fp/fan_pwm", "r")
77 value = int(f.readline().strip(), 16)
81 def setPWM(self, fanid, value):
84 f = open("/proc/stb/fp/fan_pwm", "w")
88 fancontrol = FanControl()