Merge branch 'bug_236_recordpath' into experimental
[enigma2.git] / lib / python / Components / Renderer / FrontpanelLed.py
index cd329b562cebf98e1e1329562260c5e71c0c1736..f896ecdeee5f51628e4428dfc67422cfbf3cba65 100644 (file)
@@ -2,28 +2,31 @@ from Components.Element import Element
 
 # this is not a GUI renderer.
 class FrontpanelLed(Element):
-       def __init__(self):
+       def __init__(self, which = 0, patterns = [(20, 0, 0xffffffff),(20, 0x55555555, 0x84fc8c04)], boolean = True):
+               self.which = which
+               self.boolean = boolean
+               self.patterns = patterns
                Element.__init__(self)
 
        def changed(self, *args, **kwargs):
-               if self.source.value or 1:
-                       pattern = 0x55555555
-                       pattern_4bit = 0x84fc8c04
-                       speed = 20
+               if self.boolean:
+                       val = self.source.boolean and 0 or 1
                else:
-                       pattern = 0
-                       pattern_4bit = 0xffffffff
-                       speed = 1
+                       val = self.source.value
+       
+               (speed, pattern, pattern_4bit) = self.patterns[val]
 
                try:
-                       open("/proc/stb/fp/led0_pattern", "w").write("%08x" % pattern)
-               except IOError:
-                       pass
-               try:
-                       open("/proc/stb/fp/led_pattern", "w").write("%08x" % pattern_4bit)
-               except IOError:
-                       pass
-               try:
-                       open("/proc/stb/fp/led_pattern_speed", "w").write("%d" % speed)
+                       open("/proc/stb/fp/led%d_pattern" % self.which, "w").write("%08x" % pattern)
                except IOError:
                        pass
+               if self.which == 0:
+                       try:
+                               open("/proc/stb/fp/led_set_pattern", "w").write("%08x" % pattern_4bit)
+                               open("/proc/stb/fp/led_set_speed", "w").write("%d" % speed)
+                       except IOError:
+                               pass
+                       try:
+                               open("/proc/stb/fp/led_pattern_speed", "w").write("%d" % speed)
+                       except IOError:
+                               pass