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
|
step = duration/steps
|
||||||
delta = distance/steps
|
delta = distance/steps
|
||||||
value = current
|
value = current
|
||||||
|
switch = 0
|
||||||
while steps:
|
while steps:
|
||||||
|
switch += 1
|
||||||
value += delta
|
value += delta
|
||||||
n = int(round(value))
|
n = int(round(value))
|
||||||
if n != current:
|
if n != current:
|
||||||
current = n
|
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]
|
CURRENT_STATE = sender[1].dmx_data[:16]
|
||||||
time.sleep(step)
|
time.sleep(step)
|
||||||
steps -= 1
|
steps -= 1
|
||||||
|
@ -98,7 +108,7 @@ def switch(state):
|
||||||
#lb.fadeTo(lights, fade)
|
#lb.fadeTo(lights, fade)
|
||||||
lb.layerGo(state)
|
lb.layerGo(state)
|
||||||
else:
|
else:
|
||||||
brightness = round(lights['7'] / 255 * 50)
|
brightness = lights['7']
|
||||||
fade_to(brightness, duration)
|
fade_to(brightness, duration)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
Loading…
Reference in a new issue