The branch, frodo has been updated
via b153021322602b8c7f8a04df801afe318744a82f (commit)
from ffb39305ef3cadfb311dcbaf04406a9f85bcfba7 (commit)
- Log -----------------------------------------------------------------
http://xbmc.git.sourceforge.net/git/gitweb.cgi?p=xbmc/scripts;a=commit;h=b153021322602b8c7f8a04df801afe318744a82f
commit b153021322602b8c7f8a04df801afe318744a82f
Author: Martijn Kaijser <[email protected]>
Date: Wed Nov 14 19:57:32 2012 +0100
[script.xbmc.boblight] -v2.0.1
diff --git a/script.xbmc.boblight/addon.xml b/script.xbmc.boblight/addon.xml
index 0006efd..f27665c 100644
--- a/script.xbmc.boblight/addon.xml
+++ b/script.xbmc.boblight/addon.xml
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<addon id="script.xbmc.boblight" name="XBMC Boblight" version="1.0.3"
provider-name="bobo1on1, Memphiz">
+<addon id="script.xbmc.boblight" name="XBMC Boblight" version="2.0.1"
provider-name="bobo1on1, Memphiz">
<requires>
- <import addon="xbmc.python" version="2.0"/>
+ <import addon="xbmc.python" version="2.1"/>
</requires>
<extension point="xbmc.service" library="default.py"
start="login"></extension>
<extension point="xbmc.addon.metadata">
diff --git a/script.xbmc.boblight/changelog.txt
b/script.xbmc.boblight/changelog.txt
index 0f3937c..84e7792 100644
--- a/script.xbmc.boblight/changelog.txt
+++ b/script.xbmc.boblight/changelog.txt
@@ -1,3 +1,10 @@
+2.0.1
+- [fix] close download dialog once we finished/failed
+- [fix] - catch exceptions during libboblight download and add a toast for
suggesting a check of the fs permissions
+
+2.0.0
+- compleate rewrite of the addon, it uses xbmc.Monitor class to monitor for
changes in addon settings, player start/stop and others
+
1.0.3
- fixed the lib downloading code on win32
diff --git a/script.xbmc.boblight/default.py b/script.xbmc.boblight/default.py
index 122992b..138a46a 100644
--- a/script.xbmc.boblight/default.py
+++ b/script.xbmc.boblight/default.py
@@ -1,6 +1,7 @@
+# -*- coding: utf-8 -*-
'''
Boblight for XBMC
- Copyright (C) 2011 Team XBMC
+ Copyright (C) 2012 Team XBMC
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -18,176 +19,196 @@
import xbmc
import xbmcaddon
import xbmcgui
-import time
import os
-__settings__ = xbmcaddon.Addon(id='script.xbmc.boblight')
-__cwd__ = __settings__.getAddonInfo('path')
-__icon__ = os.path.join(__cwd__,"icon.png")
-__scriptname__ = "XBMC Boblight"
+__addon__ = xbmcaddon.Addon()
+__cwd__ = __addon__.getAddonInfo('path')
+__scriptname__ = __addon__.getAddonInfo('name')
+__version__ = __addon__.getAddonInfo('version')
+__icon__ = __addon__.getAddonInfo('icon')
+__ID__ = __addon__.getAddonInfo('id')
+__language__ = __addon__.getLocalizedString
-__libbaseurl__ =
"http://mirrors.xbmc.org/build-deps/addon-deps/binaries/libboblight"
-__libnameosx__ = "libboblight-osx.0.dylib"
-__libnameios__ = "libboblight-ios.0.dylib"
-__libnamewin__ = "libboblight-win32.0.dll"
+__profile__ = xbmc.translatePath( __addon__.getAddonInfo('profile') )
+__resource__ = xbmc.translatePath( os.path.join( __cwd__, 'resources', 'lib'
) )
-BASE_RESOURCE_PATH = xbmc.translatePath( os.path.join( __cwd__, 'resources',
'lib' ) )
-sys.path.append (BASE_RESOURCE_PATH)
+sys.path.append (__resource__)
-from boblight import *
from settings import *
from tools import *
-#if __settings__.getSetting('enabled') != 'true':
-# exit(0)
+log( "[%s] - Version: %s Started" % (__scriptname__,__version__))
-global g_failedConnectionNotified
-
-capture_width = 32
+capture_width = 32
capture_height = 32
-
-def process_boblight():
- capture = xbmc.RenderCapture()
- capture.capture(capture_width, capture_height, xbmc.CAPTURE_FLAG_CONTINUOUS)
- while not xbmc.abortRequested:
- if settings_checkForNewSettings() or not bob_ping():
- reconnectBoblight()
- settings_setup() #after reconnect reload
settings
- if settings_getBobDisable():
- bob_set_priority(255)
- time.sleep(1)
- continue
+settings = settings()
+
+class MyPlayer( xbmc.Player ):
+ def __init__( self, *args, **kwargs ):
+ xbmc.Player.__init__( self )
+ log('MyPlayer - init')
+
+ def onPlayBackStopped( self ):
+ myPlayerChanged( 'stop' )
+
+ def onPlayBackEnded( self ):
+ myPlayerChanged( 'stop' )
+
+ def onPlayBackStarted( self ):
+ myPlayerChanged( 'start' )
+
+class MyMonitor( xbmc.Monitor ):
+ def __init__( self, *args, **kwargs ):
+ xbmc.Monitor.__init__( self )
+ log('MyMonitor - init')
+
+ def onSettingsChanged( self ):
+ settings.start()
+ if not settings.reconnect:
+ check_state()
+
+ def onScreensaverDeactivated( self ):
+ settings.screensaver = False
+ settings.handleStaticBgSettings()
- capture.waitForCaptureStateChangeEvent(1000)
- if capture.getCaptureState() == xbmc.CAPTURE_STATE_DONE:
- if not bob_set_priority(128):
- return
-
- width = capture.getWidth();
- height = capture.getHeight();
- pixels = capture.getImage();
- bob_setscanrange(width, height)
- rgb = (c_int * 3)()
- for y in range(height):
- row = width * y * 4
- for x in range(width):
- rgb[0] = pixels[row + x * 4 + 2]
- rgb[1] = pixels[row + x * 4 + 1]
- rgb[2] = pixels[row + x * 4]
- bob_addpixelxy(x, y, byref(rgb))
-
- if not bob_sendrgb():
- print "boblight: error sending values: " + bob_geterror()
- return
+ def onScreensaverActivated( self ):
+ settings.screensaver = True
+ settings.handleStaticBgSettings()
+
+class Main():
+ def __init__( self, *args, **kwargs ):
+ self.warning = 0
+
+ def connectBoblight(self, force_warning):
+ if force_warning:
+ self.warning = 0
+
+ bob.bob_set_priority(255)
+
+ if settings.hostip == None:
+ log("connecting to local boblightd")
else:
- if not settings_isStaticBobActive(): #don't kill the lights in accident
here
- if not bob_set_priority(255):
- return
-
-def initGlobals():
- global g_failedConnectionNotified
-
- g_failedConnectionNotified = False
- settings_initGlobals()
-
-def printLights():
- nrLights = bob_getnrlights()
- print "boblight: Found " + str(nrLights) + " lights:"
-
- for i in range(0, nrLights):
- lightname = bob_getlightname(i)
- print "boblight: " + lightname
-
-#do a initial bling bling with the lights
-def showRgbBobInit():
- settings_confForBobInit()
- bob_set_priority(128) #allow lights to be turned on
- rgb = (c_int * 3)(255,0,0)
- bob_set_static_color(byref(rgb))
- time.sleep(0.3)
- rgb = (c_int * 3)(0,255,0)
- bob_set_static_color(byref(rgb))
- time.sleep(0.3)
- rgb = (c_int * 3)(0,0,255)
- bob_set_static_color(byref(rgb))
- time.sleep(0.3)
- rgb = (c_int * 3)(0,0,0)
- bob_set_static_color(byref(rgb))
- time.sleep(3)
- bob_set_priority(255) #turn the lights off
-
-def reconnectBoblight():
- global g_failedConnectionNotified
+ log("connecting to boblightd %s:%s" % (settings.hostip,
str(settings.hostport)))
- hostip = settings_getHostIp()
- hostport = settings_getHostPort()
+ ret = bob.bob_connect(settings.hostip, settings.hostport)
- if hostip == None:
- print "boblight: connecting to local boblightd"
- else:
- print "boblight: connecting to boblightd " + hostip + ":" + str(hostport)
-
- while not xbmc.abortRequested:
- #check for new settingsk
- if settings_checkForNewSettings(): #networksettings changed?
- g_failedConnectionNotified = False #reset notification flag
- hostip = settings_getHostIp()
- hostport = settings_getHostPort()
- ret = bob_connect(hostip, hostport)
-
if not ret:
- print "boblight: connection to boblightd failed: " + bob_geterror()
- count = 10
- while (not xbmc.abortRequested) and (count > 0):
- time.sleep(1)
- count -= 1
- if not g_failedConnectionNotified:
- g_failedConnectionNotified = True
- text = __settings__.getLocalizedString(500)
- xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" %
(__scriptname__,text,10,__icon__))
+ log("connection to boblightd failed: %s" % bob.bob_geterror())
+ text = __language__(500)
+ if self.warning < 3:
+ xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" %
(__scriptname__,text,750,__icon__))
+ self.warning += 1
+ return False
else:
- text = __settings__.getLocalizedString(501)
- xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" %
(__scriptname__,text,10,__icon__))
- print "boblight: connected to boblightd"
- settings_initGlobals() #invalidate settings after reconnect
- break
- return True
-
-#MAIN - entry point
-initGlobals()
-loaded = bob_loadLibBoblight()
-
-if loaded == 1: #libboblight not found
-#ask user if we should fetch the lib for osx and windows
- if xbmc.getCondVisibility('system.platform.osx') or
xbmc.getCondVisibility('system.platform.windows'):
- t1 = __settings__.getLocalizedString(504)
- t2 = __settings__.getLocalizedString(509)
- if xbmcgui.Dialog().yesno(__scriptname__,t1,t2):
- tools_downloadLibBoblight()
- loaded = bob_loadLibBoblight()
+ self.warning = 0
+ text = __language__(501)
+ xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" %
(__scriptname__,text,750,__icon__))
+ log("connected to boblightd")
+ bob.bob_set_priority(128)
+ return True
- if xbmc.getCondVisibility('system.platform.linux'):
- t1 = __settings__.getLocalizedString(504)
- t2 = __settings__.getLocalizedString(505)
- t3 = __settings__.getLocalizedString(506)
- xbmcgui.Dialog().ok(__scriptname__,t1,t2,t3)
-elif loaded == 2: #no ctypes available
- t1 = __settings__.getLocalizedString(507)
- t2 = __settings__.getLocalizedString(508)
- xbmcgui.Dialog().ok(__scriptname__,t1,t2)
-
-if loaded == 0:
- #main loop
- while not xbmc.abortRequested:
-
- if reconnectBoblight():
- printLights() #print found lights to debuglog
- print "boblight: setting up with user settings"
- showRgbBobInit() #init light bling bling
- settings_setup()
- process_boblight() #boblight loop
-
- time.sleep(1)
-
-#cleanup
-bob_destroy()
+ def startup(self):
+ platform = get_platform()
+ libpath = get_libpath(platform)
+ loaded = bob.bob_loadLibBoblight(libpath,platform)
+
+ if loaded == 1: #libboblight not found
+ if platform == 'linux':
+ t1 = __language__(504)
+ t2 = __language__(505)
+ t3 = __language__(506)
+ xbmcgui.Dialog().ok(__scriptname__,t1,t2,t3)
+
+ else: # ask user if we should
fetch the
+ t1 = __language__(504) # lib for osx, ios and
windows
+ t2 = __language__(509)
+ if xbmcgui.Dialog().yesno(__scriptname__,t1,t2):
+ tools_downloadLibBoblight(platform)
+ loaded = bob.bob_loadLibBoblight(libpath,platform)
+
+
+ elif loaded == 2: #no ctypes available
+ t1 = __language__(507)
+ t2 = __language__(508)
+ xbmcgui.Dialog().ok(__scriptname__,t1,t2)
+
+ return loaded
+
+def check_state():
+ if xbmc.Player().isPlaying():
+ state = 'start'
+ else:
+ state = 'stop'
+ myPlayerChanged( state )
+
+def myPlayerChanged(state):
+ log('PlayerChanged(%s)' % state)
+ xbmc.sleep(100)
+ if state == 'stop':
+ ret = "static"
+ else:
+ if xbmc.getCondVisibility("VideoPlayer.Content(musicvideos)"):
+ ret = "musicvideo"
+ else:
+ ret = "movie"
+
+ if settings.overwrite_cat: # fix his out when other isn't
+ if settings.overwrite_cat_val == 0: # the static light anymore
+ ret = "movie"
+ else:
+ ret = "musicvideo"
+ settings.handleCategory(ret)
+
+
+def run_boblight():
+ main = Main()
+ xbmc_monitor = MyMonitor()
+ player_monitor = MyPlayer()
+ if main.startup() == 0:
+ capture = xbmc.RenderCapture()
+ capture.capture(capture_width, capture_height,
xbmc.CAPTURE_FLAG_CONTINUOUS)
+ while not xbmc.abortRequested:
+ xbmc.sleep(100)
+ if not settings.bobdisable:
+ if not bob.bob_ping() or settings.reconnect:
+ if main.connectBoblight(settings.reconnect):
+ if settings.bob_init():
+ check_state()
+ settings.reconnect = False
+
+ if not settings.staticBobActive:
+ capture.waitForCaptureStateChangeEvent(1000)
+ if capture.getCaptureState() == xbmc.CAPTURE_STATE_DONE:
+ bob.bob_set_priority(128)
+ width = capture.getWidth();
+ height = capture.getHeight();
+ pixels = capture.getImage();
+ bob.bob_setscanrange(width, height)
+ rgb = (c_int * 3)()
+ for y in range(height):
+ row = width * y * 4
+ for x in range(width):
+ rgb[0] = pixels[row + x * 4 + 2]
+ rgb[1] = pixels[row + x * 4 + 1]
+ rgb[2] = pixels[row + x * 4]
+ bob.bob_addpixelxy(x, y, byref(rgb))
+
+ if not bob.bob_sendrgb():
+ log("error sending values: %s" % bob.bob_geterror())
+ return
+
+ else:
+ log('boblight disabled in Addon Settings')
+ bob.bob_set_priority(255)
+ continue
+
+ del main #cleanup
+ del player_monitor
+ del xbmc_monitor
+
+if ( __name__ == "__main__" ):
+ run_boblight()
+ bob.bob_set_priority(255) # we are shutting down, kill the LEDs
+ bob.bob_destroy()
+
+
diff --git a/script.xbmc.boblight/resources/language/English/strings.xml
b/script.xbmc.boblight/resources/language/English/strings.xml
index 2e78830..3665402 100644
--- a/script.xbmc.boblight/resources/language/English/strings.xml
+++ b/script.xbmc.boblight/resources/language/English/strings.xml
@@ -40,6 +40,7 @@
<string id="402">Red</string>
<string id="403">Green</string>
<string id="404">Blue</string>
+ <string id="405">Disable when Screen Saver is on</string>
<!--Notifications-->
<string id="500">Failed to connect to boblightd!</string>
@@ -52,6 +53,7 @@
<string id="507">This addon can't be run on that</string>
<string id="508">operating system! (missing ctypes module)</string>
<string id="509">Should the addon try to download it for you?</string>
+ <string id="510">Error downloading. Check filesystem permissions.</string>
</strings>
diff --git a/script.xbmc.boblight/resources/language/German/strings.xml
b/script.xbmc.boblight/resources/language/German/strings.xml
index 0dafb6e..8edfbb1 100644
--- a/script.xbmc.boblight/resources/language/German/strings.xml
+++ b/script.xbmc.boblight/resources/language/German/strings.xml
@@ -39,7 +39,8 @@
<string id="401">Festes Hintergrundlicht</string>
<string id="402">Rot</string>
<string id="403">Gruen</string>
- <string id="404">Blau</string>
+ <string id="404">Blau</string>
+ <string id="405">Waehrend Bildschirmschoner Licht ausschalten</string>
<!--Notifications-->
<string id="500">Fehler beim Verbinden zu boblightd!</string>
@@ -52,4 +53,5 @@
<string id="507">Dieses Addon kann auf Ihrem Betriebssystem nicht</string>
<string id="508">ausgefuehrt werden! (Das ctypes Modul fehlt)</string>
<string id="509">Soll versucht werden diese automatisch
herunterzuladen?</string>
+ <string id="510">Fehler beim Herunterladen. Dateisystemberechtigungen
pruefen.</string>
</strings>
diff --git a/script.xbmc.boblight/resources/lib/boblight.py
b/script.xbmc.boblight/resources/lib/boblight.py
index dda276e..2619465 100644
--- a/script.xbmc.boblight/resources/lib/boblight.py
+++ b/script.xbmc.boblight/resources/lib/boblight.py
@@ -1,6 +1,7 @@
+# -*- coding: utf-8 -*-
'''
Boblight for XBMC
- Copyright (C) 2011 Team XBMC
+ Copyright (C) 2012 Team XBMC
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,188 +21,140 @@
cheat sheet
-c_void_p(g_libboblight.boblight_init())
-g_libboblight.boblight_destroy(boblight)
-c_int(g_libboblight.boblight_connect(boblight, const char* address, int port,
int usectimeout))
-c_int(g_libboblight.boblight_setpriority(boblight, int priority))
-c_char_p(g_libboblight.boblight_geterror(boblight))
-c_int(g_libboblight.boblight_getnrlights(boblight))
-c_char_p(g_libboblight.boblight_getlightname(boblight, int lightnr))
-c_int(g_libboblight.boblight_getnroptions(boblight))
-c_char_p(g_libboblight.boblight_getoptiondescriptboblight, int option))
-c_int(g_libboblight.boblight_setoption(boblight, int lightnr, const char*
option))
-c_int(g_libboblight.boblight_getoption(boblight, int lightnr, const char*
option, const char** output))
-g_libboblight.boblight_setscanrange(boblight, int width, int height)
-c_int(g_libboblight.boblight_addpixel(boblight, int lightnr, int* rgb))
-g_libboblight.boblight_addpixelxy(boblight, int x, int y, int* rgb)
-c_int(g_libboblight.boblight_sendrgb(boblight, int sync, int* outputused))
-c_int(g_libboblight.boblight_ping(boblight, int* outputused))
+c_void_p(self.libboblight.boblight_init())
+self.libboblight.boblight_destroy(boblight)
+c_int(self.libboblight.boblight_connect(boblight, const char* address, int
port, int usectimeout))
+c_int(self.libboblight.boblight_setpriority(boblight, int priority))
+c_char_p(self.libboblight.boblight_geterror(boblight))
+c_int(self.libboblight.boblight_getnrlights(boblight))
+c_char_p(self.libboblight.boblight_getlightname(boblight, int lightnr))
+c_int(self.libboblight.boblight_getnroptions(boblight))
+c_char_p(self.libboblight.boblight_getoptiondescriptboblight, int option))
+c_int(self.libboblight.boblight_setoption(boblight, int lightnr, const char*
option))
+c_int(self.libboblight.boblight_getoption(boblight, int lightnr, const char*
option, const char** output))
+self.libboblight.boblight_setscanrange(boblight, int width, int height)
+c_int(self.libboblight.boblight_addpixel(boblight, int lightnr, int* rgb))
+self.libboblight.boblight_addpixelxy(boblight, int x, int y, int* rgb)
+c_int(self.libboblight.boblight_sendrgb(boblight, int sync, int* outputused))
+c_int(self.libboblight.boblight_ping(boblight, int* outputused))
"""
-import platform
-import xbmc
import sys
import os
-__scriptname__ = sys.modules[ "__main__" ].__scriptname__
-__settings__ = sys.modules[ "__main__" ].__settings__
-__cwd__ = sys.modules[ "__main__" ].__cwd__
-__icon__ = sys.modules[ "__main__" ].__icon__
-
-__libbaseurl__ = sys.modules[ "__main__" ].__libbaseurl__
-__libnameosx__ = sys.modules[ "__main__" ].__libnameosx__
-__libnameios__ = sys.modules[ "__main__" ].__libnameios__
-__libnamewin__ = sys.modules[ "__main__" ].__libnamewin__
-
-global g_boblightLoaded
-global g_bobHandle
-global g_current_priority
-global g_libboblight
-global g_connected
-
try:
from ctypes import *
HAVE_CTYPES = True
except:
HAVE_CTYPES = False
-def bob_loadLibBoblight():
- global g_boblightLoaded
- global g_current_priority
- global g_libboblight
- global g_bobHandle
- global g_connected
-
- g_connected = False
- g_current_priority = -1
- ret = 0
-
- if HAVE_CTYPES:
- libname = "libboblight.so" #default to linux type
- # load g_libboblight.so/dylib
- try:
- if xbmc.getCondVisibility('system.platform.osx'):
- libname = xbmc.translatePath( os.path.join( __cwd__, 'resources',
'lib', __libnameosx__) )
- if not os.path.exists(libname):
- ret = 1
- else:
- cdll.LoadLibrary(libname)
- g_libboblight = CDLL(libname)
- elif xbmc.getCondVisibility('system.platform.ios'):
- libname = xbmc.translatePath( os.path.join( __cwd__, 'resources',
'lib', __libnameios__) )
- if not os.path.exists(libname):
+class Boblight():
+ def __init__( self, *args, **kwargs ):
+ self.current_priority = -1
+ self.libboblight = None
+ self.bobHandle = None
+ self.connected = False
+ self.boblightLoaded = False
+
+ def bob_loadLibBoblight(self,libname,platform):
+ ret = 0
+ if HAVE_CTYPES:
+ try:
+ if not os.path.exists(libname) and platform != "linux":
ret = 1
else:
- cdll.LoadLibrary(libname)
- g_libboblight = CDLL(libname)
- elif xbmc.getCondVisibility('system.platform.windows'):
- libname = xbmc.translatePath( os.path.join( __cwd__, 'resources',
'lib', __libnamewin__) )
- if not os.path.exists(libname):
- ret = 1
- else:
- cdll.LoadLibrary(libname)
- g_libboblight = CDLL(libname)
- else:
- cdll.LoadLibrary("libboblight.so")
- g_libboblight = CDLL("libboblight.so")
- g_libboblight.boblight_init.restype = c_void_p
- g_libboblight.boblight_geterror.restype = c_char_p
- g_libboblight.boblight_getlightname.restype = c_char_p
- g_libboblight.boblight_getoptiondescript.restype = c_char_p
- g_boblightLoaded = True
- g_bobHandle = c_void_p(g_libboblight.boblight_init(None))
- except:
- g_boblightLoaded = False
- print "boblight: Error loading " + libname + " - only demo mode."
- ret = 1
- else:
- print "boblight: No ctypes available - only demo mode."
- ret = 2
- g_boblightLoaded = False
- return ret
-
-def bob_set_priority(priority):
- global g_current_priority
+ self.libboblight = CDLL(libname)
+ self.libboblight.boblight_init.restype = c_void_p
+ self.libboblight.boblight_geterror.restype = c_char_p
+ self.libboblight.boblight_getlightname.restype = c_char_p
+ self.libboblight.boblight_getoptiondescript.restype = c_char_p
+ self.boblightLoaded = True
+ self.bobHandle = c_void_p(self.libboblight.boblight_init(None))
+
+ except:
+ ret = 1
+ else:
+ ret = 2
+ return ret
- ret = True
- if g_boblightLoaded and g_connected:
- if priority != g_current_priority:
- g_current_priority = priority
- if not g_libboblight.boblight_setpriority(g_bobHandle,
g_current_priority):
- print "boblight: error setting priority: " +
c_char_p(g_libboblight.boblight_geterror(g_bobHandle)).value
- ret = False
- return ret
-
-def bob_setscanrange(width, height):
- if g_boblightLoaded and g_connected:
- g_libboblight.boblight_setscanrange(g_bobHandle, width, height)
-
-def bob_addpixelxy(x,y,rgb):
- if g_boblightLoaded and g_connected:
- g_libboblight.boblight_addpixelxy(g_bobHandle, x, y, rgb)
-
-def bob_addpixel(rgb):
- if g_boblightLoaded and g_connected:
- g_libboblight.boblight_addpixel(g_bobHandle, -1, rgb)
-
-def bob_sendrgb():
- ret = False
- if g_boblightLoaded and g_connected:
- ret = c_int(g_libboblight.boblight_sendrgb(g_bobHandle, 1, None)) != 0
- else:
+ def bob_set_priority(self,priority):
ret = True
- return ret
+ if self.boblightLoaded and self.connected:
+ if priority != self.current_priority:
+ self.current_priority = priority
+ if not self.libboblight.boblight_setpriority(self.bobHandle,
self.current_priority):
+ ret = False
+ return ret
+
+ def bob_setscanrange(self,width, height):
+ if self.boblightLoaded and self.connected:
+ self.libboblight.boblight_setscanrange(self.bobHandle, width, height)
+
+ def bob_addpixelxy(self,x,y,rgb):
+ if self.boblightLoaded and self.connected:
+ self.libboblight.boblight_addpixelxy(self.bobHandle, x, y, rgb)
-def bob_setoption(option):
- ret = False
- if g_boblightLoaded and g_connected:
- ret = c_int(g_libboblight.boblight_setoption(g_bobHandle, -1, option)) != 0
- else:
- ret = True
- return ret
+ def bob_addpixel(self,rgb):
+ if self.boblightLoaded and self.connected:
+ self.libboblight.boblight_addpixel(self.bobHandle, -1, rgb)
-def bob_getnrlights():
- if HAVE_CTYPES:
- ret = c_int(0)
- if g_boblightLoaded and g_connected:
- ret = c_int(g_libboblight.boblight_getnrlights(g_bobHandle))
- return ret.value
- else:
- return 0
+ def bob_sendrgb(self):
+ ret = False
+ if self.boblightLoaded and self.connected:
+ ret = c_int(self.libboblight.boblight_sendrgb(self.bobHandle, 1, None))
!= 0
+ return ret
+
+ def bob_setoption(self,option):
+ ret = False
+ if self.boblightLoaded and self.connected:
+ ret = c_int(self.libboblight.boblight_setoption(self.bobHandle, -1,
option)) != 0
+ else:
+ ret = True
+ return ret
+
+ def bob_getnrlights(self):
+ if HAVE_CTYPES:
+ ret = c_int(0)
+ if self.boblightLoaded and self.connected:
+ ret = c_int(self.libboblight.boblight_getnrlights(self.bobHandle))
+ return ret.value
+ else:
+ return 0
+
+ def bob_getlightname(self,nr):
+ ret = ""
+ if self.boblightLoaded and self.connected:
+ ret = self.libboblight.boblight_getlightname(self.bobHandle,nr)
+ return ret
-def bob_getlightname(nr):
- ret = ""
- if g_boblightLoaded and g_connected:
- ret = g_libboblight.boblight_getlightname(g_bobHandle,nr)
- return ret
-
-def bob_connect(hostip, hostport):
- global g_connected
+ def bob_connect(self,hostip, hostport):
+ if self.boblightLoaded:
+ ret = c_int(self.libboblight.boblight_connect(self.bobHandle, hostip,
hostport, 1000000))
+ self.connected = ret.value != 0
+ else:
+ self.connected = False
+ return self.connected
+
+ def bob_set_static_color(self,rgb):
+ res = False
+ if self.boblightLoaded and self.connected:
+ self.bob_addpixel(rgb)
+ res = self.bob_sendrgb()
+ return res
- if g_boblightLoaded:
- ret = c_int(g_libboblight.boblight_connect(g_bobHandle, hostip, hostport,
1000000))
- g_connected = ret.value != 0
- else:
- g_connected = False
- return g_connected
+ def bob_destroy(self):
+ if self.boblightLoaded:
+ self.libboblight.boblight_destroy(self.bobHandle)
+ self.boblightLoaded = False
-def bob_set_static_color(rgb):
- if g_boblightLoaded and g_connected:
- bob_addpixel(rgb)
- bob_sendrgb()
-
-def bob_destroy():
- if g_boblightLoaded:
- g_libboblight.boblight_destroy(g_bobHandle)
-
-def bob_geterror():
- ret = ""
- if g_boblightLoaded:
- ret = c_char_p(g_libboblight.boblight_geterror(g_bobHandle)).value
- return ret
-
-def bob_ping():
- ret = False
- if g_boblightLoaded and g_connected:
- ret = c_int(g_libboblight.boblight_ping(g_bobHandle, None)).value == 1
- return ret
+ def bob_geterror(self):
+ ret = ""
+ if self.boblightLoaded:
+ ret = c_char_p(self.libboblight.boblight_geterror(self.bobHandle)).value
+ return ret
+
+ def bob_ping(self):
+ ret = False
+ if self.boblightLoaded and self.connected:
+ ret = c_int(self.libboblight.boblight_ping(self.bobHandle, None)).value
== 1
+ return ret
diff --git a/script.xbmc.boblight/resources/lib/settings.py
b/script.xbmc.boblight/resources/lib/settings.py
index 28a1a80..7ce4f37 100644
--- a/script.xbmc.boblight/resources/lib/settings.py
+++ b/script.xbmc.boblight/resources/lib/settings.py
@@ -1,6 +1,7 @@
+# -*- coding: utf-8 -*-
'''
Boblight for XBMC
- Copyright (C) 2011 Team XBMC
+ Copyright (C) 2012 Team XBMC
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -17,382 +18,231 @@
'''
import sys
-import time
-import xbmc
+import xbmc, xbmcgui
+
__scriptname__ = sys.modules[ "__main__" ].__scriptname__
-__settings__ = sys.modules[ "__main__" ].__settings__
+__addon__ = sys.modules[ "__main__" ].__addon__
__cwd__ = sys.modules[ "__main__" ].__cwd__
__icon__ = sys.modules[ "__main__" ].__icon__
-sys.path.append (__cwd__)
+__language__ = sys.modules[ "__main__" ].__language__
+__ID__ = sys.modules[ "__main__" ].__ID__
from boblight import *
-
-#general
-global g_networkaccess
-global g_hostip
-global g_hostport
-#movie/musicvideo/other
-global g_saturation
-global g_value
-global g_speed
-global g_autospeed
-global g_interpolation
-global g_threshold
-global g_timer
-global g_category
-global g_bobdisable
-global g_staticBobActive
-global g_overwrite_cat
-global g_overwrite_cat_val
-
-#init globals with defaults
-def settings_initGlobals():
- global g_networkaccess
- global g_hostip
- global g_hostport
- global g_saturation
- global g_value
- global g_speed
- global g_autospeed
- global g_interpolation
- global g_threshold
- global g_networkaccess
- global g_hostip
- global g_hostport
- global g_timer
- global g_category
- global g_bobdisable
- global g_staticBobActive
- global g_overwrite_cat
- global g_overwrite_cat_val
-
- g_networkaccess = False
- g_hostip = "127.0.0.1"
- g_hostport = None
- g_saturation = -1.0
- g_value = -1.0
- g_speed = -1.0
- g_autospeed = -1.0
- g_interpolation = -1
- g_threshold = -1.0
- g_networkaccess = __settings__.getSetting("networkaccess") == "true"
- g_hostip = __settings__.getSetting("hostip")
- g_hostport = int(__settings__.getSetting("hostport"))
- g_timer = time.time()
- g_category = "movie"
- g_bobdisable = -1
- g_staticBobActive = False
- g_overwrite_cat = False
- g_overwrite_cat_val = 0
-
- if not g_networkaccess:
- g_hostip = None
- g_hostport = -1
-
-def settings_getHostIp():
- global g_hostip
- return g_hostip
-
-def settings_getHostPort():
- global g_hostport
- return g_hostport
-
-def settings_getBobDisable():
- global g_bobdisable
- return g_bobdisable
-
-def settings_isStaticBobActive():
- global g_staticBobActive
- return g_staticBobActive
-
-#configures boblight for the initial bling bling
-def settings_confForBobInit():
- saturation,value,speed,autospeed,interpolation,threshold =
settings_setupForStatic()
- bob_setoption("saturation " + str(saturation))
- bob_setoption("value " + str(value))
- bob_setoption("speed " + str(speed))
- bob_setoption("autospeed " + str(autospeed))
- bob_setoption("interpolation " + str(interpolation))
- bob_setoption("threshold " + str(threshold))
-
-#returns the settings category based on the currently played media
-#returns "movie" if a movies is played, "musicvideo" if a musicvideo is
played", "other" else
-def settings_getSettingCategory():
- ret = "other"
-
- playing = xbmc.getCondVisibility("Player.HasVideo")
-
- if playing: #we play something
- ret = "movie"
- musicvideo = xbmc.getCondVisibility("VideoPlayer.Content(musicvideos)")
- if musicvideo:
- ret = "musicvideo"
-
- if g_overwrite_cat and ret != "other": #fix
his out when other isn't the static light anymore
- if g_overwrite_cat_val == 0:
- ret = "movie"
+from tools import log
+
+bob = Boblight()
+
+BLING = [[255,0,0],[0,255,0],[0,0,255],[0,0,0]]
+OPTS = ['saturation','value','speed','autospeed','interpolation','threshold']
+
+class settings():
+ def __init__( self, *args, **kwargs ):
+ log('settings() - __init__')
+ self.staticBobActive = False
+ self.run_init = True
+ self.category = "static"
+ self.networkaccess = __addon__.getSetting("networkaccess") ==
"true"
+ if not self.networkaccess:
+ self.hostip = None
+ self.hostport = -1
else:
- ret = "musicvideo"
-
- return ret
-
-#check for new settings and handle them if anything changed
-#only checks if the last check is 5 secs old
-#returns if a reconnect is needed due to settings change
-def settings_checkForNewSettings():
-#todo for now impl. stat on addon.getAddonInfo('profile')/settings.xml and
use mtime
-#check for new settings every 5 secs
- global g_timer
- reconnect = False
-
- if time.time() - g_timer > 5:
- reconnect = settings_setup()
- g_timer = time.time()
- return reconnect
-
-#handle boblight configuration from the "Movie" category
-#returns the new settings
-def settings_setupForMovie():
- preset = int(__settings__.getSetting("movie_preset"))
-
- if preset == 1: #preset smooth
- saturation = 3.0
- value = 10.0
- speed = 20.0
- autospeed = 0.0
- interpolation = 0
- threshold = 0.0
- elif preset == 2: #preset action
- saturation = 3.0
- value = 10.0
- speed = 80.0
- autospeed = 0.0
- interpolation = 0
- threshold = 0.0
- elif preset == 0: #custom
- saturation = float(__settings__.getSetting("movie_saturation"))
- value = float(__settings__.getSetting("movie_value"))
- speed = float(__settings__.getSetting("movie_speed"))
- autospeed = float(__settings__.getSetting("movie_autospeed"))
- interpolation = __settings__.getSetting("movie_interpolation") == "true"
- threshold = float(__settings__.getSetting("movie_threshold"))
- return (saturation,value,speed,autospeed,interpolation,threshold)
-
-#handle boblight configuration from the "MusicVideo" category
-#returns the new settings
-def settings_setupForMusicVideo():
- preset = int(__settings__.getSetting("musicvideo_preset"))
-
- if preset == 1: #preset Ballad
- saturation = 3.0
- value = 10.0
- speed = 20.0
- autospeed = 0.0
- interpolation = 1
- threshold = 0.0
- elif preset == 2: #preset Rock
- saturation = 3.0
- value = 10.0
- speed = 80.0
- autospeed = 0.0
- interpolation = 0
- threshold = 0.0
- elif preset == 0: #custom
- saturation = float(__settings__.getSetting("musicvideo_saturation"))
- value = float(__settings__.getSetting("musicvideo_value"))
- speed = float(__settings__.getSetting("musicvideo_speed"))
- autospeed = float(__settings__.getSetting("movie_autospeed"))
- interpolation = __settings__.getSetting("musicvideo_interpolation") ==
"true"
- threshold = float(__settings__.getSetting("musicvideo_threshold"))
- return (saturation,value,speed,autospeed,interpolation,threshold)
-
-#handle boblight configuration from the "other" category
-#returns the new settings
-def settings_setupForOther():
-# FIXME don't use them for now - reactivate when boblight works on non
rendered scenes (e.x. menu)
-# saturation = float(__settings__.getSetting("other_saturation"))
-# value = float(__settings__.getSetting("other_value"))
-# speed = float(__settings__.getSetting("other_speed"))
-# autospeed = float(__settings__.getSetting("other_autospeed"))
-# interpolation = __settings__.getSetting("other_interpolation") == "true"
-# threshold = float(__settings__.getSetting("other_threshold"))
- return settings_setupForStatic()
-
-#handle boblight configuration for static lights
-#returns the new settings
-def settings_setupForStatic():
- saturation = 4.0
- value = 1.0
- speed = 50.0
- autospeed = 0.0
- interpolation = 1
- threshold = 0.0
- return (saturation,value,speed,autospeed,interpolation,threshold)
-
-
-#handle all settings in the general tab according to network access
-#returns true if reconnect is needed due to network changes
-def settings_handleNetworkSettings():
- global g_networkaccess
- global g_hostip
- global g_hostport
- reconnect = False
-
- networkaccess = __settings__.getSetting("networkaccess") == "true"
- hostip = __settings__.getSetting("hostip")
- hostport = int(__settings__.getSetting("hostport"))
-
- #server settings
- #we need to reconnect if networkaccess bool changes
- #or if network access is enabled and ip or port have changed
- if g_networkaccess != networkaccess or ((g_hostip != hostip or g_hostport !=
hostport) and g_networkaccess) :
- print "boblight: changed networkaccess to " + str(networkaccess)
- g_networkaccess = networkaccess
-
- if not networkaccess:
- g_hostip = None
- g_hostport = -1
+ self.hostip = __addon__.getSetting("hostip")
+ self.hostport = int(__addon__.getSetting("hostport"))
+ self.start()
+
+ def start(self):
+ log('settings() - start')
+ self.reconnect = False
+ self.force_update = True
+ self.networkaccess = __addon__.getSetting("networkaccess") ==
"true"
+ self.overwrite_cat = __addon__.getSetting("overwrite_cat") ==
"true"
+ self.overwrite_cat_val =
int(__addon__.getSetting("overwrite_cat_val"))
+ self.screensaver =
xbmc.getCondVisibility("System.ScreenSaverActive")
+ self.bobdisable = __addon__.getSetting("bobdisable") ==
"true"
+ self.current_option = ""
+
+ if not self.networkaccess:
+ self.hostip = None
+ self.hostport = -1
+ self.reconnect = True
else:
- if g_hostip != hostip:
- print "boblight: changed hostip to " + str(hostip)
- g_hostip = hostip
+ hostip = __addon__.getSetting("hostip")
+ hostport = int(__addon__.getSetting("hostport"))
+ if ((self.hostip != hostip) or (self.hostport != hostport)):
+ self.hostip = hostip
+ self.hostport = hostport
+ self.reconnect = True
- if g_hostport != hostport:
- print "boblight: changed hostport to " + str(hostport)
- g_hostport = hostport
- reconnect = True
- return reconnect
-
-#handle all settings according to the static bg light
-#this is used until category "other" can do real boblight
-#when no video is rendered
-#category - the category we are in currently
-def settings_handleStaticBgSettings(category):
- global g_staticBobActive
- other_static_bg = __settings__.getSetting("other_static_bg") == "true"
- other_static_red = int(float(__settings__.getSetting("other_static_red")))
- other_static_green =
int(float(__settings__.getSetting("other_static_green")))
- other_static_blue =
int(float(__settings__.getSetting("other_static_blue")))
+ # Other settings
+ self.other_static_bg = __addon__.getSetting("other_static_bg")
== "true"
+ self.other_static_red =
int(float(__addon__.getSetting("other_static_red")))
+ self.other_static_green =
int(float(__addon__.getSetting("other_static_green")))
+ self.other_static_blue =
int(float(__addon__.getSetting("other_static_blue")))
+ self.other_static_onscreensaver =
__addon__.getSetting("other_static_onscreensaver") == "true"
+
+ # Movie settings
+ self.movie_saturation =
float(__addon__.getSetting("movie_saturation"))
+ self.movie_value =
float(__addon__.getSetting("movie_value"))
+ self.movie_speed =
float(__addon__.getSetting("movie_speed"))
+ self.movie_autospeed =
float(__addon__.getSetting("movie_autospeed"))
+ self.movie_interpolation =
int(__addon__.getSetting("movie_interpolation") == "true")
+ self.movie_threshold =
float(__addon__.getSetting("movie_threshold"))
+ self.movie_preset = int(__addon__.getSetting("movie_preset"))
+
+ # Music Video settings
+ self.music_saturation =
float(__addon__.getSetting("musicvideo_saturation"))
+ self.music_value =
float(__addon__.getSetting("musicvideo_value"))
+ self.music_speed =
float(__addon__.getSetting("musicvideo_speed"))
+ self.music_autospeed =
float(__addon__.getSetting("movie_autospeed"))
+ self.music_interpolation =
int(__addon__.getSetting("musicvideo_interpolation") == "true")
+ self.music_threshold =
float(__addon__.getSetting("musicvideo_threshold"))
+ self.music_preset =
int(__addon__.getSetting("musicvideo_preset"))
+
+ #handle boblight configuration from the "Movie" category
+ #returns the new settings
+ def setupForMovie(self):
+ log('settings() - setupForMovie')
- if category == "other" and other_static_bg and not g_bobdisable:#for now
enable static light on other if settings want this
- bob_set_priority(128) #allow lights to be
turned on
- rgb = (c_int * 3)(other_static_red,other_static_green,other_static_blue)
- bob_set_static_color(byref(rgb))
- g_staticBobActive = True
- else:
- g_staticBobActive = False
-
-#handles the boblight configuration of all categorys
-#and applies changed settings to boblight
-#"movie","musicvideo" and "other
-#returns if a setting has been changed
-def settings_handleGlobalSettings(category):
- global g_saturation
- global g_value
- global g_speed
- global g_autospeed
- global g_interpolation
- global g_threshold
- settingChanged = False
-
- #call the right setup function according to categroy
- #switch case in python - dictionary with function pointers
- option = { "movie" : settings_setupForMovie,
- "musicvideo" : settings_setupForMusicVideo,
- "other" : settings_setupForOther,
- }
- saturation,value,speed,autospeed,interpolation,threshold = option[category]()
-
- #setup boblight - todo error checking
- if g_saturation != saturation:
- ret = bob_setoption("saturation " + str(saturation))
- settingChanged = True
- print "boblight: changed saturation to " + str(saturation) + "(ret " +
str(ret) + ")"
- g_saturation = saturation
+ if self.movie_preset == 1: #preset smooth
+ saturation = 3.0
+ value = 10.0
+ speed = 20.0
+ autospeed = 0.0
+ interpolation = 0
+ threshold = 0.0
+ elif self.movie_preset == 2: #preset action
+ saturation = 3.0
+ value = 10.0
+ speed = 80.0
+ autospeed = 0.0
+ interpolation = 0
+ threshold = 0.0
+ elif self.movie_preset == 0: #custom
+ saturation = self.movie_saturation
+ value = self.movie_value
+ speed = self.movie_speed
+ autospeed = self.movie_autospeed
+ interpolation = self.movie_interpolation
+ threshold = self.movie_threshold
+ return (saturation,value,speed,autospeed,interpolation,threshold)
- if g_value != value:
- ret = bob_setoption("value " + str(value))
- settingChanged = True
- print "boblight: changed value to " + str(value) + "(ret " + str(ret) + ")"
- g_value = value
-
- if g_speed != speed:
- ret = bob_setoption("speed " + str(speed))
- settingChanged = True
- print "boblight: changed speed to " + str(speed) + "(ret " + str(ret) + ")"
- g_speed = speed
-
- if g_autospeed != autospeed:
- ret = bob_setoption("autospeed " + str(autospeed))
- settingChanged = True
- print "boblight: changed autospeed to " + str(autospeed) + "(ret " +
str(ret) + ")"
- g_autospeed = autospeed
-
- if g_interpolation != interpolation:
- ret = bob_setoption("interpolation " + str(interpolation))
- settingChanged = True
- print "boblight: changed interpolation to " + str(interpolation) + "(ret "
+ str(ret) + ")"
- g_interpolation = interpolation
-
- if g_threshold != threshold:
- ret = bob_setoption("threshold " + str(threshold))
- settingChanged = True
- print "boblight: changed threshold to " + str(threshold) + "(ret " +
str(ret) + ")"
- g_threshold = threshold
- return settingChanged
-
-#handle change of category we are in
-#"movie","musicvideo" or "other"
-#returns if category has changed
-def settings_handleCategory(category):
- global g_category
- categoryChanged = False
-
- if g_category != category:
- categoryChanged = True #don't change notify
when category changes
- print "boblight: use settings for " + category
- g_category = category
- return categoryChanged
-
-#handle bob disable setting
-#sets the global g_bobdisable and prints
-#toast dialog on disable
-def settings_handleDisableSetting():
- global g_bobdisable
- bobdisable = __settings__.getSetting("bobdisable") == "true"
-
- if g_bobdisable != bobdisable:
- if bobdisable:
- text = __settings__.getLocalizedString(503)
- xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" %
(__scriptname__,text,10,__icon__))
- print "boblight: boblight disabled"
+ #handle boblight configuration from the "MusicVideo" category
+ #returns the new settings
+ def setupForMusicVideo(self):
+ log('settings() - setupForMusicVideo')
+
+ if self.music_preset == 1: #preset Ballad
+ saturation = 3.0
+ value = 10.0
+ speed = 20.0
+ autospeed = 0.0
+ interpolation = 1
+ threshold = 0.0
+ elif self.music_preset == 2: #preset Rock
+ saturation = 3.0
+ value = 10.0
+ speed = 80.0
+ autospeed = 0.0
+ interpolation = 0
+ threshold = 0.0
+ elif self.music_preset == 0: #custom
+ saturation = self.music_saturation
+ value = self.music_value
+ speed = self.music_speed
+ autospeed = self.music_autospeed
+ interpolation = self.music_interpolation
+ threshold = self.music_threshold
+ return (saturation,value,speed,autospeed,interpolation,threshold)
+
+ #handle boblight configuration from the "other" category
+ #returns the new settings
+ def setupForOther(self):
+ log('settings() - setupForOther')
+ # FIXME don't use them for now - reactivate when boblight works on non
rendered scenes (e.x. menu)
+ # saturation = float(__addon__.getSetting("other_saturation"))
+ # value = float(__addon__.getSetting("other_value"))
+ # speed = float(__addon__.getSetting("other_speed"))
+ # autospeed = float(__addon__.getSetting("other_autospeed"))
+ # interpolation = __addon__.getSetting("other_interpolation") == "true"
+ # threshold = float(__addon__.getSetting("other_threshold"))
+ return self.setupForStatic()
+
+ #handle boblight configuration for static lights
+ #returns the new settings
+ def setupForStatic(self):
+ log('settings() - setupForStatic')
+ saturation = 4.0
+ value = 1.0
+ speed = 50.0
+ autospeed = 0.0
+ interpolation = 1
+ threshold = 0.0
+ return (saturation,value,speed,autospeed,interpolation,threshold)
+
+ #handle all settings according to the static bg light
+ #this is used until category "other" can do real boblight
+ #when no video is rendered
+
+ def handleStaticBgSettings(self):
+ log('settings() - handleStaticBgSettings')
+ if (self.category == "static" and # only for 'static'
category
+ self.other_static_bg and # only if we want it
displayed on static
+ (not (self.screensaver and
+ self.other_static_onscreensaver)) # only if screen saver
is off and we want it on
+ ):
+ bob.bob_set_priority(128) # allow lights to be
turned on
+ rgb = (c_int * 3)(self.other_static_red,
+ self.other_static_green,
+ self.other_static_blue)
+ ret = bob.bob_set_static_color(byref(rgb))
+ self.staticBobActive = True
else:
- print "boblight: boblight enabled"
- g_bobdisable = bobdisable
-
-#handles all settings of boblight and applies them as needed
-#returns if a reconnect is needed due to settings changes
-def settings_setup():
- global g_overwrite_cat
- global g_overwrite_cat_val
- reconnect = False
- settingChanged = False
- categoryChanged = False
-
- g_overwrite_cat = __settings__.getSetting("overwrite_cat") == "true"
- g_overwrite_cat_val = int(__settings__.getSetting("overwrite_cat_val"))
-
- category = settings_getSettingCategory()
- categoryChanged = settings_handleCategory(category)
- reconnect = settings_handleNetworkSettings()
- settingChanged = settings_handleGlobalSettings(category)
- settings_handleStaticBgSettings(category)
- settings_handleDisableSetting()
-
- #notify user via toast dialog when a setting was changed (beside category
changes)
- if settingChanged and not categoryChanged:
- text = __settings__.getLocalizedString(502)
- xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" %
(__scriptname__,text,10,__icon__))
-
- return reconnect
+ bob.bob_set_priority(255)
+ self.staticBobActive = False
+
+ #handles the boblight configuration of all categorys
+ #and applies changed settings to boblight
+ #"movie","musicvideo", "other and "static"
+ def handleGlobalSettings(self):
+ log('settings() - handleGlobalSettings')
+ if (self.current_option != self.category) or self.force_update:
+ #call the right setup function according to categroy
+ #switch case in python - dictionary with function pointers
+ option = { "movie" : self.setupForMovie,
+ "musicvideo" : self.setupForMusicVideo,
+ "other" : self.setupForOther,
+ "static" : self.setupForStatic,
+ }
+ saturation,value,speed,autospeed,interpolation,threshold =
option[self.category]()
+ for opt in OPTS:
+ ret = bob.bob_setoption("%s %s" % (opt,str(locals()[opt])))
+ log("changed %s to %s ret: %s" % (opt,str(locals()[opt]),ret))
+ self.current_option = self.category
+ self.force_update = False
+ #handle change of category we are calling
+ def handleCategory(self, category):
+ log('settings() - handleCategory(%s)' % category)
+ self.category = category
+ self.handleGlobalSettings()
+ self.handleStaticBgSettings()
+
+ def bob_init(self):
+ if self.run_init:
+ log('bob_init')
+ nrLights = bob.bob_getnrlights()
+ log("settings() - Found %s lights" % str(nrLights))
+ for i in range(nrLights):
+ lightname = bob.bob_getlightname(i)
+ log("settings() - Light[%.2d] - %s" % (i+1, lightname))
+
+ self.handleGlobalSettings()
+ bob.bob_set_priority(128) # allow lights to be turned on, we
will switch them off
+ # in 'handleStaticBgSettings()' if
they are not needed
+ for i in range(len(BLING)):
+ rgb = (c_int * 3)(BLING[i][0],BLING[i][1],BLING[i][2])
+ bob.bob_set_static_color(byref(rgb))
+ xbmc.sleep(1000)
+ self.run_init = False
+ xbmc.sleep(500)
+ return True
diff --git a/script.xbmc.boblight/resources/lib/tools.py
b/script.xbmc.boblight/resources/lib/tools.py
index 9503a75..6696d7f 100644
--- a/script.xbmc.boblight/resources/lib/tools.py
+++ b/script.xbmc.boblight/resources/lib/tools.py
@@ -1,6 +1,7 @@
+# -*- coding: utf-8 -*-
'''
Boblight for XBMC
- Copyright (C) 2011 Team XBMC
+ Copyright (C) 2012 Team XBMC
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -16,24 +17,19 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
'''
-import platform
import xbmc
import xbmcgui
import sys
import os
-import re
import urllib
-import urllib2
__scriptname__ = sys.modules[ "__main__" ].__scriptname__
-__settings__ = sys.modules[ "__main__" ].__settings__
-__cwd__ = sys.modules[ "__main__" ].__cwd__
-__icon__ = sys.modules[ "__main__" ].__icon__
+__cwd__ = sys.modules[ "__main__" ].__cwd__
+__icon__ = sys.modules[ "__main__" ].__icon__
+__language__ = sys.modules[ "__main__" ].__language__
-__libbaseurl__ = sys.modules[ "__main__" ].__libbaseurl__
-__libnameosx__ = sys.modules[ "__main__" ].__libnameosx__
-__libnameios__ = sys.modules[ "__main__" ].__libnameios__
-__libnamewin__ = sys.modules[ "__main__" ].__libnamewin__
+__libbasepath__ =
xbmc.translatePath(os.path.join(__cwd__,'resources','lib','%s') )
+__libbaseurl__ =
"http://mirrors.xbmc.org/build-deps/addon-deps/binaries/libboblight"
def DownloaderClass(url,dest):
dp = xbmcgui.DialogProgress()
@@ -47,28 +43,52 @@ def _pbhook(numblocks, blocksize, filesize,
url=None,dp=None):
except:
percent = 100
dp.update(percent)
- print "boblight: DOWNLOAD FAILED" # need to get this part working
+ log("boblight: DOWNLOAD FAILED") # need to get this part working
if dp.iscanceled():
- print "boblight: DOWNLOAD CANCELLED" # need to get this part working
- dp.close()
+ log("boblight: DOWNLOAD CANCELLED") # need to get this part working
+ dp.close()
-def tools_downloadLibBoblight():
- print "boblight: try to fetch libboblight"
- url = "none"
- dest = "none"
+def tools_downloadLibBoblight(platform):
+ log("boblight: try to fetch libboblight")
+ libname = get_libname(platform)
destdir = xbmc.translatePath( os.path.join( __cwd__, 'resources', 'lib') )
- if xbmc.getCondVisibility('system.platform.osx'):
- url = "%s/%s/%s.zip" % (__libbaseurl__, 'osx', __libnameosx__)
- dest = os.path.join( destdir, __libnameosx__)
+ url = "%s/%s/%s.zip" % (__libbaseurl__, platform, libname)
+ dest = os.path.join( destdir, libname)
+ try:
DownloaderClass(url, dest + ".zip")
+ log("%s -> %s" % (url, dest))
+ xbmc.executebuiltin('XBMC.Extract("%s.zip","%s")' % (dest, destdir), True)
+ os.remove(dest + ".zip")
+ except:
+ text = __language__(510)
+ xbmc.executebuiltin("XBMC.Notification(%s,%s,%s,%s)" %
(__scriptname__,text,750,__icon__))
+
+def log(msg):
+ xbmc.log("### [%s] - %s" % (__scriptname__,msg,),level=xbmc.LOGDEBUG )
+
+def get_platform():
+ if xbmc.getCondVisibility('system.platform.osx'):
+ platform = "osx"
+ elif xbmc.getCondVisibility('system.platform.windows'):
+ platform = "win32"
elif xbmc.getCondVisibility('system.platform.ios'):
- url = "%s/%s/%s.zip" % (__libbaseurl__, 'ios', __libnameios__)
- dest = os.path.join( destdir, __libnameios__)
- DownloaderClass(url, dest + ".zip")
- elif xbmc.getCondVisibility('system.platform.windows'):
- url = "%s/%s/%s.zip" % (__libbaseurl__, 'win32', __libnamewin__)
- dest = os.path.join( destdir, __libnamewin__)
- DownloaderClass(url, dest + ".zip")
- print "boblight: " + url + " -> " + dest
- xbmc.executebuiltin('XBMC.Extract("%s","%s")' % (dest + ".zip", destdir),
True)
- os.remove(dest + ".zip")
+ platform = "ios"
+ else:
+ platform = "linux"
+ return platform
+
+def get_libname(platform):
+ if platform == "osx":
+ return "libboblight-osx.0.dylib"
+ elif platform == "ios":
+ return "libboblight-ios.0.dylib"
+ elif platform == "win32":
+ return "libboblight-win32.0.dll"
+ elif platform == "linux":
+ return "libboblight.so"
+
+def get_libpath(platform):
+ if platform == 'linux':
+ return get_libname(platform)
+ else:
+ return __libbasepath__ % (get_libname(platform),)
diff --git a/script.xbmc.boblight/resources/settings.xml
b/script.xbmc.boblight/resources/settings.xml
index 1d3112a..a10c986 100644
--- a/script.xbmc.boblight/resources/settings.xml
+++ b/script.xbmc.boblight/resources/settings.xml
@@ -40,5 +40,6 @@
<setting id="other_static_red" type="slider" subsetting="true"
enable="eq(-1,true)" label="402" option="int" default="128" range="0,255" />
<setting id="other_static_green" type="slider" subsetting="true"
enable="eq(-2,true)" label="403" option="int" default="128" range="0,255" />
<setting id="other_static_blue" type="slider" subsetting="true"
enable="eq(-3,true)" label="404" option="int" default="128" range="0,255" />
+ <setting id="other_static_onscreensaver" type="bool" label="405"
default="false" />
</category>
</settings>
-----------------------------------------------------------------------
Summary of changes:
script.xbmc.boblight/addon.xml | 4 +-
script.xbmc.boblight/changelog.txt | 7 +
script.xbmc.boblight/default.py | 335 ++++++------
.../resources/language/English/strings.xml | 2 +
.../resources/language/German/strings.xml | 4 +-
script.xbmc.boblight/resources/lib/boblight.py | 285 ++++------
script.xbmc.boblight/resources/lib/settings.py | 586 ++++++++------------
script.xbmc.boblight/resources/lib/tools.py | 82 ++-
script.xbmc.boblight/resources/settings.xml | 1 +
9 files changed, 581 insertions(+), 725 deletions(-)
hooks/post-receive
--
Scripts
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
_______________________________________________
Xbmc-addons mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/xbmc-addons