only switch half of the lights at once to avoid led controller overload
This commit is contained in:
parent
1f4959d351
commit
7b564fc4a6
1 changed files with 12 additions and 2 deletions
|
@ -77,12 +77,22 @@ def fade_to(target, duration):
|
|||
step = duration/steps
|
||||
delta = distance/steps
|
||||
value = current
|
||||
switch = 0
|
||||
while steps:
|
||||
switch += 1
|
||||
value += delta
|
||||
n = int(round(value))
|
||||
if n != current:
|
||||
current = n
|
||||
sender[1].dmx_data = [n] * 16
|
||||
old = sender[1].dmx_data[:16]
|
||||
target = [n] * 16
|
||||
if switch % 2:
|
||||
a = target
|
||||
b = old
|
||||
else:
|
||||
a = old
|
||||
b = target
|
||||
sender[1].dmx_data = [a[x] if x % 2 else b[x] for x in range(16)]
|
||||
CURRENT_STATE = sender[1].dmx_data[:16]
|
||||
time.sleep(step)
|
||||
steps -= 1
|
||||
|
@ -98,7 +108,7 @@ def switch(state):
|
|||
#lb.fadeTo(lights, fade)
|
||||
lb.layerGo(state)
|
||||
else:
|
||||
brightness = round(lights['7'] / 255 * 50)
|
||||
brightness = lights['7']
|
||||
fade_to(brightness, duration)
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
|
Loading…
Reference in a new issue