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..eb233a38 --- /dev/null +++ b/effects/fade.py @@ -0,0 +1,27 @@ +import hyperion, time + +# 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 +calcChannel = lambda i: min(max(int(colorStart[i] + color_step[i]*step),0),255) +for step in range(256): + if hyperion.abort(): + break + + hyperion.setColor( calcChannel(0),calcChannel(1),calcChannel(2) ) + time.sleep( fadeTime / 256 ) + +# maintain color until effect end +hyperion.setColor(colorEnd[0],colorEnd[1],colorEnd[2]) +while not hyperion.abort(): + time.sleep(1) + 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/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 new file mode 100644 index 00000000..4a85b133 --- /dev/null +++ b/effects/random.json @@ -0,0 +1,9 @@ +{ + "name" : "Random", + "script" : "random.py", + "args" : + { + "speed" : 1.0, + "saturation" : 1.0 + } +} diff --git a/effects/random.py b/effects/random.py new file mode 100644 index 00000000..63b56dca --- /dev/null +++ b/effects/random.py @@ -0,0 +1,21 @@ +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 +for i in range(hyperion.ledCount): + ledData += bytearray((0,0,0)) + +# Start the write data loop +while not hyperion.abort(): + hyperion.setColor(ledData) + for i in range(hyperion.ledCount): + if random.randrange(10) == 1: + 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]) + 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/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..214af60e --- /dev/null +++ b/effects/shutdown.py @@ -0,0 +1,49 @@ +import hyperion, time, 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)) + +# Start the write data loop +for i in range(6): + if hyperion.abort(): + off = False + break + if i % 2: + hyperion.setColor(alarmColor[0], alarmColor[1], alarmColor[2]) + else: + hyperion.setColor(0, 0, 0) + 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") diff --git a/effects/snake.json b/effects/snake.json index 2c7ba395..d5a7674f 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" : 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 new file mode 100644 index 00000000..e4d3649e --- /dev/null +++ b/effects/sparks-color.json @@ -0,0 +1,14 @@ +{ + "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.json b/effects/sparks.json new file mode 100644 index 00000000..0860987e --- /dev/null +++ b/effects/sparks.json @@ -0,0 +1,14 @@ +{ + "name" : "Sparks", + "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 new file mode 100644 index 00000000..f215ba9a --- /dev/null +++ b/effects/sparks.py @@ -0,0 +1,37 @@ +import hyperion, time, colorsys, random + +# Get the parameters +rotationTime = float(hyperion.args.get('rotation-time', 3.0)) +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)) + +# Initialize the led data +ledData = bytearray() +for i in range(hyperion.ledCount): + ledData += bytearray((0, 0, 0)) + +# 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: + + 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) 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) 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/traces.py b/effects/traces.py new file mode 100644 index 00000000..7f6a8dfe --- /dev/null +++ b/effects/traces.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 = 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":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 +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/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 + } +}