From 9872d8f02bebc739e110e8938418231430488892 Mon Sep 17 00:00:00 2001 From: johan Date: Sun, 8 Dec 2013 16:23:01 +0100 Subject: [PATCH] Ensure types in effects to avoid integer calculations were floats were needed Former-commit-id: 84d8b281a544478bf14e88284cb600fdbb11f65c --- effects/knight-rider.py | 4 ++-- effects/mood-blobs.py | 10 ++++------ effects/rainbow-mood.py | 8 ++++---- effects/rainbow-swirl.py | 10 +++++----- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/effects/knight-rider.py b/effects/knight-rider.py index 1245336c..d2ff3ecc 100644 --- a/effects/knight-rider.py +++ b/effects/knight-rider.py @@ -3,8 +3,8 @@ import time import colorsys # Get the rotation time -speed = hyperion.args.get('speed', 1.0) -fadeFactor = hyperion.args.get('fadeFactor', 0.7) +speed = float(hyperion.args.get('speed', 1.0)) +fadeFactor = float(hyperion.args.get('fadeFactor', 0.7)) # Check parameters speed = max(0.0001, speed) diff --git a/effects/mood-blobs.py b/effects/mood-blobs.py index c9da30fe..c0ce3d15 100644 --- a/effects/mood-blobs.py +++ b/effects/mood-blobs.py @@ -4,13 +4,11 @@ import colorsys import math # Get the parameters -rotationTime = hyperion.args.get('rotationTime', 20.0) +rotationTime = float(hyperion.args.get('rotationTime', 20.0)) color = hyperion.args.get('color', (0,0,255)) -hueChange = hyperion.args.get('hueChange', 60.0) / 360.0 -blobs = hyperion.args.get('blobs', 5) -reverse = hyperion.args.get('reverse', False) -print color -print hyperion.args +hueChange = float(hyperion.args.get('hueChange', 60.0)) / 360.0 +blobs = int(hyperion.args.get('blobs', 5)) +reverse = bool(hyperion.args.get('reverse', False)) # Check parameters rotationTime = max(0.1, rotationTime) diff --git a/effects/rainbow-mood.py b/effects/rainbow-mood.py index 4f6c0255..2ce08edd 100644 --- a/effects/rainbow-mood.py +++ b/effects/rainbow-mood.py @@ -3,10 +3,10 @@ import time import colorsys # Get the parameters -rotationTime = hyperion.args.get('rotation-time', 30.0) -brightness = hyperion.args.get('brightness', 1.0) -saturation = hyperion.args.get('saturation', 1.0) -reverse = hyperion.args.get('reverse', False) +rotationTime = float(hyperion.args.get('rotation-time', 30.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) diff --git a/effects/rainbow-swirl.py b/effects/rainbow-swirl.py index f8ac2522..ec623aa1 100644 --- a/effects/rainbow-swirl.py +++ b/effects/rainbow-swirl.py @@ -3,10 +3,10 @@ import time import colorsys # Get the parameters -rotationTime = hyperion.args.get('rotation-time', 3.0) -brightness = hyperion.args.get('brightness', 1.0) -saturation = hyperion.args.get('saturation', 1.0) -reverse = hyperion.args.get('reverse', False) +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) @@ -31,7 +31,7 @@ increment %= hyperion.ledCount # Switch direction if needed if reverse: increment = -increment - + # Start the write data loop while not hyperion.abort(): hyperion.setColor(ledData)