add OSDPositionSetup plugin, to compensate for TV overscan
authorpieterg <pieterg@users.sourceforge.net>
Sat, 25 Dec 2010 12:38:18 +0000 (13:38 +0100)
committerpieterg <pieterg@users.sourceforge.net>
Sat, 25 Dec 2010 12:38:18 +0000 (13:38 +0100)
configure.ac
lib/python/Plugins/SystemPlugins/Makefile.am
lib/python/Plugins/SystemPlugins/OSDPositionSetup/Makefile.am [new file with mode: 0644]
lib/python/Plugins/SystemPlugins/OSDPositionSetup/__init__.py [new file with mode: 0644]
lib/python/Plugins/SystemPlugins/OSDPositionSetup/plugin.py [new file with mode: 0644]

index b175122..cd567b2 100755 (executable)
@@ -176,6 +176,7 @@ lib/python/Plugins/SystemPlugins/SoftwareUpdate/Makefile
 lib/python/Plugins/SystemPlugins/ConfigurationBackup/Makefile
 lib/python/Plugins/SystemPlugins/CableScan/Makefile
 lib/python/Plugins/SystemPlugins/FastScan/Makefile
+lib/python/Plugins/SystemPlugins/OSDPositionSetup/Makefile
 lib/python/Plugins/DemoPlugins/Makefile
 lib/python/Plugins/DemoPlugins/TPMDemo/Makefile
 lib/python/Plugins/DemoPlugins/TestPlugin/Makefile
index 2961bb6..b1372e3 100755 (executable)
@@ -3,7 +3,7 @@ installdir = $(pkglibdir)/python/Plugins/SystemPlugins
 SUBDIRS = SoftwareManager FrontprocessorUpgrade PositionerSetup Satfinder \
        SkinSelector SatelliteEquipmentControl Videomode VideoTune Hotplug \
        DefaultServicesScanner NFIFlash DiseqcTester CommonInterfaceAssignment \
-       SoftwareUpdate ConfigurationBackup CableScan FastScan \
+       SoftwareUpdate ConfigurationBackup CableScan FastScan OSDPositionSetup \
        CrashlogAutoSubmit CleanupWizard VideoEnhancement WirelessLan NetworkWizard \
        TempFanControl
 
diff --git a/lib/python/Plugins/SystemPlugins/OSDPositionSetup/Makefile.am b/lib/python/Plugins/SystemPlugins/OSDPositionSetup/Makefile.am
new file mode 100644 (file)
index 0000000..2b505b2
--- /dev/null
@@ -0,0 +1,5 @@
+installdir = $(pkglibdir)/python/Plugins/SystemPlugins/OSDPositionSetup
+
+install_PYTHON = \
+       __init__.py \
+       plugin.py
diff --git a/lib/python/Plugins/SystemPlugins/OSDPositionSetup/__init__.py b/lib/python/Plugins/SystemPlugins/OSDPositionSetup/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/lib/python/Plugins/SystemPlugins/OSDPositionSetup/plugin.py b/lib/python/Plugins/SystemPlugins/OSDPositionSetup/plugin.py
new file mode 100644 (file)
index 0000000..b0f38a1
--- /dev/null
@@ -0,0 +1,138 @@
+from Screens.Screen import Screen
+from Components.ConfigList import ConfigListScreen
+from Components.config import config, ConfigSubsection, ConfigInteger, ConfigSlider, getConfigListEntry
+
+config.plugins.OSDPositionSetup = ConfigSubsection()
+config.plugins.OSDPositionSetup.dst_left = ConfigInteger(default = 0)
+config.plugins.OSDPositionSetup.dst_width = ConfigInteger(default = 720)
+config.plugins.OSDPositionSetup.dst_top = ConfigInteger(default = 0)
+config.plugins.OSDPositionSetup.dst_height = ConfigInteger(default = 576)
+
+class ScreenPosition(Screen, ConfigListScreen):
+       skin = """
+       <screen position="0,0" size="e,e" title="OSD position setup" backgroundColor="blue">
+               <widget name="config" position="c-175,c-75" size="350,150" foregroundColor="black" backgroundColor="blue" />
+               <ePixmap pixmap="skin_default/buttons/green.png" position="c-145,e-100" zPosition="0" size="140,40" alphatest="on" />
+               <ePixmap pixmap="skin_default/buttons/red.png" position="c+5,e-100" zPosition="0" size="140,40" alphatest="on" />
+               <widget name="ok" position="c-145,e-100" size="140,40" valign="center" halign="center" zPosition="1" font="Regular;20" transparent="1" backgroundColor="green" />
+               <widget name="cancel" position="c+5,e-100" size="140,40" valign="center" halign="center" zPosition="1" font="Regular;20" transparent="1" backgroundColor="red" />
+       </screen>"""
+
+       def __init__(self, session):
+               self.skin = ScreenPosition.skin
+               Screen.__init__(self, session)
+
+               from Components.ActionMap import ActionMap
+               from Components.Button import Button
+
+               self["ok"] = Button(_("OK"))
+               self["cancel"] = Button(_("Cancel"))
+
+               self["actions"] = ActionMap(["SetupActions", "ColorActions"],
+               {
+                       "ok": self.keyGo,
+                       "save": self.keyGo,
+                       "cancel": self.keyCancel,
+                       "green": self.keyGo,
+                       "red": self.keyCancel,
+               }, -2)
+
+               self.list = []
+               ConfigListScreen.__init__(self, self.list, session = self.session)
+
+               left = 0
+               width = 720
+               top = 0
+               height = 576
+
+               try:
+                       file = open("/proc/stb/fb/dst_left", "r")
+                       line = file.readline()
+                       file.close()
+                       left = int(line, 16)
+                       file = open("/proc/stb/fb/dst_width", "r")
+                       line = file.readline()
+                       file.close()
+                       width = int(line, 16)
+                       file = open("/proc/stb/fb/dst_top", "r")
+                       line = file.readline()
+                       file.close()
+                       top = int(line, 16)
+                       file = open("/proc/stb/fb/dst_height", "r")
+                       line = file.readline()
+                       file.close()
+                       height = int(line, 16)
+               except:
+                       pass
+
+               self.dst_left = ConfigSlider(default = left, increment = 1, limits = (0, 720))
+               self.dst_width = ConfigSlider(default = width, increment = 1, limits = (0, 720))
+               self.dst_top = ConfigSlider(default = top, increment = 1, limits = (0, 576))
+               self.dst_height = ConfigSlider(default = height, increment = 1, limits = (0, 576))
+               self.list.append(getConfigListEntry(_("left"), self.dst_left))
+               self.list.append(getConfigListEntry(_("width"), self.dst_width))
+               self.list.append(getConfigListEntry(_("top"), self.dst_top))
+               self.list.append(getConfigListEntry(_("height"), self.dst_height))
+               self["config"].list = self.list
+               self["config"].l.setList(self.list)
+
+       def keyLeft(self):
+               ConfigListScreen.keyLeft(self)
+               self.setPreviewPosition()
+
+       def keyRight(self):
+               ConfigListScreen.keyRight(self)
+               self.setPreviewPosition()
+
+       def setPreviewPosition(self):
+               setPosition(int(self.dst_left.value), int(self.dst_width.value), int(self.dst_top.value), int(self.dst_height.value))
+
+       def keyGo(self):
+               config.plugins.OSDPositionSetup.dst_left.value = self.dst_left.value
+               config.plugins.OSDPositionSetup.dst_width.value = self.dst_width.value
+               config.plugins.OSDPositionSetup.dst_top.value = self.dst_top.value
+               config.plugins.OSDPositionSetup.dst_height.value = self.dst_height.value
+               config.plugins.OSDPositionSetup.save()
+               self.close()
+
+       def keyCancel(self):
+               setConfiguredPosition()
+               self.close()
+
+def setPosition(dst_left, dst_width, dst_top, dst_height):
+       if dst_left + dst_width > 720:
+               dst_width = 720 - dst_left
+       if dst_top + dst_height > 576:
+               dst_height = 576 - dst_top
+       try:
+               file = open("/proc/stb/fb/dst_left", "w")
+               file.write('%X' % dst_left)
+               file.close()
+               file = open("/proc/stb/fb/dst_width", "w")
+               file.write('%X' % dst_width)
+               file.close()
+               file = open("/proc/stb/fb/dst_top", "w")
+               file.write('%X' % dst_top)
+               file.close()
+               file = open("/proc/stb/fb/dst_height", "w")
+               file.write('%X' % dst_height)
+               file.close()
+       except:
+               return
+
+def setConfiguredPosition():
+       setPosition(int(config.plugins.OSDPositionSetup.dst_left.value), int(config.plugins.OSDPositionSetup.dst_width.value), int(config.plugins.OSDPositionSetup.dst_top.value), int(config.plugins.OSDPositionSetup.dst_height.value))
+
+def main(session, **kwargs):
+       session.open(ScreenPosition)
+
+def startup(reason, **kwargs):
+       setConfiguredPosition()
+
+def Plugins(**kwargs):
+       from os import path
+       if path.exists("/proc/stb/fb/dst_left"):
+               from Plugins.Plugin import PluginDescriptor
+               return [PluginDescriptor(name = "OSD position setup", description = "Compensate for overscan", where = PluginDescriptor.WHERE_PLUGINMENU, fnc = main),
+                                       PluginDescriptor(name = "OSD position setup", description = "", where = PluginDescriptor.WHERE_SESSIONSTART, fnc = startup)]
+       return []