From 3ba86a125321f01c9650c5a449be55a19de025cc Mon Sep 17 00:00:00 2001 From: Peter Fern Date: Mon, 9 May 2016 19:19:52 +1000 Subject: [PATCH] Allow random mood blobs color, set mood-blobs-full to random Small change to allow a random start hue for mood blobs - adds a bit of spice instead of starting at the same color every time. Former-commit-id: 2b5a0250b95ac5632661d3b8fce3c1567f5daaa3 --- effects/mood-blobs-full.json | 2 +- effects/mood-blobs.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/effects/mood-blobs-full.json b/effects/mood-blobs-full.json index 8b230010..05e4ff1e 100644 --- a/effects/mood-blobs-full.json +++ b/effects/mood-blobs-full.json @@ -4,7 +4,7 @@ "args" : { "rotationTime" : 60.0, - "color" : [0,0,255], + "colorRandom" : true, "hueChange" : 30.0, "blobs" : 5, "reverse" : false, diff --git a/effects/mood-blobs.py b/effects/mood-blobs.py index b638f3d3..45efff85 100644 --- a/effects/mood-blobs.py +++ b/effects/mood-blobs.py @@ -2,10 +2,12 @@ import hyperion import time import colorsys import math +from random import random # Get the parameters rotationTime = float(hyperion.args.get('rotationTime', 20.0)) color = hyperion.args.get('color', (0,0,255)) +colorRandom = bool(hyperion.args.get('colorRandom', False)) hueChange = float(hyperion.args.get('hueChange', 60.0)) blobs = int(hyperion.args.get('blobs', 5)) reverse = bool(hyperion.args.get('reverse', False)) @@ -34,6 +36,9 @@ baseColorChangeRate = max(0, baseColorChangeRate) # > 0 # Calculate the color data baseHsv = colorsys.rgb_to_hsv(color[0]/255.0, color[1]/255.0, color[2]/255.0) +if colorRandom: + baseHsv = (random(), baseHsv[1], baseHsv[2]) + colorData = bytearray() for i in range(hyperion.ledCount): hue = (baseHsv[0] + hueChange * math.sin(2*math.pi * i / hyperion.ledCount)) % 1.0