explicit support for 2nd frontpanel led, allow customizable on/off patterns
[enigma2.git] / lib / python / Components / Renderer / FrontpanelLed.py
1 from Components.Element import Element
2
3 # this is not a GUI renderer.
4 class FrontpanelLed(Element):
5         def __init__(self, which = 0, pattern_on = (20, 0x55555555, 0x84fc8c04), pattern_off = (20, 0, 0xffffffff)):
6                 self.which = which
7                 self.pattern_on = pattern_on
8                 self.pattern_off = pattern_off
9                 Element.__init__(self)
10
11         def changed(self, *args, **kwargs):
12                 if self.source.boolean:
13                         (speed, pattern, pattern_4bit) = self.pattern_on
14                 else:
15                         (speed, pattern, pattern_4bit) = self.pattern_off
16
17                 try:
18                         open("/proc/stb/fp/led%d_pattern" % self.which, "w").write("%08x" % pattern)
19                 except IOError:
20                         pass
21                 if self.which == 0:
22                         try:
23                                 open("/proc/stb/fp/led_pattern", "w").write("%08x" % pattern_4bit)
24                         except IOError:
25                                 pass
26                         try:
27                                 open("/proc/stb/fp/led_pattern_speed", "w").write("%d" % speed)
28                         except IOError:
29                                 pass