Permalink
Browse files

Initial commit

  • Loading branch information...
1 parent a8fd4a6 commit 1e45e0ee6494a97f24749c8468f1231e33d5e6c6 @tszczerba tszczerba committed Jul 21, 2015
View
@@ -14,8 +14,6 @@ dist/
downloads/
eggs/
.eggs/
-lib/
-lib64/
parts/
sdist/
var/
View
Oops, something went wrong.
View
@@ -0,0 +1,82 @@
+import xbmc
+import os
+import sys
+
+
+
+import xbmcaddon
+import xbmcgui
+import time
+import subprocess
+addon = xbmcaddon.Addon()
+addonname = addon.getAddonInfo('name')
+addon_dir = xbmc.translatePath( addon.getAddonInfo('path') )
+#xbmcgui.Dialog().ok(addonname, os.path.join( addon_dir, 'resources', 'lib' ))
+sys.path.append(os.path.join( addon_dir, 'resources', 'lib' ) )
+try:
+ import HyperPyCon
+except Exception, e:
+ xbmcgui.Dialog().ok(addonname, repr(e)[50:])
+
+line1 = "Welcome!"
+line2 = "We are about to prepare your hyperion config file in this step-by-step wizard..."
+line3 = "You must complete all steps to have the config file generated.... Lets start!"
+
+zupa = xbmcgui.Dialog().ok(addonname, line1, line2 + line3)
+#if not zupa:
+# return
+try:
+ if "spidev" not in subprocess.check_output(['ls','/dev']):
+ xbmcgui.Dialog().ok(addonname, "We have detected that your system does not have spi enabled. You can still continue but leds may not work if you're using GPIO connection.")
+
+
+
+ xbmcgui.Dialog().ok(addonname, "In next two steps please provovide number of leds at the top edge of tv (horizontally)" +
+ " and number of leds at the side of your tv (count leds at single side only) - horizontally")
+
+
+ nol_horizontal = xbmcgui.Dialog().input("Select number of leds horizontally","16",xbmcgui.INPUT_NUMERIC)
+ nol_vertical = xbmcgui.Dialog().input("Select number of leds vertically","9",xbmcgui.INPUT_NUMERIC)
+# xbmcgui.Dialog().ok(addonname,str(nol_horizontal),str(nol_vertical))
+ hyperion_configuration = HyperPyCon.HyperPyCon(int(nol_horizontal), int(nol_vertical))
+
+ options = ["Right bottom corner and goes up","Left bottom corner and goes up"]
+ selected_index = xbmcgui.Dialog().select("Select where the led chain starts:",options)
+
+ if options[selected_index] == "Left bottom corner and goes up":
+ hyperion_configuration.led_chain.reverse_direction()
+ hyperion_configuration.led_chain.set_offset(int(nol_horizontal))
+
+ grabber = ""
+ lsusb_output = subprocess.check_output('lsusb')
+
+ if "1b71:3002" in lsusb_output:
+ grabber = "utv007"
+ elif "05e1:0408" in lsusb_output:
+ grabber = "stk1160"
+
+ if grabber != "":
+ if "video0" in subprocess.check_output(['ls','/dev']):
+ xbmcgui.Dialog().ok(addonname, "Compatible video grabber has been detected. We will add appropriate section to the config file.")
+ hyperion_configuration.config_grabber(grabber)
+ else:
+ xbmcgui.Dialog().ok(addonname, "Video grabber has been detected but video0 does not exist. Please install drivers or use different disto")
+ else:
+ xbmcgui.Dialog().ok(addonname, "We have not detected the grabber. Grabber-v4l2 section will not be added to the config file.")
+
+ xbmcgui.Dialog().ok(addonname, "That's all! Now we will attempt to restart hyperion...")
+ hyperion_configuration.save_config_file(hyperion_configuration.create_config(grabber),"/storage/.config/","hyperion.config.new")
+ hyperion_configuration.restart_hyperion("hyperion.config.new")
+ if not xbmcgui.Dialog().yesno(addonname, "Have you seen the rainbow swirl?"):
+ xbmcgui.Dialog().ok(addonname, "Something went wrong... Please try running hyperion from command line to see the error...")
+ sys.exit()
+
+ if xbmcgui.Dialog().yesno(addonname, "Do you want us to save this config as your default one?","(if No, changes will be lost after hyperion/system restart)"):
+ hyperion_configuration.overwrite_default_config()
+
+ xbmcgui.Dialog().ok(addonname, "[To be added] All hyperion settings are available in the settings of this addon. Enjoy!")
+
+except Exception, e:
+ xbmcgui.Dialog().ok(addonname, repr(e))
+
+
View
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<addon id="plugin.program.hyperion.configurator" name="Hyperion Config Creator" version="1.0.0" provider-name="tociek">
+ <requires>
+ <import addon="xbmc.python" version="2.14.0"/>
+ </requires>
+ <extension point="xbmc.python.pluginsource" library="addon.py">
+ <provides>executable</provides>
+ </extension>
+ <extension point="xbmc.addon.metadata">
+ <platform>all</platform>
+ <summary lang="en">Popup Hello World</summary>
+ <description lang="en">Example Plugin to show hello world</description>
+ <license>GNU General Public License, v2</license>
+ <language></language>
+ <forum>http://forum.kodi.tv/showthread.php?tid=209948</forum>
+ <source>https://github.com/zag2me/plugin.program.hello.world</source>
+ <email>zag@kodi.org</email>
+ </extension>
+</addon>
View
@@ -0,0 +1 @@
+1.0.0 Initial Release
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,101 @@
+from sys import argv
+import time, subprocess
+from collections import OrderedDict
+from Led import Led, LedChain
+import HyperionConfigTester
+import HyperionConfigSections
+import sys
+import json
+import os
+import shutil
+
+class HyperPyCon:
+ def __init__(self, nol_horizontal, nol_vertical):
+ self.total_number_of_leds = ((nol_horizontal + nol_vertical) * 2)
+ self.led_chain = LedChain(self.total_number_of_leds)
+ self.led_chain.generate_layout(nol_horizontal, nol_vertical)
+ self.transform = HyperionConfigSections.Transform("leds","0-"+str(self.total_number_of_leds-1),
+ HyperionConfigSections.HSV(1.0,1.0),
+ HyperionConfigSections.SingleColor(0.05,2.2,0,1),
+ HyperionConfigSections.SingleColor(0.05,2.0,0,0.85),
+ HyperionConfigSections.SingleColor(0.05,2.0,0,0.85))
+ self.color = HyperionConfigSections.Color()
+ self.smoothing = HyperionConfigSections.Smoothing("linear",100,20)
+ self.device = HyperionConfigSections.Device()
+ self.blackborderdetector = HyperionConfigSections.blackborderdetectord
+ self.effects = HyperionConfigSections.effectsd
+ self.bootsequence = HyperionConfigSections.bootsequenced
+ self.framegrabber = HyperionConfigSections.framegrabberd
+ self.xbmcVideoChecker = HyperionConfigSections.XBMCVideoChecker()
+ self.jsonServer = HyperionConfigSections.json_serverd
+ self.protoServer = HyperionConfigSections.proto_serverd
+ self.grabber = HyperionConfigSections.GrabberV4l2()
+
+ def create_config(self, add_grabber):
+ self.color.add_transformation(self.transform)
+ self.color.set_smoothing(self.smoothing)
+ hyperion_config_dict = OrderedDict(
+ device = self.device.to_dict(),
+ color = self.color.to_dict(),
+ leds = self.led_chain.get_list_of_leds_dicts(),
+ blackborderdetector = self.blackborderdetector,
+ effects = self.effects,
+ bootsequence = self.bootsequence,
+ framegrabber = self.framegrabber,
+ xbmcVideoChecker = self.xbmcVideoChecker.to_dict(),
+ jsonServer = self.jsonServer,
+ protoServer = self.protoServer,
+ endOfJson = 'endOfJson')
+
+ if add_grabber:
+ hyperion_config_dict.update(OrderedDict(grabber_v4l2 = HyperionConfigSections.GrabberV4l2().to_dict()))
+
+ return json.dumps(hyperion_config_dict,sort_keys=False,indent=4, separators=(',', ': ')).replace("grabber_v4l2","grabber-v4l2")
+
+ def save_config_file(self,content,folder,file_name):
+ self.config_file_path = folder+file_name
+ f = open(folder+file_name,"w", 0777)
+ f.write(content)
+ f.close()
+
+ def overwrite_default_config(self):
+ if os.uname()[1] == "OpenELEC":
+ config_folder = "/storage/.config/"
+ else:
+ config_folder = "/etc/"
+ raise "It is not OE"
+ #return config_folder+"hyperion_config_json" + config_folder+"hyperion_config_json_bak"
+ shutil.copyfile(config_folder+"hyperion.config.json",config_folder+"hyperion.config.json_bak")
+ shutil.copyfile(self.config_file_path,config_folder+"hyperion.config.json")
+
+ def config_grabber(self,grabber_model):
+ """setting grabber specific parameters. utv007 model is default"""
+ if grabber_model == "stk1160":
+ self.grabber.width = 240
+ self.grabber.height = 192
+ self.grabber.frame_decimation = 2
+ self.grabber.size_decimation = 20
+
+ def restart_hyperion(self,hyperion_config_file_name):
+ HyperionConfigTester.HyperionConfigTester().restart_hyperion(hyperion_config_file_name)
+
+
+
+#h = HyperPyCon(23,23)
+#h.restart_hyperion()
+#print "Config ready"
+#print "Testing leds..."
+#test = HyperionConfigTester.HyperionConfigTester(led_chain, "OPENELEC")
+#test.connect_to_hyperion()
+#test.mark_corners()
+##test.change_colors()
+##time.sleep(5)
+#test.set_single_color(255,255,0)
+##test.change_colors()
+##time.sleep(5)
+#test.disconnect();
+
+#print json.dumps(hyperion_dict_templates.GrabberV4l2.to_dict())
+
+
+
@@ -0,0 +1,177 @@
+import json
+from collections import OrderedDict
+
+blackborderdetectord = dict(enable = True, threshold = 0.05)
+effectsd = dict(paths = ["/storage/hyperion/effects"])
+bootsequenced = dict(effect = "Rainbow swirl fast", duration_ms = 1000)
+framegrabberd = dict(width = 64, height = 64, frequency_Hz = 10.0)
+json_serverd = dict(port = 19444)
+proto_serverd = dict(port = 19445)
+
+class Device:
+ name = "MyPi"
+ type = "ws2801"
+ output = "/dev/spidev0.0"
+ rate = 250000
+ color_order = "rgb"
+
+ def __init__(self):
+ self.name = "MyPi"
+ self.type = "ws2801"
+ self.output = "/dev/spidev0.0"
+ self.rate = 500000
+ self.color_order = "rgb"
+
+ def to_dict(self):
+ return OrderedDict(name = self.name, type = self.type, output = self.output, rate = self.rate, colorOrder = self.color_order)
+
+
+class SingleColor:
+ threshold = 0.0700
+ gamma = 2.0000
+ blacklevel = 0.0000
+ whitelevel = 1.0000
+
+ def __init__(self,threshold,gamma,blacklevel,whitelevel):
+ self.threshold = threshold
+ self.gamma = gamma
+ self.blacklevel = blacklevel
+ self.whitelevel = whitelevel
+
+ def to_dict(self):
+ return OrderedDict(threshold = self.threshold, gamma = self.gamma, blacklevel = self.blacklevel, whitelevel = self.whitelevel)
+
+
+class HSV:
+ saturation_gain = 1.0000
+ value_gain = 1.0000
+
+ def __init__(self,saturation_gain,value_gain):
+ self.saturation_gain = saturation_gain
+ self.value_gain = value_gain
+
+ def to_dict(self):
+ return OrderedDict(saturationGain = self.saturation_gain, valueGain = self.value_gain )
+
+class Transform:
+ tranformation_id = "default"
+ leds_indexes_range = "*"
+ red = None
+ green = None
+ blue = None
+ hsv = None
+
+ def __init__(self,tranformation_id, leds_indexes_range, hsv, red, green, blue):
+ """red,green,blue must be isntances of SingleColorParms"""
+ self.tranformation_id = tranformation_id
+ self.leds_indexes_range = leds_indexes_range
+ self.red = red
+ self.green = green
+ self.blue = blue
+ self.hsv = hsv
+
+ def to_dict(self):
+ return OrderedDict(id = self.tranformation_id, leds = self.leds_indexes_range, hsv = self.hsv.to_dict(), red = self.red.to_dict(), green = self.green.to_dict(), blue = self.blue.to_dict())
+
+class Smoothing:
+ type = 'linear'
+ time_ms = 100
+ update_frequency = 20.0000
+
+ def __init__(self,type,time_ms,update_frequency):
+ self.type = type
+ self.time_ms = time_ms
+ self.update_frequency = update_frequency
+
+ def to_dict(self):
+ return OrderedDict(type = self.type,time_ms = self.time_ms,updateFrequency = self.update_frequency)
+
+class Color:
+ transformations = []
+ smoothing = None
+
+ def __init__(self):
+ self.transformations = []
+ pass
+
+ def add_transformation(self, transformation):
+ self.transformations.append(transformation.to_dict())
+
+ def set_smoothing(self, smoothing):
+ self.smoothing = smoothing
+
+ def to_dict(self):
+ return OrderedDict(transform = self.transformations,smoothing = self.smoothing.to_dict())
+
+class BootSequence:
+ def __init__(self):
+ self.effect = "Rainbow swirl fast"
+ self.duration_ms = 1000
+
+ def to_dict(self):
+ return OrderedDict(effect = self.effect, duration_ms = self.duration_ms)
+
+class XBMCVideoChecker:
+ def __init__(self):
+ self.xbmc_address = "127.0.0.1"
+ self.xbmc_tcp_port = 9090
+ self.grab_video = True
+ self.grab_pictures = True
+ self.grab_audio = True
+ self.grab_menu = False
+ self.grab_screensaver = True
+ self.enable_3D_detection = True
+
+ def to_dict(self):
+ return dict(xbmcAddress = self.xbmc_address, xbmcTcpPort = self.xbmc_tcp_port, grabVideo = self.grab_video, grabPictures = self.grab_pictures,
+ grabAudio = self.grab_audio, grabMenu = self.grab_menu, grabScreensaver = self.grab_screensaver, enable3DDetection = self.enable_3D_detection)
+
+class GrabberV4l2:
+ def __init__(self):
+ self.device = "/dev/video0"
+ self.input = 0
+ self.standard = "PAL"
+ self.width = 720
+ self.height = 576
+ self.frame_decimation = 2
+ self.size_decimation = 8
+ self.priority = 1200
+ self.mode = "2D"
+ self.crop_left = 5
+ self.crop_right = 5
+ self.crop_top = 5
+ self.crop_bottom = 5
+ self.red_signal_threshold = 0.2
+ self.green_signal_threshold = 0.2
+ self.blue_signal_threshold = 0.2
+
+ def to_dict(self):
+ return OrderedDict(
+ device = self.device,
+ input = self.input,
+ standard = self.standard,
+ width = self.width,
+ height = self.height,
+ frameDecimation = self.frame_decimation,
+ sizeDecimation = self.size_decimation,
+ priority = self.priority,
+ mode = self.mode,
+ cropLeft = self.crop_left,
+ cropRight = self.crop_right,
+ cropTop = self.crop_top,
+ cropBottom = self.crop_bottom,
+ redSignalThreshold = self.red_signal_threshold,
+ greenSignalThreshold = self.green_signal_threshold,
+ blueSignalThreshold = self.blue_signal_threshold
+ )
+
+
+
+
+
+
+
+
+
+
+
Oops, something went wrong.

0 comments on commit 1e45e0e

Please sign in to comment.