3 from Components.config import config, ConfigSubList, ConfigSubsection, ConfigSlider
4 from Tools.BoundFunction import boundFunction
6 import NavigationInstance
7 from enigma import iRecordableService
10 # ATM there's only support for one fan
12 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"):
17 config.misc.standbyCounter.addNotifier(self.standbyCounterChanged, initial_call = False)
19 def setVoltage_PWM(self):
20 for fanid in range(self.getFanCount()):
21 cfg = self.getConfig(fanid)
22 self.setVoltage(fanid, cfg.vlt.value)
23 self.setPWM(fanid, cfg.pwm.value)
24 print "[FanControl]: setting fan values: fanid = %d, voltage = %d, pwm = %d" % (fanid, cfg.vlt.value, cfg.pwm.value)
26 def setVoltage_PWM_Standby(self):
27 for fanid in range(self.getFanCount()):
28 cfg = self.getConfig(fanid)
29 self.setVoltage(fanid, cfg.vlt_standby.value)
30 self.setPWM(fanid, cfg.pwm_standby.value)
31 print "[FanControl]: setting fan values (standby mode): fanid = %d, voltage = %d, pwm = %d" % (fanid, cfg.vlt_standby.value, cfg.pwm_standby.value)
33 def getRecordEvent(self, recservice, event):
34 recordings = len(NavigationInstance.instance.getRecordings())
35 if event == iRecordableService.evEnd:
37 self.setVoltage_PWM_Standby()
38 elif event == iRecordableService.evStart:
42 def leaveStandby(self):
43 NavigationInstance.instance.record_event.remove(self.getRecordEvent)
44 recordings = NavigationInstance.instance.getRecordings()
48 def standbyCounterChanged(self, configElement):
49 from Screens.Standby import inStandby
50 inStandby.onClose.append(self.leaveStandby)
51 recordings = NavigationInstance.instance.getRecordings()
52 NavigationInstance.instance.record_event.append(self.getRecordEvent)
54 self.setVoltage_PWM_Standby()
56 def createConfig(self):
57 def setVlt(fancontrol, fanid, configElement):
58 fancontrol.setVoltage(fanid, configElement.value)
59 def setPWM(fancontrol, fanid, configElement):
60 fancontrol.setPWM(fanid, configElement.value)
62 config.fans = ConfigSubList()
63 for fanid in range(self.getFanCount()):
64 fan = ConfigSubsection()
65 fan.vlt = ConfigSlider(default = 15, increment = 5, limits = (0, 255))
66 fan.pwm = ConfigSlider(default = 0, increment = 5, limits = (0, 255))
67 fan.vlt_standby = ConfigSlider(default = 5, increment = 5, limits = (0, 255))
68 fan.pwm_standby = ConfigSlider(default = 0, increment = 5, limits = (0, 255))
69 fan.vlt.addNotifier(boundFunction(setVlt, self, fanid))
70 fan.pwm.addNotifier(boundFunction(setPWM, self, fanid))
71 config.fans.append(fan)
73 def getConfig(self, fanid):
74 return config.fans[fanid]
76 def getFanCount(self):
79 def hasRPMSensor(self, fanid):
80 return os.path.exists("/proc/stb/fp/fan_speed")
82 def hasFanControl(self, fanid):
83 return os.path.exists("/proc/stb/fp/fan_vlt") or os.path.exists("/proc/stb/fp/fan_pwm")
85 def getFanSpeed(self, fanid):
86 f = open("/proc/stb/fp/fan_speed", "r")
87 value = int(f.readline().strip()[:-4])
91 def getVoltage(self, fanid):
92 f = open("/proc/stb/fp/fan_vlt", "r")
93 value = int(f.readline().strip(), 16)
97 def setVoltage(self, fanid, value):
100 f = open("/proc/stb/fp/fan_vlt", "w")
101 f.write("%x" % value)
104 def getPWM(self, fanid):
105 f = open("/proc/stb/fp/fan_pwm", "r")
106 value = int(f.readline().strip(), 16)
110 def setPWM(self, fanid, value):
113 f = open("/proc/stb/fp/fan_pwm", "w")
114 f.write("%x" % value)
117 fancontrol = FanControl()