explicit support for 2nd frontpanel led, allow customizable on/off patterns
authorFelix Domke <tmbinc@elitedvb.net>
Wed, 20 May 2009 14:56:05 +0000 (16:56 +0200)
committerFelix Domke <tmbinc@elitedvb.net>
Wed, 20 May 2009 14:56:05 +0000 (16:56 +0200)
lib/python/Components/Renderer/FrontpanelLed.py

index ec230d1..408f1c9 100644 (file)
@@ -2,25 +2,28 @@ from Components.Element import Element
 
 # this is not a GUI renderer.
 class FrontpanelLed(Element):
 
 # this is not a GUI renderer.
 class FrontpanelLed(Element):
+       def __init__(self, which = 0, pattern_on = (20, 0x55555555, 0x84fc8c04), pattern_off = (20, 0, 0xffffffff)):
+               self.which = which
+               self.pattern_on = pattern_on
+               self.pattern_off = pattern_off
+               Element.__init__(self)
+
        def changed(self, *args, **kwargs):
        def changed(self, *args, **kwargs):
-               if self.source.value:
-                       pattern = 0x55555555
-                       pattern_4bit = 0x84fc8c04
-                       speed = 20
+               if self.source.boolean:
+                       (speed, pattern, pattern_4bit) = self.pattern_on
                else:
                else:
-                       pattern = 0
-                       pattern_4bit = 0xffffffff
-                       speed = 1
+                       (speed, pattern, pattern_4bit) = self.pattern_off
 
                try:
 
                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
                except IOError:
                        pass
+               if self.which == 0:
+                       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)
+                       except IOError:
+                               pass