Skip to content

Commit f7a3686

Browse files
author
tociek
committed
Bug fixes including issue#1
1 parent f1d2632 commit f7a3686

File tree

3 files changed

+39
-32
lines changed

3 files changed

+39
-32
lines changed

addon.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@
4848

4949
if grabber != "":
5050
if "video0" in subprocess.check_output(['ls','/dev']):
51-
xbmcgui.Dialog().ok(addonname, "Compatible video grabber has been detected. We will add appropriate section to the config file.")
52-
hyperion_configuration.config_grabber(grabber)
51+
if xbmcgui.Dialog().yesno(addonname, "Compatible video grabber has been detected. Do you want to enable video grabber in hyperion?"):
52+
hyperion_configuration.config_grabber(grabber)
5353
else:
5454
xbmcgui.Dialog().ok(addonname, "Video grabber has been detected but video0 does not exist. Please install drivers or use different disto")
5555
else:

changelog.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
1.0.0 Initial Release
2+
3+
1.0.1 Bug Fixes (issue#1 + few more :) )

resources/lib/Led.py

Lines changed: 35 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,43 @@ def __init__(self):
66
self.y_start = 0
77
self.y_end = 0
88
self.position = 0
9-
self.color = bytearray([0,0,0])
10-
9+
self.color = bytearray([0,0,0])
10+
1111
def setCoordinates(self, in_x_start, in_x_end, in_y_start,in_y_end):
1212
self.x_start = in_x_start
1313
self.x_end = in_x_end
1414
self.y_start = in_y_start
1515
self.y_end = in_y_end
1616

17+
1718
def printRaw(self):
1819
print "led [" , self.position , "] - (" , self.x_start , " , " , self.x_end , ") , Y(", self.y_start , " , " , self.y_end , ")"
19-
20+
2021
def hscan_to_dict(self):
2122
"""returns dictionary for horizontal coordinates"""
2223
return dict(minimum = round(self.x_start,4), maximum = round(self.x_end,4))
23-
24+
2425
def vscan_to_dict(self):
2526
"""returns dictionary for vertical coordinates"""
26-
return dict(minimum = round(self.y_start,4), maximum = round(self.y_end,4))
27-
27+
return dict(minimum = round(self.y_start,4), maximum = round(self.y_end,4))
28+
2829
def to_json_string(self):
2930
return json.dumps(self.vscan_to_dict(),sort_keys=False,indent=4, separators=(',', ': '))
30-
31+
3132
def set_color(self,red, green, blue):
3233
if red > 255 or red < 0 or green > 255 or green < 0 or blue > 255 or blue < 0 :
3334
raise "Incorrect values (must be between <0,255>"
3435
else:
35-
self.color = bytearray([red,green,blue])
36+
self.color = bytearray([red,green,blue])
37+
38+
3639

3740
class LedChain:
3841
def __init__(self, no_of_leds):
3942
self.number_of_leds = no_of_leds
4043
self.leds = []
4144
self.offset = 0
42-
45+
4346
def generate_layout(self, nol_horizontal, nol_vertical):
4447
"""key method in this class - it calculates coordinates of picture scan area. As a result
4548
there are Led instances created with coordinates assigned"""
@@ -49,10 +52,10 @@ def generate_layout(self, nol_horizontal, nol_vertical):
4952
area_bottom_coordinate = 0.0
5053
area_left_coordinate = 0.0
5154
area_right_coordinate = 0.0
52-
55+
5356
self.vertical_segment = 1.0/nol_vertical
5457
self.horizontal_segment = 1.0/nol_horizontal
55-
for i in range(0,self.number_of_leds):
58+
for i in range(0,self.number_of_leds):
5659
if i < nol_vertical: # right
5760
vertical_position = i+1
5861
area_top_coordinate = (1 -(self.vertical_segment * vertical_position))
@@ -69,15 +72,16 @@ def generate_layout(self, nol_horizontal, nol_vertical):
6972
area_top_coordinate = (1 - self.vertical_segment)
7073
horizontal_position = i - nol_vertical - nol_horizontal - nol_vertical
7174
area_left_coordinate = horizontal_position * self.horizontal_segment
72-
75+
7376
area_bottom_coordinate = area_top_coordinate + self.vertical_segment
7477
area_right_coordinate = area_left_coordinate + self.horizontal_segment
7578
led = Led()
7679
led.setCoordinates(area_left_coordinate,area_right_coordinate, area_top_coordinate,area_bottom_coordinate)
7780
led.position = i
7881
self.leds.append(led)
7982
self.original_chain = list(self.leds) #make a copy of initial setup
80-
83+
84+
8185
def set_overlap(self,overlap_pct):
8286
"""Use this method if you want to have leds scanning areas overlaping each other
8387
(to loose some details of the effect, to make it smoother"""
@@ -88,60 +92,61 @@ def set_overlap(self,overlap_pct):
8892
led.x_end = min(led.x_end + self.horizontal_overlap,1)
8993
led.y_start = max(led.y_start - self.vertical_overlap,0)
9094
led.y_end = min(led.y_end + self.vertical_overlap,1)
91-
95+
9296
def reverse_direction(self):
9397
"""Reverses leds direction from counterclockwise to clockwise"""
9498
self.leds.reverse()
95-
99+
96100
def left_bottom_start(self):
97101
"""Moves the start of leds from right to left bottom corner for clockwise direction"""
98-
102+
99103
def set_offset(self, offset_value):
100104
"""it can be useful when your leds do not start at right/bottom corner, but, lets say, from the middle of bottom edge"""
101105
if offset_value > 0:
102-
self.leds.append(self.leds[0:offset_value-1])
103-
del self.leds[0:offset_value-1]
106+
for i in range(offset_value):
107+
self.leds.append(self.leds.pop(0))
104108
elif offset_value < 0:
105-
self.leds.insert(0,self.leds[self.no_of_leds+offset_value-1,self.no_of_leds-1])
106-
del self.leds[self.no_of_leds+offset_value-1,self.no_of_leds-1]
107-
109+
for i in range(offset_value):
110+
self.leds.insert(0,self.leds.pop(self.no_of_leds-1))
111+
108112
def print_me(self):
109113
for i in range(0,len(self.leds)):
110114
self.leds[i].printRaw()
111-
115+
112116
def to_string(self):
113117
for i in range(0,len(self.leds)):
114118
self.leds[i].printRaw()
115-
119+
116120
def leds_to_json_string(self):
117121
"""Returns json string representing the leds"""
118122
leds_array = []
119123
for i in range(0,len(self.leds)):
120124
leds_array.append(dict(index = i,hscan = self.leds[i].hscan_to_dict(), vscan = self.leds[i].vscan_to_dict()))
121125
return json.dumps(leds_array,sort_keys=False,indent=4, separators=(',', ': '))
122-
126+
123127
def get_list_of_leds_dicts(self):
124-
"""Returns json string representing the leds"""
128+
"""Returns array of dicts leds"""
125129
leds_array = []
126130
for i in range(0,len(self.leds)):
127131
leds_array.append(dict(index = i,hscan = self.leds[i].hscan_to_dict(), vscan = self.leds[i].vscan_to_dict()))
128-
return leds_array
129-
132+
return leds_array
133+
134+
130135
def leds_to_bytearray(self):
131136
"""Converts leds' colors into bytearray. Useful if you want to send the data to the leds via hyperion interface"""
132137
data = bytearray()
133138
for led in self.leds:
134139
data += led.color
135140
return data
136-
141+
137142
def set_single_color(self,red,green,blue):
138143
"""Sets single color for all leds"""
139144
if red > 255 or red < 0 or green > 255 or green < 0 or blue > 255 or blue < 0 :
140145
raise "Incorrect values (must be between <0,255>)"
141146
else:
142147
for i in range(len(self.leds)):
143-
self.leds[i].set_color(red, green, blue)
144-
148+
self.leds[i].set_color(red, green, blue)
149+
145150
#test
146151
#t = LedChain(50)
147152
#t.set_offset(5)

0 commit comments

Comments
 (0)