4 from datetime import datetime
6 from enigma import eTimer
7 from Components.config import ConfigSelection, ConfigSelectionNumber, ConfigSlider, ConfigYesNo
8 from Plugins.Plugin import PluginDescriptor
9 from fcntl import ioctl
11 from pngutil import png_util
12 pngutil = png_util.PNGUtil()
13 lcd4linuxPluginPath = "/usr/lib/enigma2/python/Plugins/Extensions/LCD4linux"
15 LCDType1_id_lver = "150"
18 from Plugins.Extensions.LCD4linux import plugin
20 def getResolution(t, r="0"):
22 ttt = LCD4linux.xmlLCDType.value.split("x")
23 MAX_W,MAX_H = int(ttt[0]),int(ttt[1])
28 elif t[1:] in ["3","4","5","10"]:
30 elif t[1:] in ["6","9","11","12"]:
32 elif t[1:] in ["7","8","13"]:
33 MAX_W,MAX_H = 1024,600
41 MAX_W,MAX_H = LCD4linux.SizeW.value,LCD4linux.SizeH.value
42 elif t[1:] == "50": # vuduo2
45 MAX_W,MAX_H = MAX_H,MAX_W
48 plugin_writeHelligkeit = None
51 def writeHelligkeit_lver(hell):
54 global plugin_writeHelligkeit
55 global LCDType1_id_lver
56 plugin_writeHelligkeit(hell)
57 if plugin.config.plugins.LCD4linux.LCDType1.value == LCDType1_id_lver:
59 g_min, g_max = getHellRange(plugin.config.plugins.LCD4linux.Helligkeit)
60 updateBrightness(int(hell), g_min, g_max)
62 def writeHelligkeit(hell,hell2,STOP = False):
66 global plugin_writeHelligkeit
68 plugin_writeHelligkeit(hell, hell2, STOP)
69 if plugin.LCD4linux.LCDType1.value == LCDType1_id:
71 g_min, g_max = getHellRange(plugin.LCD4linux.Helligkeit)
72 updateBrightness(int(hell), g_min, g_max)
74 def getHellRange(ins):
76 if isinstance(ins, ConfigSelectionNumber):
78 for s in ins.choices.choices:
79 choices.append(int(s))
80 return (min(choices), max(choices))
81 elif isinstance(ins, ConfigSlider):
82 return (ins.min, ins.max)
89 def updateBrightness(hell, _min, _max):
91 if _min == _max: return
92 hell = int( 255*hell/(_max - _min) )
100 print "[LCD4linux Support] update Brightness : ",hell
101 led_fd = open("/dev/lcd2",'rw')
102 ioctl(led_fd, 0x10, hell)
109 self.PIC = "/tmp/dpf"
110 self.updateTimer = eTimer()
111 self.updateTimer.callback.append(self.updateLCD)
112 self.pngutilconnect = pngutil.connect()
113 self.last_mod_time = 0
114 self.oldPluginVer = False
116 def startUpdateTimer(self):
117 if self.pngutilconnect :
118 self.updateTimer.start(1000, True)
121 self.updateTimer.stop()
122 if self.oldPluginVer:
123 lcd = plugin.config.plugins.LCD4linux.LCDType1.value
125 lcd = plugin.LCD4linux.LCDType1.value
127 if os.path.exists(self.PIC):
128 modify_time = os.stat(self.PIC).st_mtime
129 if modify_time != self.last_mod_time:
130 self.last_mod_time = modify_time
132 pngutil.send(self.PIC)
133 print "[LCD4linux Support] time (write to lcd) : ",time()-pngutiltime
134 self.updateTimer.start(500, True)
136 def setLcd4linuxDuo2(self):
137 global plugin_writeHelligkeit
139 lcdtype = plugin.LCDType
140 print "[LCD4linux Support] set LCD4linux for DUO2 (ver %s)"%plugin.Version
141 if plugin.Version == "V0.8r3":
142 global LCDType1_id_lver
143 self.oldPluginVer = True
144 lcdtype.append((LCDType1_id_lver, _("Vu+ Duo2 LCD 400x240")))
145 plugin.config.plugins.LCD4linux.LCDType1 = ConfigSelection(choices = lcdtype, default=LCDType1_id_lver)
146 plugin.config.plugins.LCD4linux.Standby = ConfigSelection(choices = [("0", _("off")), ("1", _("on"))], default="0")
147 plugin.config.plugins.LCD4linux.Thread = ConfigYesNo(default = True)
148 plugin.config.plugins.LCD4linux.Helligkeit = ConfigSlider(default = 1, limits = (0, 7))
149 plugin_writeHelligkeit = plugin.writeHelligkeit
150 plugin.writeHelligkeit = writeHelligkeit_lver
153 lcdtype.append((LCDType1_id, _("Vu+ Duo2 LCD 400x240")))
154 plugin.LCD4linux.LCDType1 = ConfigSelection(choices = lcdtype, default=LCDType1_id)
155 plugin.LCD4linux.Standby = ConfigSelection(choices = [("0", _("off")), ("1", _("on"))], default="0")
156 plugin.LCD4linux.Helligkeit = ConfigSelectionNumber(0, 10, 1, default = 2)
157 plugin_writeHelligkeit = plugin.writeHelligkeit
158 plugin.writeHelligkeit = writeHelligkeit
159 plugin.getResolution = getResolution
160 self.PIC = plugin.PIC+".png"
165 pngutiltimer = pngUtilTimer()
167 def lcdtimer(reason, **kwargs):
168 if pngutiltimer.setLcd4linuxDuo2():
169 pngutiltimer.startUpdateTimer()
171 def Plugins(**kwargs):
173 global lcd4linuxPluginPath
174 if os.path.exists(lcd4linuxPluginPath+"/plugin.py"):
176 PluginDescriptor(name="LCD4linuxSupport",
177 description="LCD4linuxSupport",
178 where = [PluginDescriptor.WHERE_SESSIONSTART],