1 from Components.ActionMap import ActionMap
2 from Components.Sensors import sensors
3 from Components.Sources.Sensor import SensorSource
4 from Components.Sources.StaticText import StaticText
5 from Components.ConfigList import ConfigListScreen
6 from Components.config import getConfigListEntry
8 from Screens.Screen import Screen
10 from Plugins.Plugin import PluginDescriptor
11 from Components.FanControl import fancontrol
13 class TempFanControl(Screen, ConfigListScreen):
15 <screen position="90,100" size="570,420" title="Fan Control" >
16 <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
17 <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
18 <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
19 <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />
20 <widget source="red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
21 <widget source="green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
22 <widget source="yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
23 <widget source="blue" render="Label" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />
25 <widget name="config" position="10,50" size="550,90" scrollbarMode="showOnDemand" />
27 <widget source="SensorTempText0" render="Label" position="10,150" zPosition="1" size="90,40" font="Regular;20" halign="left" valign="top" backgroundColor="#9f1313" transparent="1" />
28 <widget source="SensorTemp0" render="Label" position="100,150" zPosition="1" size="100,20" font="Regular;19" halign="right">
29 <convert type="SensorToText"></convert>
31 <widget source="SensorTempText1" render="Label" position="10,170" zPosition="1" size="90,40" font="Regular;20" halign="left" valign="top" backgroundColor="#9f1313" transparent="1" />
32 <widget source="SensorTemp1" render="Label" position="100,170" zPosition="1" size="100,20" font="Regular;19" halign="right">
33 <convert type="SensorToText"></convert>
35 <widget source="SensorTempText2" render="Label" position="10,190" zPosition="1" size="90,40" font="Regular;20" halign="left" valign="top" backgroundColor="#9f1313" transparent="1" />
36 <widget source="SensorTemp2" render="Label" position="100,190" zPosition="1" size="100,20" font="Regular;19" halign="right">
37 <convert type="SensorToText"></convert>
39 <widget source="SensorTempText3" render="Label" position="10,210" zPosition="1" size="90,40" font="Regular;20" halign="left" valign="top" backgroundColor="#9f1313" transparent="1" />
40 <widget source="SensorTemp3" render="Label" position="100,210" zPosition="1" size="100,20" font="Regular;19" halign="right">
41 <convert type="SensorToText"></convert>
43 <widget source="SensorTempText4" render="Label" position="10,230" zPosition="1" size="90,40" font="Regular;20" halign="left" valign="top" backgroundColor="#9f1313" transparent="1" />
44 <widget source="SensorTemp4" render="Label" position="100,230" zPosition="1" size="100,20" font="Regular;19" halign="right">
45 <convert type="SensorToText"></convert>
47 <widget source="SensorTempText5" render="Label" position="10,250" zPosition="1" size="90,40" font="Regular;20" halign="left" valign="top" backgroundColor="#9f1313" transparent="1" />
48 <widget source="SensorTemp5" render="Label" position="100,250" zPosition="1" size="100,20" font="Regular;19" halign="right">
49 <convert type="SensorToText"></convert>
51 <widget source="SensorTempText6" render="Label" position="10,270" zPosition="1" size="90,40" font="Regular;20" halign="left" valign="top" backgroundColor="#9f1313" transparent="1" />
52 <widget source="SensorTemp6" render="Label" position="100,270" zPosition="1" size="100,20" font="Regular;19" halign="right">
53 <convert type="SensorToText"></convert>
55 <widget source="SensorTempText7" render="Label" position="10,290" zPosition="1" size="90,40" font="Regular;20" halign="left" valign="top" backgroundColor="#9f1313" transparent="1" />
56 <widget source="SensorTemp7" render="Label" position="100,290" zPosition="1" size="100,20" font="Regular;19" halign="right">
57 <convert type="SensorToText"></convert>
60 <widget source="SensorFanText0" render="Label" position="290,150" zPosition="1" size="90,40" font="Regular;20" halign="left" valign="top" backgroundColor="#9f1313" transparent="1" />
61 <widget source="SensorFan0" render="Label" position="380,150" zPosition="1" size="150,20" font="Regular;19" halign="right">
62 <convert type="SensorToText"></convert>
64 <widget source="SensorFanText1" render="Label" position="290,170" zPosition="1" size="90,40" font="Regular;20" halign="left" valign="top" backgroundColor="#9f1313" transparent="1" />
65 <widget source="SensorFan1" render="Label" position="380,170" zPosition="1" size="150,20" font="Regular;19" halign="right">
66 <convert type="SensorToText"></convert>
68 <widget source="SensorFanText2" render="Label" position="290,190" zPosition="1" size="90,40" font="Regular;20" halign="left" valign="top" backgroundColor="#9f1313" transparent="1" />
69 <widget source="SensorFan2" render="Label" position="380,190" zPosition="1" size="150,20" font="Regular;19" halign="right">
70 <convert type="SensorToText"></convert>
72 <widget source="SensorFanText3" render="Label" position="290,210" zPosition="1" size="90,40" font="Regular;20" halign="left" valign="top" backgroundColor="#9f1313" transparent="1" />
73 <widget source="SensorFan3" render="Label" position="380,210" zPosition="1" size="150,20" font="Regular;19" halign="right">
74 <convert type="SensorToText"></convert>
76 <widget source="SensorFanText4" render="Label" position="290,230" zPosition="1" size="90,40" font="Regular;20" halign="left" valign="top" backgroundColor="#9f1313" transparent="1" />
77 <widget source="SensorFan4" render="Label" position="380,230" zPosition="1" size="150,20" font="Regular;19" halign="right">
78 <convert type="SensorToText"></convert>
80 <widget source="SensorFanText5" render="Label" position="290,250" zPosition="1" size="90,40" font="Regular;20" halign="left" valign="top" backgroundColor="#9f1313" transparent="1" />
81 <widget source="SensorFan5" render="Label" position="380,250" zPosition="1" size="150,20" font="Regular;19" halign="right">
82 <convert type="SensorToText"></convert>
84 <widget source="SensorFanText6" render="Label" position="290,270" zPosition="1" size="90,40" font="Regular;20" halign="left" valign="top" backgroundColor="#9f1313" transparent="1" />
85 <widget source="SensorFan6" render="Label" position="380,270" zPosition="1" size="150,20" font="Regular;19" halign="right">
86 <convert type="SensorToText"></convert>
88 <widget source="SensorFanText7" render="Label" position="290,290" zPosition="1" size="90,40" font="Regular;20" halign="left" valign="top" backgroundColor="#9f1313" transparent="1" />
89 <widget source="SensorFan7" render="Label" position="380,290" zPosition="1" size="150,20" font="Regular;19" halign="right">
90 <convert type="SensorToText"></convert>
94 def __init__(self, session, args = None):
95 Screen.__init__(self, session)
97 templist = sensors.getSensorsList(sensors.TYPE_TEMPERATURE)
98 tempcount = len(templist)
99 fanlist = sensors.getSensorsList(sensors.TYPE_FAN_RPM)
100 fancount = len(fanlist)
102 self["red"] = StaticText(_("Cancel"))
103 self["green"] = StaticText(_("OK"))
104 self["yellow"] = StaticText("")
105 self["blue"] = StaticText("")
107 for count in range(8):
108 if count < tempcount:
110 self["SensorTempText%d" % count] = StaticText(sensors.getSensorName(id))
111 self["SensorTemp%d" % count] = SensorSource(sensorid = id)
113 self["SensorTempText%d" % count] = StaticText("")
114 self["SensorTemp%d" % count] = SensorSource()
118 self["SensorFanText%d" % count] = StaticText(sensors.getSensorName(id))
119 self["SensorFan%d" % count] = SensorSource(sensorid = id)
121 self["SensorFanText%d" % count] = StaticText("")
122 self["SensorFan%d" % count] = SensorSource()
125 for count in range(fancontrol.getFanCount()):
126 self.list.append(getConfigListEntry(_("Fan %d Voltage") % (count + 1), fancontrol.getConfig(count).vlt))
127 self.list.append(getConfigListEntry(_("Fan %d PWM") % (count + 1), fancontrol.getConfig(count).pwm))
128 ConfigListScreen.__init__(self, self.list, session = self.session)
129 #self["config"].list = self.list
130 #self["config"].setList(self.list)
132 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
135 "cancel": self.revert,
141 for count in range(fancontrol.getFanCount()):
142 fancontrol.getConfig(count).vlt.save()
143 fancontrol.getConfig(count).pwm.save()
147 for count in range(fancontrol.getFanCount()):
148 fancontrol.getConfig(count).vlt.load()
149 fancontrol.getConfig(count).pwm.load()
152 def main(session, **kwargs):
153 session.open(TempFanControl)
155 def startMenu(menuid):
156 if menuid != "system":
159 return [(_("Temperature and Fan control"), main, "tempfancontrol", 80)]
161 def Plugins(**kwargs):
162 return PluginDescriptor(name = "Temperature and Fan control", description = _("Temperature and Fan control"), where = PluginDescriptor.WHERE_MENU, fnc = startMenu)