LED Brightness Setup : Add new plugin
authorChang.H.S <jhs@dev3>
Thu, 8 Dec 2011 02:36:53 +0000 (11:36 +0900)
committerChang.H.S <jhs@dev3>
Thu, 8 Dec 2011 04:54:54 +0000 (13:54 +0900)
configure.ac
lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/Makefile.am [new file with mode: 0644]
lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/__init__.py [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/_ledsetup.so [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/ledsetup.py [new file with mode: 0644]
lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/meta/Makefile.am [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/meta/plugin_ledbrightnesssetup.xml [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/plugin.py [new file with mode: 0755]
lib/python/Plugins/SystemPlugins/Makefile.am

index 1b95bea..5ca12a5 100644 (file)
@@ -242,6 +242,8 @@ lib/python/Plugins/SystemPlugins/UIPositionSetup/meta/Makefile
 lib/python/Plugins/SystemPlugins/HDMICEC/Makefile
 lib/python/Plugins/SystemPlugins/HDMICEC/components/Makefile
 lib/python/Plugins/SystemPlugins/HDMICEC/meta/Makefile
 lib/python/Plugins/SystemPlugins/HDMICEC/Makefile
 lib/python/Plugins/SystemPlugins/HDMICEC/components/Makefile
 lib/python/Plugins/SystemPlugins/HDMICEC/meta/Makefile
+lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/Makefile
+lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/meta/Makefile
 lib/python/Tools/Makefile
 lib/service/Makefile
 lib/components/Makefile
 lib/python/Tools/Makefile
 lib/service/Makefile
 lib/components/Makefile
diff --git a/lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/Makefile.am b/lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/Makefile.am
new file mode 100644 (file)
index 0000000..371b83f
--- /dev/null
@@ -0,0 +1,9 @@
+installdir = $(pkglibdir)/python/Plugins/SystemPlugins/LEDBrightnessSetup
+
+SUBDIRS = meta
+
+install_PYTHON =       \
+       __init__.py \
+       plugin.py \
+       _ledsetup.so \
+       ledsetup.py
diff --git a/lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/__init__.py b/lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/__init__.py
new file mode 100755 (executable)
index 0000000..e69de29
diff --git a/lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/_ledsetup.so b/lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/_ledsetup.so
new file mode 100755 (executable)
index 0000000..810b2bc
Binary files /dev/null and b/lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/_ledsetup.so differ
diff --git a/lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/ledsetup.py b/lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/ledsetup.py
new file mode 100644 (file)
index 0000000..ad23636
--- /dev/null
@@ -0,0 +1,74 @@
+# This file was automatically generated by SWIG (http://www.swig.org).
+# Version 1.3.39
+#
+# Do not make changes to this file unless you know what you are doing--modify
+# the SWIG interface file instead.
+# This file is compatible with both classic and new-style classes.
+
+from sys import version_info
+if version_info >= (2,6,0):
+    def swig_import_helper():
+        from os.path import dirname
+        import imp
+        fp = None
+        try:
+            fp, pathname, description = imp.find_module('_ledsetup', [dirname(__file__)])
+        except ImportError:
+            import _ledsetup
+            return _ledsetup
+        if fp is not None:
+            try:
+                _mod = imp.load_module('_ledsetup', fp, pathname, description)
+            finally:
+                fp.close()
+                return _mod
+    _ledsetup = swig_import_helper()
+    del swig_import_helper
+else:
+    import _ledsetup
+del version_info
+try:
+    _swig_property = property
+except NameError:
+    pass # Python < 2.2 doesn't have 'property'.
+def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
+    if (name == "thisown"): return self.this.own(value)
+    if (name == "this"):
+        if type(value).__name__ == 'SwigPyObject':
+            self.__dict__[name] = value
+            return
+    method = class_type.__swig_setmethods__.get(name,None)
+    if method: return method(self,value)
+    if (not static) or hasattr(self,name):
+        self.__dict__[name] = value
+    else:
+        raise AttributeError("You cannot add attributes to %s" % self)
+
+def _swig_setattr(self,class_type,name,value):
+    return _swig_setattr_nondynamic(self,class_type,name,value,0)
+
+def _swig_getattr(self,class_type,name):
+    if (name == "thisown"): return self.this.own()
+    method = class_type.__swig_getmethods__.get(name,None)
+    if method: return method(self)
+    raise AttributeError(name)
+
+def _swig_repr(self):
+    try: strthis = "proxy of " + self.this.__repr__()
+    except: strthis = ""
+    return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
+
+try:
+    _object = object
+    _newclass = 1
+except AttributeError:
+    class _object : pass
+    _newclass = 0
+
+
+
+def LEDUpdate(*args):
+  return _ledsetup.LEDUpdate(*args)
+LEDUpdate = _ledsetup.LEDUpdate
+
+
diff --git a/lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/meta/Makefile.am b/lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/meta/Makefile.am
new file mode 100755 (executable)
index 0000000..4afcbc4
--- /dev/null
@@ -0,0 +1,3 @@
+installdir = $(datadir)/meta
+
+dist_install_DATA = plugin_ledbrightnesssetup.xml
diff --git a/lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/meta/plugin_ledbrightnesssetup.xml b/lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/meta/plugin_ledbrightnesssetup.xml
new file mode 100755 (executable)
index 0000000..e515faa
--- /dev/null
@@ -0,0 +1,16 @@
+<default>
+         <prerequisites>
+                    <tag type="System" />
+         </prerequisites>
+          <info>
+                    <author>hschang</author>
+                    <name>LED Brightness Setup</name>
+                    <packagename>enigma2-plugin-systemplugins-ledbrightnesssetup</packagename>
+                    <shortdescription>Setup LED brightness and blink interval</shortdescription>
+                    <description>Setup LED brightness and blink interval</description>
+        </info>
+        <files type="package">
+                    <file type="package" name="enigma2-plugin-systemplugins-ledbrightnesssetup" />
+        </files>
+
+</default>
diff --git a/lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/plugin.py b/lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/plugin.py
new file mode 100755 (executable)
index 0000000..8221d80
--- /dev/null
@@ -0,0 +1,138 @@
+from Screens.Screen import Screen
+from Components.ConfigList import ConfigListScreen
+from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigInteger
+from Components.ActionMap import ActionMap
+from Components.Sources.StaticText import StaticText
+from Plugins.Plugin import PluginDescriptor
+from Screens.MessageBox import MessageBox
+from Tools.Directories import fileExists
+from enigma import eTimer
+from ledsetup import LEDUpdate
+
+config.plugins.brightnesssetup = ConfigSubsection()
+config.plugins.brightnesssetup.brightness = ConfigInteger(default = 1, limits = (1,15))
+config.plugins.brightnesssetup.brightnessstandby = ConfigInteger(default = 5, limits = (1,15))
+config.plugins.brightnesssetup.brightnessdeepstandby = ConfigInteger(default = 5, limits = (1,15))
+config.plugins.brightnesssetup.blinkingtime = ConfigInteger(default = 5, limits = (1,15))
+
+class LEDOption:
+       BRIGHTNESS = 0
+       DEEPSTANDBY = 1
+       BLINKINGTIME = 2
+
+class LEDBrightnessSetupStandby:
+       def __init__(self):
+               self.initLEDSetup()
+               config.misc.standbyCounter.addNotifier(self.standbyBegin, initial_call = False)
+
+       def standbyBegin(self, configElement):
+               from Screens.Standby import inStandby
+               inStandby.onClose.append(self.StandbyEnd)
+               brightness = int(config.plugins.brightnesssetup.brightnessstandby.value)
+               LEDUpdate(brightness ,LEDOption.BRIGHTNESS)
+
+       def StandbyEnd(self):
+               brightness = int(config.plugins.brightnesssetup.brightness.value)
+               LEDUpdate(brightness ,LEDOption.BRIGHTNESS)
+
+       def initLEDSetup(self):
+               brightness = int(config.plugins.brightnesssetup.brightness.value)
+               brightnessstandby = int(config.plugins.brightnesssetup.brightnessdeepstandby.value)
+               blinkingtime = int(config.plugins.brightnesssetup.blinkingtime.value)
+               cmdList = []
+               cmdList.append( (brightness,LEDOption.BRIGHTNESS) )
+               cmdList.append( (brightnessstandby,LEDOption.DEEPSTANDBY) )
+               cmdList.append( (blinkingtime,LEDOption.BLINKINGTIME) )
+               for ( value, option ) in cmdList:
+                       ret = LEDUpdate(value ,option)
+                       if ret != 0:
+                               print "DEVICE OPEN ERROR"
+                               break;
+
+class LEDBrightnessSetup(Screen,ConfigListScreen):
+       skin = """
+                       <screen name="LEDBrightnessSetup" position="center,center" size="560,250" title="LED Brightness Setup" >
+                       <ePixmap pixmap="Vu_HD/buttons/red.png" position="10,10" size="25,25" alphatest="on" />
+                       <ePixmap pixmap="Vu_HD/buttons/green.png" position="290,10" size="25,25" alphatest="on" />
+                       <widget source="key_red" render="Label" position="40,10" zPosition="1" size="140,25" font="Regular;20" halign="center" valign="center" transparent="1" />
+                       <widget source="key_green" render="Label" position="320,10" zPosition="1" size="140,25" font="Regular;20" halign="center" valign="center" transparent="1" />
+                       <widget name="config" zPosition="2" position="5,50" size="550,200" scrollbarMode="showOnDemand" transparent="1" />
+                       </screen>"""
+
+       def __init__(self,session):
+               Screen.__init__(self,session)
+               self.session = session
+               self["shortcuts"] = ActionMap(["ShortcutActions", "SetupActions" ],
+               {
+                       "ok": self.keySave,
+                       "cancel": self.keyCancel,
+                       "red": self.keyCancel,
+                       "green": self.keySave,
+               }, -2)
+               self.list = []
+               ConfigListScreen.__init__(self, self.list,session = self.session)
+               self["key_red"] = StaticText(_("Cancel"))
+               self["key_green"] = StaticText(_("Ok"))
+               self.createSetup()
+               self.onLayoutFinish.append(self.checkModel)
+               self.checkModelTimer = eTimer()
+               self.checkModelTimer.callback.append(self.invalidmodel)
+
+       def getModel(self):
+               if fileExists("/proc/stb/info/vumodel"):
+                       vumodel = open("/proc/stb/info/vumodel")
+                       info=vumodel.read().strip()
+                       vumodel.close()
+                       if info == "ultimo":
+                               return True
+                       else:
+                               return False
+               else:
+                       return False
+
+       def checkModel(self):
+               if not self.getModel():
+                       self.checkModelTimer.start(100,True)
+
+       def invalidmodel(self):
+                       self.session.openWithCallback(self.close, MessageBox, _("This Plugin only support for ULTIMO"), MessageBox.TYPE_ERROR, timeout = 30)
+
+
+       def createSetup(self):
+               self.list = []
+               self.brightness = getConfigListEntry(_("Touch LED brightness at normal state"), config.plugins.brightnesssetup.brightness)
+               self.brightness_standby = getConfigListEntry(_("Touch LED brightness at Standby"), config.plugins.brightnesssetup.brightnessstandby)
+               self.brightness_deepstandby = getConfigListEntry(_("Touch LED brightness at Deep Standby"), config.plugins.brightnesssetup.brightnessdeepstandby)
+               self.blinkingtime = getConfigListEntry(_("Touch LED blinking time"), config.plugins.brightnesssetup.blinkingtime)
+               self.list.append( self.brightness )
+               self.list.append( self.brightness_standby )
+               self.list.append( self.brightness_deepstandby )
+               self.list.append( self.blinkingtime )
+               self["config"].list = self.list
+               self["config"].l.setList(self.list)
+
+       def saveLEDSetup(self):
+               brightness = int(config.plugins.brightnesssetup.brightness.value)
+               brightnessstandby = int(config.plugins.brightnesssetup.brightnessdeepstandby.value)
+               blinkingtime = int(config.plugins.brightnesssetup.blinkingtime.value)
+               cmdList = []
+               cmdList.append( (brightness,LEDOption.BRIGHTNESS) )
+               cmdList.append( (brightnessstandby,LEDOption.DEEPSTANDBY) )
+               cmdList.append( (blinkingtime,LEDOption.BLINKINGTIME) )
+               for ( value, option ) in cmdList:
+                       ret = LEDUpdate(value ,option)
+                       if ret != 0:
+                               self.session.open(MessageBox, "DEVICE OPEN ERROR", type = MessageBox.TYPE_ERROR, timeout = 30)
+                               break;
+
+       def keySave(self):
+               self.saveLEDSetup()
+               ConfigListScreen.keySave(self)
+
+def main(session, **kwargs):
+       session.open(LEDBrightnessSetup)
+
+def Plugins(**kwargs):
+       return [PluginDescriptor(name=_("LED Brightness Setup"), description="Setup LED brightness and blink interval", where = PluginDescriptor.WHERE_PLUGINMENU, needsRestart = False, fnc=main)]
+
+ledbrightnesssetupstandby = LEDBrightnessSetupStandby()
index da14371..a5c4b50 100755 (executable)
@@ -5,7 +5,7 @@ SUBDIRS = SoftwareManager FrontprocessorUpgrade PositionerSetup Satfinder \
        DefaultServicesScanner NFIFlash DiseqcTester CommonInterfaceAssignment \
        CrashlogAutoSubmit CleanupWizard VideoEnhancement WirelessLan NetworkWizard \
        TempFanControl FactoryTest Fancontrol FPGAUpgrade WirelessLanSetup ManualFancontrol \
        DefaultServicesScanner NFIFlash DiseqcTester CommonInterfaceAssignment \
        CrashlogAutoSubmit CleanupWizard VideoEnhancement WirelessLan NetworkWizard \
        TempFanControl FactoryTest Fancontrol FPGAUpgrade WirelessLanSetup ManualFancontrol \
-       Blindscan RemoteControlCode UI3DSetup UIPositionSetup HDMICEC
+       Blindscan RemoteControlCode UI3DSetup UIPositionSetup HDMICEC LEDBrightnessSetup
 
 install_PYTHON =       \
        __init__.py
 
 install_PYTHON =       \
        __init__.py