Skip to content

Commit c647019

Browse files
author
tociek
committed
big fixes, control image added and bottom/center option
1 parent bb01a0e commit c647019

6 files changed

Lines changed: 51 additions & 11 deletions

File tree

addon.py

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,35 @@
1919
xbmcgui.Dialog().ok(addonname, line1, line2 + line3)
2020

2121
try:
22-
if "spidev" not in subprocess.check_output(['ls','/dev']):
23-
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/SPI connection."+
24-
" For USB connection you are safe to proceed")
22+
23+
device_versions = [ HyperPyCon.HyperPyCon.ws2801 , HyperPyCon.HyperPyCon.adalight ]
24+
selected_device = xbmcgui.Dialog().select("Select your led device:",device_versions)
25+
if selected_device == 0:
26+
if "spidev" not in subprocess.check_output(['ls','/dev']):
27+
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/SPI connection")
2528

2629
xbmcgui.Dialog().ok(addonname, "In next two steps please provovide number of leds at the top edge of tv (horizontally)" +
2730
" and number of leds at the side of your tv (count leds at single side only) - horizontally")
2831

29-
nol_horizontal = xbmcgui.Dialog().input("Select number of leds horizontally","16",xbmcgui.INPUT_NUMERIC)
30-
nol_vertical = xbmcgui.Dialog().input("Select number of leds vertically","9",xbmcgui.INPUT_NUMERIC)
32+
nol_horizontal = xbmcgui.Dialog().input("Select number of leds horizontally","29",xbmcgui.INPUT_NUMERIC)
33+
nol_vertical = xbmcgui.Dialog().input("Select number of leds vertically","16",xbmcgui.INPUT_NUMERIC)
3134

3235
hyperion_configuration = HyperPyCon.HyperPyCon(int(nol_horizontal), int(nol_vertical))
36+
hyperion_configuration.set_device_type(device_versions[selected_device])
3337

34-
options = ["Right bottom corner and goes up","Left bottom corner and goes up"]
38+
options = ["Right/bottom corner and goes up","Left/bottom corner and goes up","Center/bottom and goes right","Center/bottom and goes left"]
3539
selected_index = xbmcgui.Dialog().select("Select where the led chain starts:",options)
3640

37-
if options[selected_index] == "Left bottom corner and goes up":
41+
if selected_index == 1:
3842
hyperion_configuration.led_chain.reverse_direction()
3943
hyperion_configuration.led_chain.set_offset(int(nol_horizontal))
44+
elif selected_index == 2 or selected_index == 3:
45+
offset = xbmcgui.Dialog().input("How many leds from the center to the corner or the screen?","15",xbmcgui.INPUT_NUMERIC)
46+
if selected_index == 2:
47+
hyperion_configuration.led_chain.set_offset((-1)*int(offset))
48+
else:
49+
hyperion_configuration.led_chain.reverse_direction()
50+
hyperion_configuration.led_chain.set_offset(int(offset))
4051

4152
grabber = ""
4253
lsusb_output = subprocess.check_output('lsusb')
@@ -64,7 +75,17 @@
6475
else:
6576
xbmcgui.Dialog().ok(addonname, "For the next 10 seconds you will see leds in 3 corners marked with different colors. Check if they are exactly in the corners."+
6677
" If not, start this wizard again and provide correct numbers of leds horizontally and vertically.")
67-
hyperion_configuration.test_corners(10)
78+
#hyperion_configuration.test_corners(10)
79+
okno = xbmcgui.WindowDialog(xbmcgui.getCurrentWindowId())
80+
#obrazek = xbmcgui.ControlImage(0,0,okno.getWidth(),okno.getHeight(),addon_dir+"/test_picture.png")
81+
obrazek = xbmcgui.ControlImage(0,0,1280,720,addon_dir+"/test_picture.png")
82+
okno.addControl(obrazek)
83+
okno.show()
84+
obrazek.setVisible(True)
85+
hyperion_configuration.show_test_image(addon_dir+"/test_picture.png")
86+
time.sleep(10)
87+
okno.close()
88+
hyperion_configuration.clear_leds()
6889

6990
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)"):
7091
hyperion_configuration.overwrite_default_config()

changelog.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
1.0.0 Initial Release
22

3-
1.0.1 Bug Fixes (issue#1 + few more :) )
3+
1.0.1 Bug fixes + control image added + bottom/center configuration added

resources/lib/HyperPyCon.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import shutil
1111

1212
class HyperPyCon:
13+
ws2801 = "Lightberry for Raspberry Pi"
14+
adalight = "Lightberry USB"
1315
def __init__(self, nol_horizontal, nol_vertical):
1416
self.total_number_of_leds = ((nol_horizontal + nol_vertical) * 2)
1517
self.led_chain = LedChain(self.total_number_of_leds)
@@ -33,6 +35,11 @@ def __init__(self, nol_horizontal, nol_vertical):
3335

3436
self.tester = HyperionConfigTester.HyperionConfigTester(self.led_chain)
3537

38+
def set_device_type(self,device_type):
39+
if device_type == HyperPyCon.adalight:
40+
self.device.type = "adalight"
41+
self.device.output = "/dev/ttyACM0"
42+
3643
def create_config(self, add_grabber):
3744
self.color.add_transformation(self.transform)
3845
self.color.set_smoothing(self.smoothing)
@@ -87,7 +94,11 @@ def test_corners(self,duration):
8794
time.sleep(duration)
8895
self.tester.disconnect()
8996

90-
97+
def show_test_image(self, image_path):
98+
self.tester.show_test_image(image_path)
99+
100+
def clear_leds(self):
101+
self.tester.clear_leds()
91102

92103

93104
#h = HyperPyCon(23,23)

resources/lib/HyperionConfigTester.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@ def __init__(self, chain = None):
1212
if os.uname()[1] == "OpenELEC":
1313
self.hyperion_path = "/storage/hyperion/bin/hyperiond.sh"
1414
self.config_folder = "/storage/.config/"
15+
self.hyperion_remote_path = "/storage/hyperion/bin/hyperion-remote.sh"
1516
else: #not tested
1617
self.hyperion_path = "hyperiond"
1718
self.config_folder = "/etc/"
19+
self.hyperion_remote_path = "hyperion-remote"
1820

1921
def restart_hyperion(self,config_file_name):
2022
subprocess.call(["killall", "hyperiond"])
@@ -38,3 +40,9 @@ def set_single_color(self, red, green, blue):
3840

3941
def disconnect(self):
4042
self.connection.disconnect()
43+
44+
def show_test_image(self, test_image_path):
45+
subprocess.Popen([self.hyperion_remote_path,"-i", test_image_path])
46+
47+
def clear_leds(self):
48+
subprocess.Popen([self.hyperion_remote_path,"-c", "000000"])

resources/lib/Led.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def set_offset(self, offset_value):
106106
for i in range(offset_value):
107107
self.leds.append(self.leds.pop(0))
108108
elif offset_value < 0:
109-
for i in range(offset_value):
109+
for i in range((-1)*offset_value):
110110
self.leds.insert(0,self.leds.pop(self.no_of_leds-1))
111111

112112
def print_me(self):

test_picture.png

3.88 KB
Loading

0 commit comments

Comments
 (0)