LED Brightness Setup : setLED is moved in eDBoxLCD, fix integer to slider.
authorChang.H.S <jhs@dev3>
Thu, 8 Dec 2011 08:18:45 +0000 (17:18 +0900)
committerChang.H.S <jhs@dev3>
Fri, 9 Dec 2011 01:51:11 +0000 (10:51 +0900)
lib/gdi/lcd.cpp
lib/gdi/lcd.h [changed mode: 0644->0755]
lib/python/Components/Lcd.py [changed mode: 0644->0755]
lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/Makefile.am
lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/_ledsetup.so [deleted file]
lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/ledsetup.py [deleted file]
lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/plugin.py

index 794e9ab..931d41c 100755 (executable)
@@ -124,6 +124,23 @@ void eDBoxLCD::setInverted(unsigned char inv)
        update();
 }
 
+int eDBoxLCD::setLED(int value, int option)
+{
+       switch(option)
+       {
+               case LED_BRIGHTNESS:
+                       ioctl(lcdfd, LED_IOCTL_BRIGHTNESS_NORMAL, (unsigned char)value);
+                       break;
+               case LED_DEEPSTANDBY:
+                       ioctl(lcdfd, LED_IOCTL_BRIGHTNESS_DEEPSTANDBY, (unsigned char)value);
+                       break;
+               case LED_BLINKINGTIME:
+                       ioctl(lcdfd, LED_IOCTL_BLINKING_TIME, (unsigned char)value);
+                       break;
+       }
+       return 0;
+}
+
 int eDBoxLCD::setLCDContrast(int contrast)
 {
 #ifndef NO_LCD
old mode 100644 (file)
new mode 100755 (executable)
index e7b4c2c..9b83352
 #define LCD_BRIGHTNESS_MIN 0
 #define LCD_BRIGHTNESS_MAX 255
 
+enum op { LED_BRIGHTNESS = 0, LED_DEEPSTANDBY, LED_BLINKINGTIME };
+
+#define LED_IOCTL_BRIGHTNESS_NORMAL 0X10
+#define LED_IOCTL_BRIGHTNESS_DEEPSTANDBY 0X11
+#define LED_IOCTL_BLINKING_TIME 0X12
+
 class eLCD
 {
 #ifdef SWIG
@@ -54,6 +60,7 @@ public:
        ~eDBoxLCD();
 #endif
        static eDBoxLCD *getInstance();
+       int setLED(int value, int option);
        int setLCDContrast(int contrast);
        int setLCDBrightness(int brightness);
        void setInverted( unsigned char );
old mode 100644 (file)
new mode 100755 (executable)
index 371b83f..ef06b49 100644 (file)
@@ -4,6 +4,4 @@ SUBDIRS = meta
 
 install_PYTHON =       \
        __init__.py \
-       plugin.py \
-       _ledsetup.so \
-       ledsetup.py
+       plugin.py
diff --git a/lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/_ledsetup.so b/lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/_ledsetup.so
deleted file mode 100755 (executable)
index 810b2bc..0000000
Binary files a/lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/_ledsetup.so and /dev/null differ
diff --git a/lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/ledsetup.py b/lib/python/Plugins/SystemPlugins/LEDBrightnessSetup/ledsetup.py
deleted file mode 100644 (file)
index ad23636..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-# 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
-
-
index 8221d80..a679237 100755 (executable)
@@ -1,19 +1,21 @@
 from Screens.Screen import Screen
 from Components.ConfigList import ConfigListScreen
-from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigInteger
+from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSlider
 from Components.ActionMap import ActionMap
 from Components.Sources.StaticText import StaticText
+from Components.Label import Label
 from Plugins.Plugin import PluginDescriptor
 from Screens.MessageBox import MessageBox
 from Tools.Directories import fileExists
 from enigma import eTimer
+from enigma import eDBoxLCD
 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))
+config.plugins.brightnesssetup.brightness = ConfigSlider(default = 1, increment = 1, limits = (0,15))
+config.plugins.brightnesssetup.brightnessstandby = ConfigSlider(default = 1, increment = 1, limits = (0,15))
+config.plugins.brightnesssetup.brightnessdeepstandby = ConfigSlider(default = 5, increment = 1, limits = (0,15))
+config.plugins.brightnesssetup.blinkingtime = ConfigSlider(default = 5, increment = 1, limits = (0,15))
 
 class LEDOption:
        BRIGHTNESS = 0
@@ -29,34 +31,31 @@ class LEDBrightnessSetupStandby:
                from Screens.Standby import inStandby
                inStandby.onClose.append(self.StandbyEnd)
                brightness = int(config.plugins.brightnesssetup.brightnessstandby.value)
-               LEDUpdate(brightness ,LEDOption.BRIGHTNESS)
+               eDBoxLCD.getInstance().setLED(brightness ,LEDOption.BRIGHTNESS)
 
        def StandbyEnd(self):
                brightness = int(config.plugins.brightnesssetup.brightness.value)
-               LEDUpdate(brightness ,LEDOption.BRIGHTNESS)
+               eDBoxLCD.getInstance().setLED(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;
+               eDBoxLCD.getInstance().setLED(brightness ,LEDOption.BRIGHTNESS)
+               eDBoxLCD.getInstance().setLED(brightnessstandby ,LEDOption.DEEPSTANDBY)
+               eDBoxLCD.getInstance().setLED(blinkingtime ,LEDOption.BLINKINGTIME)
 
 class LEDBrightnessSetup(Screen,ConfigListScreen):
        skin = """
-                       <screen name="LEDBrightnessSetup" position="center,center" size="560,250" title="LED Brightness Setup" >
+                       <screen name="LEDBrightnessSetup" position="center,center" size="560,300" 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" />
+                       <ePixmap pixmap="Vu_HD/buttons/green.png" position="195,10" size="25,25" alphatest="on" />
+                       <ePixmap pixmap="Vu_HD/buttons/yellow.png" position="380,10" size="25,25" alphatest="on" />
+                       <widget source="key_red" render="Label" position="30,10" zPosition="1" size="140,25" font="Regular;20" halign="center" valign="center" transparent="1" />
+                       <widget source="key_green" render="Label" position="215,10" zPosition="1" size="140,25" font="Regular;20" halign="center" valign="center" transparent="1" />
+                       <widget source="key_yellow" render="Label" position="400,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"/>
+                       <widget name="current_entry" position="130,240" size="300,30" font="Regular;18" halign="center" valign="center"/>
                        </screen>"""
 
        def __init__(self,session):
@@ -68,15 +67,31 @@ class LEDBrightnessSetup(Screen,ConfigListScreen):
                        "cancel": self.keyCancel,
                        "red": self.keyCancel,
                        "green": self.keySave,
+                       "yellow": self.keyDefault,
                }, -2)
                self.list = []
                ConfigListScreen.__init__(self, self.list,session = self.session)
                self["key_red"] = StaticText(_("Cancel"))
                self["key_green"] = StaticText(_("Ok"))
+               self["key_yellow"] = StaticText(_("Defalut"))
+               self["current_entry"]=Label("")
                self.createSetup()
                self.onLayoutFinish.append(self.checkModel)
                self.checkModelTimer = eTimer()
                self.checkModelTimer.callback.append(self.invalidmodel)
+               if not self.displayText in self["config"].onSelectionChanged:
+                       self["config"].onSelectionChanged.append(self.displayText)
+
+       def displayText(self):
+               if self["config"].getCurrent() == self.brightness:
+                       self["current_entry"].setText("Touch LED Brightness at Normal state")
+               elif self["config"].getCurrent() == self.brightness_standby:
+                       self["current_entry"].setText("Touch LED Brightness at Standby")
+               elif self["config"].getCurrent() == self.brightness_deepstandby:
+                       self["current_entry"].setText("Touch LED Brightness at Deep Standby")
+               elif self["config"].getCurrent() == self.blinkingtime:
+                       self["current_entry"].setText("Touch LED Blinking time")
+               self.setCurrentValue()
 
        def getModel(self):
                if fileExists("/proc/stb/info/vumodel"):
@@ -97,13 +112,12 @@ class LEDBrightnessSetup(Screen,ConfigListScreen):
        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.brightness = getConfigListEntry(_("Normal state"), config.plugins.brightnesssetup.brightness)
+               self.brightness_standby = getConfigListEntry(_("Standby"), config.plugins.brightnesssetup.brightnessstandby)
+               self.brightness_deepstandby = getConfigListEntry(_("Deep Standby"), config.plugins.brightnesssetup.brightnessdeepstandby)
+               self.blinkingtime = getConfigListEntry(_("Blinking time"), config.plugins.brightnesssetup.blinkingtime)
                self.list.append( self.brightness )
                self.list.append( self.brightness_standby )
                self.list.append( self.brightness_deepstandby )
@@ -111,24 +125,50 @@ class LEDBrightnessSetup(Screen,ConfigListScreen):
                self["config"].list = self.list
                self["config"].l.setList(self.list)
 
+       def setCurrentValue(self):
+               if self["config"].getCurrent() == self.blinkingtime:
+                       eDBoxLCD.getInstance().setLED(1 ,LEDOption.BRIGHTNESS)
+                       eDBoxLCD.getInstance().setLED(self["config"].getCurrent()[1].value ,LEDOption.BLINKINGTIME)
+               else:
+                       eDBoxLCD.getInstance().setLED(self["config"].getCurrent()[1].value ,LEDOption.BRIGHTNESS)
+
+       def keyLeft(self):
+               ConfigListScreen.keyLeft(self)
+               self.setCurrentValue()
+
+       def keyRight(self):
+               ConfigListScreen.keyRight(self)
+               self.setCurrentValue()
+
        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;
+               brightness = config.plugins.brightnesssetup.brightness.value
+               brightnessstandby = config.plugins.brightnesssetup.brightnessdeepstandby.value
+               blinkingtime = config.plugins.brightnesssetup.blinkingtime.value
+               eDBoxLCD.getInstance().setLED(brightness ,LEDOption.BRIGHTNESS)
+               eDBoxLCD.getInstance().setLED(brightnessstandby ,LEDOption.DEEPSTANDBY)
+               eDBoxLCD.getInstance().setLED(blinkingtime ,LEDOption.BLINKINGTIME)
 
        def keySave(self):
-               self.saveLEDSetup()
+               if self["config"].isChanged():
+                       self.saveLEDSetup()
                ConfigListScreen.keySave(self)
 
+       def keyDefault(self):
+               config.plugins.brightnesssetup.brightness.setValue(1)
+               config.plugins.brightnesssetup.brightnessstandby.setValue(1)
+               config.plugins.brightnesssetup.brightnessdeepstandby.setValue(5)
+               config.plugins.brightnesssetup.blinkingtime.setValue(5)
+               for entry in self["config"].getList():
+                       self["config"].l.invalidateEntry(self["config"].getList().index(entry))
+
+       def cancelConfirm(self, result):
+               if not result:
+                       return
+               for x in self["config"].list:
+                       x[1].cancel()
+               self.saveLEDSetup()
+               self.close()
+
 def main(session, **kwargs):
        session.open(LEDBrightnessSetup)