From fb8c10876b6cc9ebe0a49521342292371ad8ce26 Mon Sep 17 00:00:00 2001 From: jm-github Date: Thu, 30 Oct 2014 16:02:30 +0000 Subject: [PATCH 1/9] 5 more effects Former-commit-id: e6a826299ad48143cb155e7113a34bd6d3b20246 --- effects/loop.json | 7 +++++++ effects/loop.py | 34 ++++++++++++++++++++++++++++++++++ effects/loop2.json | 7 +++++++ effects/loop2.py | 33 +++++++++++++++++++++++++++++++++ effects/random.json | 7 +++++++ effects/random.py | 25 +++++++++++++++++++++++++ effects/sparks-color.json | 7 +++++++ effects/sparks-color.py | 35 +++++++++++++++++++++++++++++++++++ effects/sparks.json | 7 +++++++ effects/sparks.py | 33 +++++++++++++++++++++++++++++++++ 10 files changed, 195 insertions(+) create mode 100644 effects/loop.json create mode 100644 effects/loop.py create mode 100644 effects/loop2.json create mode 100644 effects/loop2.py create mode 100644 effects/random.json create mode 100644 effects/random.py create mode 100644 effects/sparks-color.json create mode 100644 effects/sparks-color.py create mode 100644 effects/sparks.json create mode 100644 effects/sparks.py diff --git a/effects/loop.json b/effects/loop.json new file mode 100644 index 00000000..9415f8b1 --- /dev/null +++ b/effects/loop.json @@ -0,0 +1,7 @@ +{ + "name" : "Loop", + "script" : "loop.py", + "args" : + { + } +} diff --git a/effects/loop.py b/effects/loop.py new file mode 100644 index 00000000..93011e97 --- /dev/null +++ b/effects/loop.py @@ -0,0 +1,34 @@ +import hyperion +import time +import colorsys +import random + +# Initialize the led data +ledData = bytearray() +for i in range(hyperion.ledCount): + ledData += bytearray((0,0,0)) + +sleepTime = 0.002 + +runners = [ +{ "i":0, "pos":0, "c":0, "step":9 , "lvl":255}, +{ "i":1, "pos":0, "c":0, "step":8 , "lvl":255}, +{ "i":2, "pos":0, "c":0, "step":7 , "lvl":255}, +{ "i":0, "pos":0, "c":0, "step":6 , "lvl":0}, +{ "i":1, "pos":0, "c":0, "step":5 , "lvl":0}, +{ "i":2, "pos":0, "c":0, "step":4, "lvl":0}, +] + +# Start the write data loop +while not hyperion.abort(): + for r in runners: + if r["c"] == 0: + #ledData[r["pos"]*3+r["i"]] = 0 + r["c"] = r["step"] + r["pos"] = (r["pos"]+1)%hyperion.ledCount + ledData[r["pos"]*3+r["i"]] = int(r["lvl"]*(0.2+0.8*random.random())) + else: + r["c"] -= 1 + + hyperion.setColor(ledData) + time.sleep(sleepTime) diff --git a/effects/loop2.json b/effects/loop2.json new file mode 100644 index 00000000..77f2c438 --- /dev/null +++ b/effects/loop2.json @@ -0,0 +1,7 @@ +{ + "name" : "Loop2", + "script" : "loop2.py", + "args" : + { + } +} diff --git a/effects/loop2.py b/effects/loop2.py new file mode 100644 index 00000000..3498ac4e --- /dev/null +++ b/effects/loop2.py @@ -0,0 +1,33 @@ +import hyperion +import time +import colorsys +import random + +# Initialize the led data +ledData = bytearray() +for i in range(hyperion.ledCount): + ledData += bytearray((0,0,0)) + +sleepTime = 0.005 + +runners = [ +{ "pos":0, "step":4 , "lvl":255}, +{ "pos":1, "step":5 , "lvl":255}, +{ "pos":2, "step":6 , "lvl":255}, +{ "pos":0, "step":7 , "lvl":255}, +{ "pos":1, "step":8 , "lvl":255}, +{ "pos":2, "step":9, "lvl":255}, +] + +# Start the write data loop +count = 0 +while not hyperion.abort(): + count += 1 + for r in runners: + if count%r["step"] == 0: + ledData[r["pos"]] = 0 + r["pos"] = (r["pos"]+3)%(hyperion.ledCount*3) + ledData[r["pos"]] = r["lvl"] + + hyperion.setColor(ledData) + time.sleep(sleepTime) diff --git a/effects/random.json b/effects/random.json new file mode 100644 index 00000000..dc1d79ae --- /dev/null +++ b/effects/random.json @@ -0,0 +1,7 @@ +{ + "name" : "Random", + "script" : "random.py", + "args" : + { + } +} diff --git a/effects/random.py b/effects/random.py new file mode 100644 index 00000000..0f5406b1 --- /dev/null +++ b/effects/random.py @@ -0,0 +1,25 @@ +import hyperion +import time +import colorsys +import random + +# Initialize the led data +ledData = bytearray() +for i in range(hyperion.ledCount): + ledData += bytearray((0,0,0)) + +sleepTime = 0.001 + +# Start the write data loop +while not hyperion.abort(): + hyperion.setColor(ledData) + for i in range(hyperion.ledCount): + if random.randrange(10) == 1: + hue = random.random() + sat = 1.0 + val = random.random() + rgb = colorsys.hsv_to_rgb(hue, sat, val) + ledData[i*3 ] = int(255*rgb[0]) + ledData[i*3+1] = int(255*rgb[1]) + ledData[i*3+2] = int(255*rgb[2]) + time.sleep(sleepTime) diff --git a/effects/sparks-color.json b/effects/sparks-color.json new file mode 100644 index 00000000..1c3e8146 --- /dev/null +++ b/effects/sparks-color.json @@ -0,0 +1,7 @@ +{ + "name" : "Sparks color", + "script" : "sparks-color.py", + "args" : + { + } +} diff --git a/effects/sparks-color.py b/effects/sparks-color.py new file mode 100644 index 00000000..34b5acf5 --- /dev/null +++ b/effects/sparks-color.py @@ -0,0 +1,35 @@ +import hyperion +import time +import colorsys +import random + +# Get the parameters +rotationTime = float(hyperion.args.get('rotation-time', 3.0)) +brightness = float(hyperion.args.get('brightness', 1.0)) +saturation = float(hyperion.args.get('saturation', 1.0)) +reverse = bool(hyperion.args.get('reverse', False)) + +# Check parameters +rotationTime = max(0.1, rotationTime) +brightness = max(0.0, min(brightness, 1.0)) +saturation = max(0.0, min(saturation, 1.0)) + +# Initialize the led data +ledData = bytearray() + +sleepTime = 0.05 + +# Start the write data loop +while not hyperion.abort(): + ledData[:] = bytearray(3*hyperion.ledCount) + for i in range(hyperion.ledCount): + if random.random() < 0.005: + hue = random.random() + sat = 1 + val = 1 + rgb = colorsys.hsv_to_rgb(hue, sat, val) + ledData[i*3] = int(255*rgb[0]) + ledData[i*3+1] = int(255*rgb[1]) + ledData[i*3+2] = int(255*rgb[2]) + hyperion.setColor(ledData) + time.sleep(sleepTime) diff --git a/effects/sparks.json b/effects/sparks.json new file mode 100644 index 00000000..d4040309 --- /dev/null +++ b/effects/sparks.json @@ -0,0 +1,7 @@ +{ + "name" : "Sparks", + "script" : "sparks.py", + "args" : + { + } +} diff --git a/effects/sparks.py b/effects/sparks.py new file mode 100644 index 00000000..821719e2 --- /dev/null +++ b/effects/sparks.py @@ -0,0 +1,33 @@ +import hyperion +import time +import colorsys +import random + +# Get the parameters +rotationTime = float(hyperion.args.get('rotation-time', 3.0)) +brightness = float(hyperion.args.get('brightness', 1.0)) +saturation = float(hyperion.args.get('saturation', 1.0)) +reverse = bool(hyperion.args.get('reverse', False)) + +# Check parameters +rotationTime = max(0.1, rotationTime) +brightness = max(0.0, min(brightness, 1.0)) +saturation = max(0.0, min(saturation, 1.0)) + +# Initialize the led data +ledData = bytearray() +for i in range(hyperion.ledCount): + ledData += bytearray((0, 0, 0)) + +sleepTime = 0.05 + +# Start the write data loop +while not hyperion.abort(): + ledData[:] = bytearray(3*hyperion.ledCount) + for i in range(hyperion.ledCount): + if random.random() < 0.005: + ledData[i*3] = 255 + ledData[i*3+1] = 255 + ledData[i*3+2] = 255 + hyperion.setColor(ledData) + time.sleep(sleepTime) From 7dfe8ae8cf64dc892cdc8945ebac0454aacc5118 Mon Sep 17 00:00:00 2001 From: redpanther Date: Wed, 20 Jan 2016 14:45:17 +0100 Subject: [PATCH 2/9] all effects has same lineendings Former-commit-id: c2586f57ce03c20a7a1083a5d62c8ddde7359b84 --- effects/knight-rider.json | 20 ++++++++++---------- effects/loop.json | 14 +++++++------- effects/loop2.json | 14 +++++++------- effects/mood-blobs-blue.json | 24 ++++++++++++------------ effects/mood-blobs-green.json | 24 ++++++++++++------------ effects/mood-blobs-red.json | 24 ++++++++++++------------ effects/rainbow-mood.json | 20 ++++++++++---------- effects/rainbow-swirl-fast.json | 20 ++++++++++---------- effects/rainbow-swirl.json | 20 ++++++++++---------- effects/random.json | 14 +++++++------- effects/snake.json | 20 ++++++++++---------- effects/sparks-color.json | 14 +++++++------- effects/sparks.json | 14 +++++++------- effects/x-mas.json | 16 ++++++++-------- 14 files changed, 129 insertions(+), 129 deletions(-) diff --git a/effects/knight-rider.json b/effects/knight-rider.json index b4644387..9801d491 100644 --- a/effects/knight-rider.json +++ b/effects/knight-rider.json @@ -1,10 +1,10 @@ -{ - "name" : "Knight rider", - "script" : "knight-rider.py", - "args" : - { - "speed" : 1.0, - "fadeFactor" : 0.7, - "color" : [255,0,0] - } -} +{ + "name" : "Knight rider", + "script" : "knight-rider.py", + "args" : + { + "speed" : 1.0, + "fadeFactor" : 0.7, + "color" : [255,0,0] + } +} diff --git a/effects/loop.json b/effects/loop.json index 9415f8b1..c4e58803 100644 --- a/effects/loop.json +++ b/effects/loop.json @@ -1,7 +1,7 @@ -{ - "name" : "Loop", - "script" : "loop.py", - "args" : - { - } -} +{ + "name" : "Loop", + "script" : "loop.py", + "args" : + { + } +} diff --git a/effects/loop2.json b/effects/loop2.json index 77f2c438..ebedbe34 100644 --- a/effects/loop2.json +++ b/effects/loop2.json @@ -1,7 +1,7 @@ -{ - "name" : "Loop2", - "script" : "loop2.py", - "args" : - { - } -} +{ + "name" : "Loop2", + "script" : "loop2.py", + "args" : + { + } +} diff --git a/effects/mood-blobs-blue.json b/effects/mood-blobs-blue.json index 1aa188ab..32280b46 100644 --- a/effects/mood-blobs-blue.json +++ b/effects/mood-blobs-blue.json @@ -1,12 +1,12 @@ -{ - "name" : "Blue mood blobs", - "script" : "mood-blobs.py", - "args" : - { - "rotationTime" : 60.0, - "color" : [0,0,255], - "hueChange" : 60.0, - "blobs" : 5, - "reverse" : false - } -} +{ + "name" : "Blue mood blobs", + "script" : "mood-blobs.py", + "args" : + { + "rotationTime" : 60.0, + "color" : [0,0,255], + "hueChange" : 60.0, + "blobs" : 5, + "reverse" : false + } +} diff --git a/effects/mood-blobs-green.json b/effects/mood-blobs-green.json index c0c104fe..aabd536c 100644 --- a/effects/mood-blobs-green.json +++ b/effects/mood-blobs-green.json @@ -1,12 +1,12 @@ -{ - "name" : "Green mood blobs", - "script" : "mood-blobs.py", - "args" : - { - "rotationTime" : 60.0, - "color" : [0,255,0], - "hueChange" : 60.0, - "blobs" : 5, - "reverse" : false - } -} +{ + "name" : "Green mood blobs", + "script" : "mood-blobs.py", + "args" : + { + "rotationTime" : 60.0, + "color" : [0,255,0], + "hueChange" : 60.0, + "blobs" : 5, + "reverse" : false + } +} diff --git a/effects/mood-blobs-red.json b/effects/mood-blobs-red.json index 3272dded..ac47af53 100644 --- a/effects/mood-blobs-red.json +++ b/effects/mood-blobs-red.json @@ -1,12 +1,12 @@ -{ - "name" : "Red mood blobs", - "script" : "mood-blobs.py", - "args" : - { - "rotationTime" : 60.0, - "color" : [255,0,0], - "hueChange" : 60.0, - "blobs" : 5, - "reverse" : false - } -} +{ + "name" : "Red mood blobs", + "script" : "mood-blobs.py", + "args" : + { + "rotationTime" : 60.0, + "color" : [255,0,0], + "hueChange" : 60.0, + "blobs" : 5, + "reverse" : false + } +} diff --git a/effects/rainbow-mood.json b/effects/rainbow-mood.json index fe754287..c9208b60 100644 --- a/effects/rainbow-mood.json +++ b/effects/rainbow-mood.json @@ -1,10 +1,10 @@ -{ - "name" : "Rainbow mood", - "script" : "rainbow-mood.py", - "args" : - { - "rotation-time" : 60.0, - "brightness" : 1.0, - "reverse" : false - } -} +{ + "name" : "Rainbow mood", + "script" : "rainbow-mood.py", + "args" : + { + "rotation-time" : 60.0, + "brightness" : 1.0, + "reverse" : false + } +} diff --git a/effects/rainbow-swirl-fast.json b/effects/rainbow-swirl-fast.json index 19fec89c..88e8d79d 100644 --- a/effects/rainbow-swirl-fast.json +++ b/effects/rainbow-swirl-fast.json @@ -1,10 +1,10 @@ -{ - "name" : "Rainbow swirl fast", - "script" : "rainbow-swirl.py", - "args" : - { - "rotation-time" : 3.0, - "brightness" : 1.0, - "reverse" : false - } -} +{ + "name" : "Rainbow swirl fast", + "script" : "rainbow-swirl.py", + "args" : + { + "rotation-time" : 3.0, + "brightness" : 1.0, + "reverse" : false + } +} diff --git a/effects/rainbow-swirl.json b/effects/rainbow-swirl.json index 3f7b7243..43a80a8d 100644 --- a/effects/rainbow-swirl.json +++ b/effects/rainbow-swirl.json @@ -1,10 +1,10 @@ -{ - "name" : "Rainbow swirl", - "script" : "rainbow-swirl.py", - "args" : - { - "rotation-time" : 20.0, - "brightness" : 1.0, - "reverse" : false - } -} +{ + "name" : "Rainbow swirl", + "script" : "rainbow-swirl.py", + "args" : + { + "rotation-time" : 20.0, + "brightness" : 1.0, + "reverse" : false + } +} diff --git a/effects/random.json b/effects/random.json index dc1d79ae..3dbc26d4 100644 --- a/effects/random.json +++ b/effects/random.json @@ -1,7 +1,7 @@ -{ - "name" : "Random", - "script" : "random.py", - "args" : - { - } -} +{ + "name" : "Random", + "script" : "random.py", + "args" : + { + } +} diff --git a/effects/snake.json b/effects/snake.json index 2c7ba395..eb914c89 100644 --- a/effects/snake.json +++ b/effects/snake.json @@ -1,10 +1,10 @@ -{ - "name" : "Snake", - "script" : "snake.py", - "args" : - { - "rotation-time" : 10.0, - "color" : [255, 0, 0], - "percentage" : 25 - } -} +{ + "name" : "Snake", + "script" : "snake.py", + "args" : + { + "rotation-time" : 10.0, + "color" : [255, 0, 0], + "percentage" : 25 + } +} diff --git a/effects/sparks-color.json b/effects/sparks-color.json index 1c3e8146..641b7d8d 100644 --- a/effects/sparks-color.json +++ b/effects/sparks-color.json @@ -1,7 +1,7 @@ -{ - "name" : "Sparks color", - "script" : "sparks-color.py", - "args" : - { - } -} +{ + "name" : "Sparks color", + "script" : "sparks-color.py", + "args" : + { + } +} diff --git a/effects/sparks.json b/effects/sparks.json index d4040309..f00c01ae 100644 --- a/effects/sparks.json +++ b/effects/sparks.json @@ -1,7 +1,7 @@ -{ - "name" : "Sparks", - "script" : "sparks.py", - "args" : - { - } -} +{ + "name" : "Sparks", + "script" : "sparks.py", + "args" : + { + } +} diff --git a/effects/x-mas.json b/effects/x-mas.json index 72892a52..6c73b645 100644 --- a/effects/x-mas.json +++ b/effects/x-mas.json @@ -1,8 +1,8 @@ -{ - "name" : "X-Mas", - "script" : "x-mas.py", - "args" : - { - "sleepTime" : 0.75 - } -} +{ + "name" : "X-Mas", + "script" : "x-mas.py", + "args" : + { + "sleepTime" : 0.75 + } +} From de5b2849751537a334ab684d3d22591cc9ed8fd9 Mon Sep 17 00:00:00 2001 From: redpanther Date: Wed, 20 Jan 2016 22:36:21 +0100 Subject: [PATCH 3/9] modify effects - snake has a nice tail - random is not so fast anymore - merge sparks and sparks-color - make more params available in json files Former-commit-id: fc2a4f6f6ce2b44a35a75a9c0dbe36504b790be9 --- effects/random.json | 6 ++++-- effects/random.py | 18 +++++++----------- effects/snake.json | 8 ++++---- effects/snake.py | 2 +- effects/sparks-color.json | 11 +++++++++-- effects/sparks-color.py | 35 ----------------------------------- effects/sparks.json | 7 +++++++ effects/sparks.py | 32 ++++++++++++++++++-------------- 8 files changed, 50 insertions(+), 69 deletions(-) delete mode 100644 effects/sparks-color.py diff --git a/effects/random.json b/effects/random.json index 3dbc26d4..4a85b133 100644 --- a/effects/random.json +++ b/effects/random.json @@ -1,7 +1,9 @@ { - "name" : "Random", + "name" : "Random", "script" : "random.py", - "args" : + "args" : { + "speed" : 1.0, + "saturation" : 1.0 } } diff --git a/effects/random.py b/effects/random.py index 0f5406b1..63b56dca 100644 --- a/effects/random.py +++ b/effects/random.py @@ -1,24 +1,20 @@ -import hyperion -import time -import colorsys -import random +import hyperion, time, colorsys, random + +# get args +sleepTime = float(hyperion.args.get('speed', 1.0)) +saturation = float(hyperion.args.get('saturation', 1.0)) +ledData = bytearray() # Initialize the led data -ledData = bytearray() for i in range(hyperion.ledCount): ledData += bytearray((0,0,0)) -sleepTime = 0.001 - # Start the write data loop while not hyperion.abort(): hyperion.setColor(ledData) for i in range(hyperion.ledCount): if random.randrange(10) == 1: - hue = random.random() - sat = 1.0 - val = random.random() - rgb = colorsys.hsv_to_rgb(hue, sat, val) + rgb = colorsys.hsv_to_rgb(random.random(), saturation, random.random()) ledData[i*3 ] = int(255*rgb[0]) ledData[i*3+1] = int(255*rgb[1]) ledData[i*3+2] = int(255*rgb[2]) diff --git a/effects/snake.json b/effects/snake.json index eb914c89..d5a7674f 100644 --- a/effects/snake.json +++ b/effects/snake.json @@ -1,10 +1,10 @@ { - "name" : "Snake", + "name" : "Snake", "script" : "snake.py", "args" : { - "rotation-time" : 10.0, - "color" : [255, 0, 0], - "percentage" : 25 + "rotation-time" : 12.0, + "color" : [255, 0, 0], + "percentage" : 10 } } diff --git a/effects/snake.py b/effects/snake.py index 2ae5cb37..d8d16561 100644 --- a/effects/snake.py +++ b/effects/snake.py @@ -23,7 +23,7 @@ for i in range(hyperion.ledCount-snakeLeds): ledData += bytearray((0, 0, 0)) for i in range(1,snakeLeds+1): - rgb = colorsys.hsv_to_rgb(hsv[0], hsv[1], hsv[2]/i) + rgb = colorsys.hsv_to_rgb(hsv[0], hsv[1], hsv[2]*(snakeLeds-i)/snakeLeds) ledData += bytearray((int(rgb[0]*255), int(rgb[1]*255), int(rgb[2]*255))) # Calculate the sleep time and rotation increment diff --git a/effects/sparks-color.json b/effects/sparks-color.json index 641b7d8d..e4d3649e 100644 --- a/effects/sparks-color.json +++ b/effects/sparks-color.json @@ -1,7 +1,14 @@ { - "name" : "Sparks color", - "script" : "sparks-color.py", + "name" : "Sparks Color", + "script" : "sparks.py", "args" : { + "rotation-time" : 3.0, + "sleep-time" : 0.05, + "brightness" : 1.0, + "saturation" : 1.0, + "reverse" : false, + "color" : [255,255,255], + "random-color" : true } } diff --git a/effects/sparks-color.py b/effects/sparks-color.py deleted file mode 100644 index 34b5acf5..00000000 --- a/effects/sparks-color.py +++ /dev/null @@ -1,35 +0,0 @@ -import hyperion -import time -import colorsys -import random - -# Get the parameters -rotationTime = float(hyperion.args.get('rotation-time', 3.0)) -brightness = float(hyperion.args.get('brightness', 1.0)) -saturation = float(hyperion.args.get('saturation', 1.0)) -reverse = bool(hyperion.args.get('reverse', False)) - -# Check parameters -rotationTime = max(0.1, rotationTime) -brightness = max(0.0, min(brightness, 1.0)) -saturation = max(0.0, min(saturation, 1.0)) - -# Initialize the led data -ledData = bytearray() - -sleepTime = 0.05 - -# Start the write data loop -while not hyperion.abort(): - ledData[:] = bytearray(3*hyperion.ledCount) - for i in range(hyperion.ledCount): - if random.random() < 0.005: - hue = random.random() - sat = 1 - val = 1 - rgb = colorsys.hsv_to_rgb(hue, sat, val) - ledData[i*3] = int(255*rgb[0]) - ledData[i*3+1] = int(255*rgb[1]) - ledData[i*3+2] = int(255*rgb[2]) - hyperion.setColor(ledData) - time.sleep(sleepTime) diff --git a/effects/sparks.json b/effects/sparks.json index f00c01ae..0860987e 100644 --- a/effects/sparks.json +++ b/effects/sparks.json @@ -3,5 +3,12 @@ "script" : "sparks.py", "args" : { + "rotation-time" : 3.0, + "sleep-time" : 0.05, + "brightness" : 1.0, + "saturation" : 1.0, + "reverse" : false, + "color" : [255,255,255], + "random-color" : false } } diff --git a/effects/sparks.py b/effects/sparks.py index 821719e2..f215ba9a 100644 --- a/effects/sparks.py +++ b/effects/sparks.py @@ -1,33 +1,37 @@ -import hyperion -import time -import colorsys -import random +import hyperion, time, colorsys, random # Get the parameters rotationTime = float(hyperion.args.get('rotation-time', 3.0)) -brightness = float(hyperion.args.get('brightness', 1.0)) -saturation = float(hyperion.args.get('saturation', 1.0)) -reverse = bool(hyperion.args.get('reverse', False)) +sleepTime = float(hyperion.args.get('sleep-time', 0.05)) +brightness = float(hyperion.args.get('brightness', 1.0)) +saturation = float(hyperion.args.get('saturation', 1.0)) +reverse = bool(hyperion.args.get('reverse', False)) +color = list(hyperion.args.get('color', (255,255,255))) +randomColor = bool(hyperion.args.get('random-color', False)) # Check parameters rotationTime = max(0.1, rotationTime) -brightness = max(0.0, min(brightness, 1.0)) -saturation = max(0.0, min(saturation, 1.0)) +brightness = max(0.0, min(brightness, 1.0)) +saturation = max(0.0, min(saturation, 1.0)) # Initialize the led data ledData = bytearray() for i in range(hyperion.ledCount): ledData += bytearray((0, 0, 0)) -sleepTime = 0.05 - # Start the write data loop while not hyperion.abort(): ledData[:] = bytearray(3*hyperion.ledCount) for i in range(hyperion.ledCount): if random.random() < 0.005: - ledData[i*3] = 255 - ledData[i*3+1] = 255 - ledData[i*3+2] = 255 + + if randomColor: + rgb = colorsys.hsv_to_rgb(random.random(), 1, 1) + for n in range(3): + color[n] = int(rgb[n]*255) + + for n in range(3): + ledData[i*3+n] = color[n] + hyperion.setColor(ledData) time.sleep(sleepTime) From 2555c5071053c5f5112893d7bc11a525e234c0f3 Mon Sep 17 00:00:00 2001 From: redpanther Date: Sat, 23 Jan 2016 13:09:23 +0100 Subject: [PATCH 4/9] add shutdown effect: system shutdown is disabled by default. enable it in json (set false to true) the shutdown is abortable. simply select another effect before shutdown time reached this effect is made for linux and did not workl on windows without modifications Former-commit-id: 32f92246fbc87de576e4b1059dd319646917ec74 --- effects/shutdown.json | 11 ++++++++++ effects/shutdown.py | 51 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 effects/shutdown.json create mode 100644 effects/shutdown.py diff --git a/effects/shutdown.json b/effects/shutdown.json new file mode 100644 index 00000000..7e09a13b --- /dev/null +++ b/effects/shutdown.json @@ -0,0 +1,11 @@ +{ + "name" : "System Shutdown", + "script" : "shutdown.py", + "args" : + { + "speed" : 1.2, + "alarm-color" : [255,0,0], + "post-color" : [255,174,11], + "shutdown-enabled" : false + } +} diff --git a/effects/shutdown.py b/effects/shutdown.py new file mode 100644 index 00000000..469443d0 --- /dev/null +++ b/effects/shutdown.py @@ -0,0 +1,51 @@ +import hyperion, time, colorsys, random, subprocess + +def setPixel(x,y,rgb): + global imageData, width + offset = y*width*3 + x*3 + if offset+2 < len(imageData): + imageData[offset] = rgb[0] + imageData[offset+1] = rgb[1] + imageData[offset+2] = rgb[2] + +# Initialize the led data and args +sleepTime = float(hyperion.args.get('speed', 1.0))*0.5 +alarmColor = hyperion.args.get('alarm-color', (255,0,0)) +postColor = hyperion.args.get('post-color', (255,174,11)) +off = bool(hyperion.args.get('shutdown-enabled', False)) +width = 12 +height = 10 + +imageData = bytearray(height * width * (0,0,0)) +imageDataBlack = bytearray(height * width * (0,0,0)) +imageDataRed = bytearray(height * width * alarmColor) + +# Start the write data loop +for i in range(6): + if hyperion.abort(): + off = False + break + if i % 2: + hyperion.setImage(width, height, imageDataRed) + else: + hyperion.setImage(width, height, imageDataBlack) + time.sleep(sleepTime) + +for y in range(height,0,-1): + if hyperion.abort(): + off = False + break + for x in range(width): + setPixel(x, y-1, alarmColor) + hyperion.setImage(width, height, imageData) + time.sleep(sleepTime) +time.sleep(1) + +for y in range(height): + for x in range(width): + setPixel(x, y, postColor) +hyperion.setImage(width, height, imageData) +time.sleep(2) + +if off and not hyperion.abort(): + subprocess.call("halt") From e7c7e05f88e18ade798a7278c01fee57ef5b7311 Mon Sep 17 00:00:00 2001 From: redpanther Date: Sun, 24 Jan 2016 08:10:36 +0100 Subject: [PATCH 5/9] add fading effect like in a cinema. sped start and end color are selectable in json file rename loop effects to more meaningfull names Former-commit-id: bed033e19d7cb38b0d5f11313a9f927ac8121194 --- effects/cinema-fade-in.json | 10 ++++++++ effects/cinema-fade-off.json | 10 ++++++++ effects/fade.py | 34 +++++++++++++++++++++++++++ effects/loop.json | 7 ------ effects/loop2.json | 7 ------ effects/loop2.py | 33 -------------------------- effects/running_dots.json | 10 ++++++++ effects/running_dots.py | 43 ++++++++++++++++++++++++++++++++++ effects/traces.json | 8 +++++++ effects/{loop.py => traces.py} | 8 +++---- 10 files changed, 119 insertions(+), 51 deletions(-) create mode 100644 effects/cinema-fade-in.json create mode 100644 effects/cinema-fade-off.json create mode 100644 effects/fade.py delete mode 100644 effects/loop.json delete mode 100644 effects/loop2.json delete mode 100644 effects/loop2.py create mode 100644 effects/running_dots.json create mode 100644 effects/running_dots.py create mode 100644 effects/traces.json rename effects/{loop.py => traces.py} (76%) diff --git a/effects/cinema-fade-in.json b/effects/cinema-fade-in.json new file mode 100644 index 00000000..2730c568 --- /dev/null +++ b/effects/cinema-fade-in.json @@ -0,0 +1,10 @@ +{ + "name" : "Cinema brighten lights", + "script" : "fade.py", + "args" : + { + "fade-time" : 5.0, + "color-start" : [ 136, 97, 7 ], + "color-end" : [ 238, 173, 47 ] + } +} diff --git a/effects/cinema-fade-off.json b/effects/cinema-fade-off.json new file mode 100644 index 00000000..7d7c20f8 --- /dev/null +++ b/effects/cinema-fade-off.json @@ -0,0 +1,10 @@ +{ + "name" : "Cinema dim lights", + "script" : "fade.py", + "args" : + { + "fade-time" : 5.0, + "color-start" : [ 238, 173, 47 ], + "color-end" : [ 136, 97, 7 ] + } +} diff --git a/effects/fade.py b/effects/fade.py new file mode 100644 index 00000000..950605d1 --- /dev/null +++ b/effects/fade.py @@ -0,0 +1,34 @@ +import hyperion, time + +def setColor(rgb): + hyperion.setColor( bytearray( hyperion.ledCount * rgb)) + +# Get the parameters +fadeTime = float(hyperion.args.get('fade-time', 5.0)) +colorStart = hyperion.args.get('color-start', (255,174,11)) +colorEnd = hyperion.args.get('color-end', (100,100,100)) + +color_step = ( + (colorEnd[0] - colorStart[0]) / 256.0, + (colorEnd[1] - colorStart[1]) / 256.0, + (colorEnd[2] - colorStart[2]) / 256.0 +) + +# fade color +for step in range(256): + if hyperion.abort(): + break + + setColor( ( + int( min(max(0, colorStart[0] + color_step[0]*step), 255) ), + int( min(max(0, colorStart[1] + color_step[1]*step), 255) ), + int( min(max(0, colorStart[2] + color_step[2]*step), 255) ) + ) ) + + time.sleep( fadeTime / 256 ) + +# maintain color until effect end +setColor(colorEnd) +while not hyperion.abort(): + time.sleep(1) + diff --git a/effects/loop.json b/effects/loop.json deleted file mode 100644 index c4e58803..00000000 --- a/effects/loop.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name" : "Loop", - "script" : "loop.py", - "args" : - { - } -} diff --git a/effects/loop2.json b/effects/loop2.json deleted file mode 100644 index ebedbe34..00000000 --- a/effects/loop2.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "name" : "Loop2", - "script" : "loop2.py", - "args" : - { - } -} diff --git a/effects/loop2.py b/effects/loop2.py deleted file mode 100644 index 3498ac4e..00000000 --- a/effects/loop2.py +++ /dev/null @@ -1,33 +0,0 @@ -import hyperion -import time -import colorsys -import random - -# Initialize the led data -ledData = bytearray() -for i in range(hyperion.ledCount): - ledData += bytearray((0,0,0)) - -sleepTime = 0.005 - -runners = [ -{ "pos":0, "step":4 , "lvl":255}, -{ "pos":1, "step":5 , "lvl":255}, -{ "pos":2, "step":6 , "lvl":255}, -{ "pos":0, "step":7 , "lvl":255}, -{ "pos":1, "step":8 , "lvl":255}, -{ "pos":2, "step":9, "lvl":255}, -] - -# Start the write data loop -count = 0 -while not hyperion.abort(): - count += 1 - for r in runners: - if count%r["step"] == 0: - ledData[r["pos"]] = 0 - r["pos"] = (r["pos"]+3)%(hyperion.ledCount*3) - ledData[r["pos"]] = r["lvl"] - - hyperion.setColor(ledData) - time.sleep(sleepTime) diff --git a/effects/running_dots.json b/effects/running_dots.json new file mode 100644 index 00000000..8accd451 --- /dev/null +++ b/effects/running_dots.json @@ -0,0 +1,10 @@ +{ + "name" : "Running dots", + "script" : "running_dots.py", + "args" : + { + "speed" : 1.5, + "whiteLevel" : 100, + "colorLevel" : 230 + } +} diff --git a/effects/running_dots.py b/effects/running_dots.py new file mode 100644 index 00000000..16d8d039 --- /dev/null +++ b/effects/running_dots.py @@ -0,0 +1,43 @@ +import hyperion, time, colorsys, random + +# get options from args +sleepTime = float(hyperion.args.get('speed', 1.5)) * 0.005 +whiteLevel = int(hyperion.args.get('whiteLevel', 0)) +lvl = int(hyperion.args.get('colorLevel', 220)) + +# check value +whiteLevel = min( whiteLevel, 254 ) +lvl = min( lvl, 255 ) + +if whiteLevel >= lvl: + lvl = 255 + +# Initialize the led data +ledData = bytearray() +for i in range(hyperion.ledCount): + ledData += bytearray((0,0,0)) + +runners = [ + { "pos":0, "step": 4, "lvl":lvl}, + { "pos":1, "step": 5, "lvl":lvl}, + { "pos":2, "step": 6, "lvl":lvl}, + { "pos":0, "step": 7, "lvl":lvl}, + { "pos":1, "step": 8, "lvl":lvl}, + { "pos":2, "step": 9, "lvl":lvl}, + #{ "pos":0, "step":10, "lvl":lvl}, + #{ "pos":1, "step":11, "lvl":lvl}, + #{ "pos":2, "step":12, "lvl":lvl}, +] + +# Start the write data loop +counter = 0 +while not hyperion.abort(): + counter += 1 + for r in runners: + if counter % r["step"] == 0: + ledData[r["pos"]] = whiteLevel + r["pos"] = (r["pos"]+3) % (hyperion.ledCount*3) + ledData[r["pos"]] = r["lvl"] + + hyperion.setColor(ledData) + time.sleep(sleepTime) diff --git a/effects/traces.json b/effects/traces.json new file mode 100644 index 00000000..a2bfdabb --- /dev/null +++ b/effects/traces.json @@ -0,0 +1,8 @@ +{ + "name" : "Color traces", + "script" : "traces.py", + "args" : + { + "speed" : 1.0 + } +} diff --git a/effects/loop.py b/effects/traces.py similarity index 76% rename from effects/loop.py rename to effects/traces.py index 93011e97..7f6a8dfe 100644 --- a/effects/loop.py +++ b/effects/traces.py @@ -8,15 +8,15 @@ ledData = bytearray() for i in range(hyperion.ledCount): ledData += bytearray((0,0,0)) -sleepTime = 0.002 +sleepTime = float(hyperion.args.get('speed', 1.0)) * 0.004 runners = [ { "i":0, "pos":0, "c":0, "step":9 , "lvl":255}, { "i":1, "pos":0, "c":0, "step":8 , "lvl":255}, { "i":2, "pos":0, "c":0, "step":7 , "lvl":255}, -{ "i":0, "pos":0, "c":0, "step":6 , "lvl":0}, -{ "i":1, "pos":0, "c":0, "step":5 , "lvl":0}, -{ "i":2, "pos":0, "c":0, "step":4, "lvl":0}, +{ "i":0, "pos":0, "c":0, "step":6 , "lvl":100}, +{ "i":1, "pos":0, "c":0, "step":5 , "lvl":100}, +{ "i":2, "pos":0, "c":0, "step":4, "lvl":100}, ] # Start the write data loop From 8732ffacf4a03690c27c142317b394aeb602864b Mon Sep 17 00:00:00 2001 From: redpanther Date: Thu, 28 Jan 2016 05:50:32 +0100 Subject: [PATCH 6/9] simplify code of effect fade.py Former-commit-id: 3c7c633e764d14c9e11c6e145289894954695c65 --- effects/fade.py | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/effects/fade.py b/effects/fade.py index 950605d1..eb233a38 100644 --- a/effects/fade.py +++ b/effects/fade.py @@ -1,8 +1,5 @@ import hyperion, time -def setColor(rgb): - hyperion.setColor( bytearray( hyperion.ledCount * rgb)) - # Get the parameters fadeTime = float(hyperion.args.get('fade-time', 5.0)) colorStart = hyperion.args.get('color-start', (255,174,11)) @@ -15,20 +12,16 @@ color_step = ( ) # fade color +calcChannel = lambda i: min(max(int(colorStart[i] + color_step[i]*step),0),255) for step in range(256): if hyperion.abort(): break - setColor( ( - int( min(max(0, colorStart[0] + color_step[0]*step), 255) ), - int( min(max(0, colorStart[1] + color_step[1]*step), 255) ), - int( min(max(0, colorStart[2] + color_step[2]*step), 255) ) - ) ) - + hyperion.setColor( calcChannel(0),calcChannel(1),calcChannel(2) ) time.sleep( fadeTime / 256 ) # maintain color until effect end -setColor(colorEnd) +hyperion.setColor(colorEnd[0],colorEnd[1],colorEnd[2]) while not hyperion.abort(): time.sleep(1) From e5b802c01d928aeda2eb19056723faa4feeeb0f9 Mon Sep 17 00:00:00 2001 From: redpanther Date: Thu, 28 Jan 2016 06:12:28 +0100 Subject: [PATCH 7/9] simplify effects Former-commit-id: bbb8dc4c3852d0651eb2f4e9999e426db4a905d0 --- effects/shutdown.py | 8 +++----- effects/strobe.py | 12 +++--------- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/effects/shutdown.py b/effects/shutdown.py index 469443d0..214af60e 100644 --- a/effects/shutdown.py +++ b/effects/shutdown.py @@ -1,4 +1,4 @@ -import hyperion, time, colorsys, random, subprocess +import hyperion, time, subprocess def setPixel(x,y,rgb): global imageData, width @@ -17,8 +17,6 @@ width = 12 height = 10 imageData = bytearray(height * width * (0,0,0)) -imageDataBlack = bytearray(height * width * (0,0,0)) -imageDataRed = bytearray(height * width * alarmColor) # Start the write data loop for i in range(6): @@ -26,9 +24,9 @@ for i in range(6): off = False break if i % 2: - hyperion.setImage(width, height, imageDataRed) + hyperion.setColor(alarmColor[0], alarmColor[1], alarmColor[2]) else: - hyperion.setImage(width, height, imageDataBlack) + hyperion.setColor(0, 0, 0) time.sleep(sleepTime) for y in range(height,0,-1): diff --git a/effects/strobe.py b/effects/strobe.py index 007e6133..39a3a558 100644 --- a/effects/strobe.py +++ b/effects/strobe.py @@ -1,6 +1,4 @@ -import hyperion -import time -import colorsys +import hyperion, time # Get the rotation time color = hyperion.args.get('color', (255,255,255)) @@ -12,13 +10,9 @@ frequency = min(100.0, frequency) # Compute the strobe interval sleepTime = 1.0 / frequency -# Initialize the led data -blackLedsData = bytearray(hyperion.ledCount * ( 0, 0, 0)) -whiteLedsData = bytearray(hyperion.ledCount * color) - # Start the write data loop while not hyperion.abort(): - hyperion.setColor(blackLedsData) + hyperion.setColor(0, 0, 0) time.sleep(sleepTime) - hyperion.setColor(whiteLedsData) + hyperion.setColor(color[0], color[1], color[2]) time.sleep(sleepTime) From 11af47d799a80bb31070f021c47b1d76b207c0c9 Mon Sep 17 00:00:00 2001 From: redpanther Date: Wed, 24 Feb 2016 23:30:50 +0100 Subject: [PATCH 8/9] make it compile on raspi Former-commit-id: 378b2ed1f605d060feb955819fb632424f21a218 --- test/dispmanx2png/dispmanx2png.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/dispmanx2png/dispmanx2png.cpp b/test/dispmanx2png/dispmanx2png.cpp index 1004b8ed..77dcb6b7 100644 --- a/test/dispmanx2png/dispmanx2png.cpp +++ b/test/dispmanx2png/dispmanx2png.cpp @@ -10,7 +10,7 @@ #include // Dispmanx grabber includes -#include +#include using namespace vlofgren; From b63cdc1bcfc9d719061b104455fa8d377f90d919 Mon Sep 17 00:00:00 2001 From: redpanther Date: Mon, 29 Feb 2016 04:29:55 +0100 Subject: [PATCH 9/9] Revert "make it compile on raspi" This reverts commit 11af47d799a80bb31070f021c47b1d76b207c0c9 [formerly 378b2ed1f605d060feb955819fb632424f21a218]. Former-commit-id: 5343c8139825860e74243ecbbb67d9aae6697d63 --- test/dispmanx2png/dispmanx2png.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/dispmanx2png/dispmanx2png.cpp b/test/dispmanx2png/dispmanx2png.cpp index 77dcb6b7..1004b8ed 100644 --- a/test/dispmanx2png/dispmanx2png.cpp +++ b/test/dispmanx2png/dispmanx2png.cpp @@ -10,7 +10,7 @@ #include // Dispmanx grabber includes -#include +#include using namespace vlofgren;