lib/python/Plugins/SystemPlugins/Hotplug/Makefile
lib/python/Plugins/SystemPlugins/Hotplug/meta/Makefile
lib/python/Plugins/SystemPlugins/Makefile
+lib/python/Plugins/SystemPlugins/TempFanControl/Makefile
lib/python/Plugins/SystemPlugins/NetworkWizard/Makefile
lib/python/Plugins/SystemPlugins/NetworkWizard/meta/Makefile
lib/python/Plugins/SystemPlugins/NFIFlash/Makefile
ConditionalShowHide.py ServicePosition.py ValueRange.py RdsInfo.py Streaming.py \
StaticMultiList.py ServiceTime.py MovieInfo.py MenuEntryCompare.py StringListSelection.py \
ValueBitTest.py TunerInfo.py ConfigEntryTest.py TemplatedMultiContent.py ProgressToText.py \
- Combine.py
+ Combine.py SensorToText.py
--- /dev/null
+from Components.Converter.Converter import Converter
+
+class SensorToText(Converter, object):
+ def __init__(self, arguments):
+ Converter.__init__(self, arguments)
+
+ def getText(self):
+ return "%d %s" % (self.source.getValue(), self.source.getUnit())
+
+ text = property(getText)
+
+
\ No newline at end of file
--- /dev/null
+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()):
+ default_vlt = self.getVoltage(fanid)
+ default_pwm = self.getPWM(fanid)
+ fan = ConfigSubsection()
+ fan.vlt = ConfigSlider(default = default_vlt, increment = 10, limits = (0, 255))
+ fan.pwm = ConfigSlider(default = default_vlt, increment = 10, 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
Element.py Playlist.py ParentalControl.py ParentalControlList.py \
Ipkg.py SelectionList.py Scanner.py SystemInfo.py DreamInfoHandler.py \
Task.py language_cache.py Console.py ResourceManager.py TuneTest.py \
- Keyboard.py
+ Keyboard.py Sensors.py FanControl.py
--- /dev/null
+from Components.FanControl import fancontrol
+
+class Sensors:
+ # (type, name, unit, directory)
+ TYPE_TEMPERATURE = 0
+ # (type, name, unit, fanid)
+ TYPE_FAN_RPM = 1
+
+ def __init__(self):
+ # (type, name, unit, sensor_specific_dict/list)
+ self.sensors_list = []
+ self.addSensors()
+
+ def getSensorsCount(self, type = None):
+ if type is None:
+ return len(self.sensors_list)
+ count = 0
+ for sensor in self.sensors_list:
+ if sensor[0] == type:
+ count += 1
+ return count
+
+ # returns a list of sensorids of type "type"
+ def getSensorsList(self, type = None):
+ if type is None:
+ return range(len(self.sensors_list))
+ list = []
+ for sensorid in range(len(self.sensors_list)):
+ if self.sensors_list[sensorid][0] == type:
+ list.append(sensorid)
+ return list
+
+
+ def getSensorType(self, sensorid):
+ return self.sensors_list[sensorid][0]
+
+ def getSensorName(self, sensorid):
+ return self.sensors_list[sensorid][1]
+
+ def getSensorValue(self, sensorid):
+ value = -1
+ sensor = self.sensors_list[sensorid]
+ if sensor[0] == self.TYPE_TEMPERATURE:
+ f = open("%s/value" % sensor[3], "r")
+ value = int(f.readline().strip())
+ f.close()
+ elif sensor[0] == self.TYPE_FAN_RPM:
+ value = fancontrol.getFanSpeed(sensor[3])
+ return value
+
+ def getSensorUnit(self, sensorid):
+ return self.sensors_list[sensorid][2]
+
+ def addSensors(self):
+ import os
+ if os.path.exists("/proc/stb/sensors"):
+ for dirname in os.listdir("/proc/stb/sensors"):
+ if dirname.find("temp", 0, 4) == 0:
+ f = open("/proc/stb/sensors/%s/name" % dirname, "r")
+ name = f.readline().strip()
+ f.close()
+
+ f = open("/proc/stb/sensors/%s/unit" % dirname, "r")
+ unit = f.readline().strip()
+ f.close()
+
+ self.sensors_list.append((self.TYPE_TEMPERATURE, name, unit, "/proc/stb/sensors/%s" % dirname))
+ for fanid in range(fancontrol.getFanCount()):
+ if fancontrol.hasRPMSensor(fanid):
+ self.sensors_list.append((self.TYPE_FAN_RPM, _("fan"), "rpm", fanid))
+
+sensors = Sensors()
\ No newline at end of file
__init__.py Clock.py EventInfo.py Source.py List.py CurrentService.py \
FrontendStatus.py Boolean.py Config.py ServiceList.py RdsDecoder.py StreamService.py \
StaticText.py CanvasSource.py ServiceEvent.py Event.py FrontendInfo.py TunerInfo.py \
- RecordState.py Progress.py
+ RecordState.py Progress.py Sensor.py
--- /dev/null
+from Components.Sensors import sensors
+
+from enigma import eTimer
+
+from Source import Source
+
+class SensorSource(Source):
+ def __init__(self, update_interval = 500, sensorid = 0):
+ self.update_interval = update_interval
+ self.sensorid = sensorid
+ Source.__init__(self)
+
+ self.update_timer = eTimer()
+ self.update_timer.callback.append(self.updateValue)
+ self.update_timer.start(self.update_interval)
+
+ def getValue(self):
+ return sensors.getSensorValue(self.sensorid)
+
+ def getUnit(self):
+ return sensors.getSensorUnit(self.sensorid)
+
+ def updateValue(self):
+ self.changed((self.CHANGED_POLL,))
+
+ def destroy(self):
+ self.update_timer.callback.remove(self.updateValue)
SUBDIRS = SoftwareManager FrontprocessorUpgrade PositionerSetup Satfinder \
SkinSelector SatelliteEquipmentControl Videomode VideoTune Hotplug \
DefaultServicesScanner NFIFlash DiseqcTester CommonInterfaceAssignment \
- CrashlogAutoSubmit CleanupWizard VideoEnhancement WirelessLan NetworkWizard
+ CrashlogAutoSubmit CleanupWizard VideoEnhancement WirelessLan NetworkWizard \
+ TempFanControl
install_PYTHON = \
__init__.py
--- /dev/null
+installdir = $(LIBDIR)/enigma2/python/Plugins/SystemPlugins/TempFanControl
+
+install_PYTHON = \
+ __init__.py \
+ plugin.py
--- /dev/null
+from Components.ActionMap import ActionMap
+from Components.Sensors import sensors
+from Components.Sources.Sensor import SensorSource
+from Components.ConfigList import ConfigListScreen
+from Components.config import getConfigListEntry
+
+from Screens.Screen import Screen
+
+from Plugins.Plugin import PluginDescriptor
+from Components.FanControl import fancontrol
+
+class TempFanControl(Screen, ConfigListScreen):
+ skin = """
+ <screen position="100,100" size="550,400" title="Fan Control" >
+ <!--widget name="text" position="0,0" size="550,400" font="Regular;15" /-->
+ <widget source="SensorTemp" render="Label" position="380,300" zPosition="1" size="150,20" font="Regular;19" halign="right">
+ <convert type="SensorToText"></convert>
+ </widget>
+ <widget source="SensorFan" render="Label" position="380,325" zPosition="1" size="150,20" font="Regular;19" halign="right">
+ <convert type="SensorToText"></convert>
+ </widget>
+ <widget name="config" position="10,10" size="500,225" scrollbarMode="showOnDemand" />
+ </screen>"""
+
+ def __init__(self, session, args = None):
+ Screen.__init__(self, session)
+
+ id = sensors.getSensorsList(sensors.TYPE_TEMPERATURE)[0]
+ self["SensorTemp"] = SensorSource(sensorid = id)
+ id = sensors.getSensorsList(sensors.TYPE_FAN_RPM)[0]
+ self["SensorFan"] = SensorSource(sensorid = id, update_interval = 100)
+
+ self.list = []
+ if fancontrol.getFanCount() > 0:
+ self.list.append(getConfigListEntry(_("Fan Voltage"), fancontrol.getConfig(0).vlt))
+ self.list.append(getConfigListEntry(_("Fan PWM"), fancontrol.getConfig(0).pwm))
+ ConfigListScreen.__init__(self, self.list, session = self.session)
+ #self["config"].list = self.list
+ #self["config"].setList(self.list)
+
+ self["actions"] = ActionMap(["OkCancelActions"],
+ {
+ "ok": self.save,
+ "cancel": self.revert
+ }, -1)
+
+ def save(self):
+ fancontrol.getConfig(0).vlt.save()
+ fancontrol.getConfig(0).pwm.save()
+ self.close()
+
+ def revert(self):
+ fancontrol.getConfig(0).vlt.load()
+ fancontrol.getConfig(0).pwm.load()
+ self.close()
+
+def main(session, **kwargs):
+ session.open(TempFanControl)
+
+def Plugins(**kwargs):
+ return PluginDescriptor(name = "Temperature and Fan control", description = _("Temperature and Fan control"), where = PluginDescriptor.WHERE_EXTENSIONSMENU, fnc = main)
+
\ No newline at end of file