mirror of
https://github.com/hyperion-project/hyperion.ng.git
synced 2025-03-01 10:33:28 +00:00
Add CodeQL for GitHub code scanning (#1548)
* Create codeql.yml * Addressing codeql findings
This commit is contained in:
@@ -1,54 +1,54 @@
|
||||
import hyperion, time
|
||||
|
||||
# Get the parameters
|
||||
speed = float(hyperion.args.get('speed', 1.0))
|
||||
fadeFactor = float(hyperion.args.get('fadeFactor', 0.7))
|
||||
color = hyperion.args.get('color', (255,0,0))
|
||||
|
||||
# Check parameters
|
||||
speed = max(0.0001, speed)
|
||||
fadeFactor = max(0.0, min(fadeFactor, 1.0))
|
||||
|
||||
# Initialize the led data
|
||||
width = 25
|
||||
imageData = bytearray(width * (0,0,0))
|
||||
imageData[0] = color[0]
|
||||
imageData[1] = color[1]
|
||||
imageData[2] = color[2]
|
||||
|
||||
# Calculate the sleep time and rotation increment
|
||||
increment = 1
|
||||
sleepTime = 1.0 / (speed * width)
|
||||
while sleepTime < 0.05:
|
||||
increment *= 2
|
||||
sleepTime *= 2
|
||||
|
||||
# Start the write data loop
|
||||
position = 0
|
||||
direction = 1
|
||||
while not hyperion.abort():
|
||||
hyperion.setImage(width, 1, imageData)
|
||||
|
||||
# Move data into next state
|
||||
for i in range(increment):
|
||||
position += direction
|
||||
if position == -1:
|
||||
position = 1
|
||||
direction = 1
|
||||
elif position == width:
|
||||
position = width-2
|
||||
direction = -1
|
||||
|
||||
# Fade the old data
|
||||
for j in range(width):
|
||||
imageData[3*j] = int(fadeFactor * imageData[3*j])
|
||||
imageData[3*j+1] = int(fadeFactor * imageData[3*j+1])
|
||||
imageData[3*j+2] = int(fadeFactor * imageData[3*j+2])
|
||||
|
||||
# Insert new data
|
||||
imageData[3*position] = color[0]
|
||||
imageData[3*position+1] = color[1]
|
||||
imageData[3*position+2] = color[2]
|
||||
|
||||
# Sleep for a while
|
||||
time.sleep(sleepTime)
|
||||
import hyperion, time
|
||||
|
||||
# Get the parameters
|
||||
speed = float(hyperion.args.get('speed', 1.0))
|
||||
fadeFactor = float(hyperion.args.get('fadeFactor', 0.7))
|
||||
color = hyperion.args.get('color', (255,0,0))
|
||||
|
||||
# Check parameters
|
||||
speed = max(0.0001, speed)
|
||||
fadeFactor = max(0.0, min(fadeFactor, 1.0))
|
||||
|
||||
# Initialize the led data
|
||||
width = 25
|
||||
imageData = bytearray(width * (0,0,0))
|
||||
imageData[0] = color[0]
|
||||
imageData[1] = color[1]
|
||||
imageData[2] = color[2]
|
||||
|
||||
# Calculate the sleep time and rotation increment
|
||||
increment = 1
|
||||
sleepTime = 1.0 / (speed * width)
|
||||
while sleepTime < 0.05:
|
||||
increment *= 2
|
||||
sleepTime *= 2
|
||||
|
||||
# Start the write data loop
|
||||
position = 0
|
||||
direction = 1
|
||||
while not hyperion.abort():
|
||||
hyperion.setImage(width, 1, imageData)
|
||||
|
||||
# Move data into next state
|
||||
for unused in range(increment):
|
||||
position += direction
|
||||
if position == -1:
|
||||
position = 1
|
||||
direction = 1
|
||||
elif position == width:
|
||||
position = width-2
|
||||
direction = -1
|
||||
|
||||
# Fade the old data
|
||||
for j in range(width):
|
||||
imageData[3*j] = int(fadeFactor * imageData[3*j])
|
||||
imageData[3*j+1] = int(fadeFactor * imageData[3*j+1])
|
||||
imageData[3*j+2] = int(fadeFactor * imageData[3*j+2])
|
||||
|
||||
# Insert new data
|
||||
imageData[3*position] = color[0]
|
||||
imageData[3*position+1] = color[1]
|
||||
imageData[3*position+2] = color[2]
|
||||
|
||||
# Sleep for a while
|
||||
time.sleep(sleepTime)
|
||||
|
@@ -1,23 +1,23 @@
|
||||
import hyperion, time, colorsys
|
||||
|
||||
# Get the parameters
|
||||
rotationTime = float(hyperion.args.get('rotation-time', 30.0))
|
||||
brightness = float(hyperion.args.get('brightness', 100))/100.0
|
||||
saturation = float(hyperion.args.get('saturation', 100))/100.0
|
||||
reverse = bool(hyperion.args.get('reverse', False))
|
||||
|
||||
# Calculate the sleep time and hue increment
|
||||
sleepTime = 0.1
|
||||
hueIncrement = sleepTime / rotationTime
|
||||
|
||||
# Switch direction if needed
|
||||
if reverse:
|
||||
increment = -increment
|
||||
|
||||
# Start the write data loop
|
||||
hue = 0.0
|
||||
while not hyperion.abort():
|
||||
rgb = colorsys.hsv_to_rgb(hue, saturation, brightness)
|
||||
hyperion.setColor(int(255*rgb[0]), int(255*rgb[1]), int(255*rgb[2]))
|
||||
hue = (hue + hueIncrement) % 1.0
|
||||
time.sleep(sleepTime)
|
||||
import hyperion, time, colorsys
|
||||
|
||||
# Get the parameters
|
||||
rotationTime = float(hyperion.args.get('rotation-time', 30.0))
|
||||
brightness = float(hyperion.args.get('brightness', 100))/100.0
|
||||
saturation = float(hyperion.args.get('saturation', 100))/100.0
|
||||
reverse = bool(hyperion.args.get('reverse', False))
|
||||
|
||||
# Calculate the sleep time and hue increment
|
||||
sleepTime = 0.1
|
||||
hueIncrement = sleepTime / rotationTime
|
||||
|
||||
# Switch direction if needed
|
||||
if reverse:
|
||||
hueIncrement = -hueIncrement
|
||||
|
||||
# Start the write data loop
|
||||
hue = 0.0
|
||||
while not hyperion.abort():
|
||||
rgb = colorsys.hsv_to_rgb(hue, saturation, brightness)
|
||||
hyperion.setColor(int(255*rgb[0]), int(255*rgb[1]), int(255*rgb[2]))
|
||||
hue = (hue + hueIncrement) % 1.0
|
||||
time.sleep(sleepTime)
|
||||
|
@@ -1,43 +1,43 @@
|
||||
import hyperion, time
|
||||
|
||||
# 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)
|
||||
import hyperion, time
|
||||
|
||||
# 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 unused 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)
|
||||
|
@@ -42,7 +42,7 @@ def buildGradient(cc, closeCircle = True):
|
||||
pos = 0
|
||||
if len(cc[0]) == 4:
|
||||
withAlpha = True
|
||||
|
||||
|
||||
for c in cc:
|
||||
if withAlpha:
|
||||
alpha = int(c[3]*255)
|
||||
@@ -50,7 +50,7 @@ def buildGradient(cc, closeCircle = True):
|
||||
alpha = 255
|
||||
pos += posfac
|
||||
ba += bytearray([pos,c[0],c[1],c[2],alpha])
|
||||
|
||||
|
||||
if closeCircle:
|
||||
# last color as first color
|
||||
lC = cc[-1]
|
||||
@@ -61,6 +61,7 @@ def buildGradient(cc, closeCircle = True):
|
||||
ba += bytearray([0,lC[0],lC[1],lC[2],alpha])
|
||||
|
||||
return ba
|
||||
return bytearray()
|
||||
|
||||
def rotateAngle( increment = 1):
|
||||
global angle
|
||||
|
@@ -1,98 +1,98 @@
|
||||
import hyperion
|
||||
import time
|
||||
import colorsys
|
||||
import random
|
||||
|
||||
min_len = int(hyperion.args.get('min_len', 3))
|
||||
max_len = int(hyperion.args.get('max_len', 3))
|
||||
#iHeight = int(hyperion.args.get('iHeight', 8))
|
||||
trails = int(hyperion.args.get('int', 8))
|
||||
sleepTime = float(hyperion.args.get('speed', 1)) / 1000.0
|
||||
color = list(hyperion.args.get('color', (255,255,255)))
|
||||
randomise = bool(hyperion.args.get('random', False))
|
||||
iWidth = hyperion.imageWidth()
|
||||
iHeight = hyperion.imageHeight()
|
||||
|
||||
class trail:
|
||||
def __init__(self):
|
||||
return
|
||||
|
||||
def start(self, x, y, step, color, _len, _h):
|
||||
self.pos = 0.0
|
||||
self.step = step
|
||||
self.h = _h
|
||||
self.x = x
|
||||
self.data = []
|
||||
brigtness = color[2]
|
||||
step_brigtness = color[2] / _len
|
||||
for i in range(0, _len):
|
||||
rgb = colorsys.hsv_to_rgb(color[0], color[1], brigtness)
|
||||
self.data.insert(0, (int(255*rgb[0]), int(255*rgb[1]), int(255*rgb[2])))
|
||||
brigtness -= step_brigtness
|
||||
|
||||
self.data.extend([(0,0,0)]*(_h-y))
|
||||
if len(self.data) < _h:
|
||||
for i in range (_h-len(self.data)):
|
||||
self.data.insert(0, (0,0,0))
|
||||
|
||||
def getdata(self):
|
||||
self.pos += self.step
|
||||
if self.pos > 1.0:
|
||||
self.pos = 0.0
|
||||
self.data.pop()
|
||||
self.data.insert(0, (0,0,0))
|
||||
return self.x, self.data[-self.h:], all(x == self.data[0] for x in self.data)
|
||||
|
||||
tr = []
|
||||
|
||||
for i in range(trails):
|
||||
r = {'exec': trail()}
|
||||
|
||||
if randomise:
|
||||
col = (random.uniform(0.0, 1.0),1,1)
|
||||
else:
|
||||
col = colorsys.rgb_to_hsv(color[0]/255.0, color[1]/255.0, color[2]/255.0)
|
||||
|
||||
r['exec'].start(
|
||||
random.randint(0, iWidth),
|
||||
random.randint(0, iHeight),
|
||||
random.uniform(0.2, 0.8),
|
||||
col,
|
||||
random.randint(min_len, max_len),
|
||||
iHeight
|
||||
)
|
||||
tr.append(r)
|
||||
|
||||
# Start the write data loop
|
||||
while not hyperion.abort():
|
||||
ledData = bytearray()
|
||||
|
||||
for r in tr:
|
||||
r['x'], r['data'], c = r['exec'].getdata()
|
||||
if c:
|
||||
if randomise:
|
||||
col = (random.uniform(0.0, 1.0),1,1)
|
||||
else:
|
||||
col = colorsys.rgb_to_hsv(color[0]/255.0, color[1]/255.0, color[2]/255.0)
|
||||
|
||||
r['exec'].start(
|
||||
random.randint(0, iWidth),
|
||||
random.randint(0, iHeight),
|
||||
random.uniform(0.2, 0.8),
|
||||
col,
|
||||
random.randint(min_len, max_len),
|
||||
iHeight
|
||||
)
|
||||
|
||||
for y in range(0, iHeight):
|
||||
for x in range(0, iWidth):
|
||||
for r in tr:
|
||||
if x == r['x']:
|
||||
led = bytearray(r['data'][y])
|
||||
break
|
||||
led = bytearray((0,0,0))
|
||||
ledData += led
|
||||
|
||||
hyperion.setImage(iWidth,iHeight,ledData)
|
||||
time.sleep(sleepTime)
|
||||
|
||||
import hyperion
|
||||
import time
|
||||
import colorsys
|
||||
import random
|
||||
|
||||
min_len = int(hyperion.args.get('min_len', 3))
|
||||
max_len = int(hyperion.args.get('max_len', 3))
|
||||
#iHeight = int(hyperion.args.get('iHeight', 8))
|
||||
trails = int(hyperion.args.get('int', 8))
|
||||
sleepTime = float(hyperion.args.get('speed', 1)) / 1000.0
|
||||
color = list(hyperion.args.get('color', (255,255,255)))
|
||||
randomise = bool(hyperion.args.get('random', False))
|
||||
iWidth = hyperion.imageWidth()
|
||||
iHeight = hyperion.imageHeight()
|
||||
|
||||
class trail:
|
||||
def __init__(self):
|
||||
return
|
||||
|
||||
def start(self, x, y, step, color, _len, _h):
|
||||
self.pos = 0.0
|
||||
self.step = step
|
||||
self.h = _h
|
||||
self.x = x
|
||||
self.data = []
|
||||
brigtness = color[2]
|
||||
step_brigtness = color[2] / _len
|
||||
for i in range(0, _len):
|
||||
rgb = colorsys.hsv_to_rgb(color[0], color[1], brigtness)
|
||||
self.data.insert(0, (int(255*rgb[0]), int(255*rgb[1]), int(255*rgb[2])))
|
||||
brigtness -= step_brigtness
|
||||
|
||||
self.data.extend([(0,0,0)]*(_h-y))
|
||||
if len(self.data) < _h:
|
||||
for i in range (_h-len(self.data)):
|
||||
self.data.insert(0, (0,0,0))
|
||||
|
||||
def getdata(self):
|
||||
self.pos += self.step
|
||||
if self.pos > 1.0:
|
||||
self.pos = 0.0
|
||||
self.data.pop()
|
||||
self.data.insert(0, (0,0,0))
|
||||
return self.x, self.data[-self.h:], all(x == self.data[0] for x in self.data)
|
||||
|
||||
tr = []
|
||||
|
||||
for unused in range(trails):
|
||||
r = {'exec': trail()}
|
||||
|
||||
if randomise:
|
||||
col = (random.uniform(0.0, 1.0),1,1)
|
||||
else:
|
||||
col = colorsys.rgb_to_hsv(color[0]/255.0, color[1]/255.0, color[2]/255.0)
|
||||
|
||||
r['exec'].start(
|
||||
random.randint(0, iWidth),
|
||||
random.randint(0, iHeight),
|
||||
random.uniform(0.2, 0.8),
|
||||
col,
|
||||
random.randint(min_len, max_len),
|
||||
iHeight
|
||||
)
|
||||
tr.append(r)
|
||||
|
||||
# Start the write data loop
|
||||
while not hyperion.abort():
|
||||
ledData = bytearray()
|
||||
|
||||
for r in tr:
|
||||
r['x'], r['data'], c = r['exec'].getdata()
|
||||
if c:
|
||||
if randomise:
|
||||
col = (random.uniform(0.0, 1.0),1,1)
|
||||
else:
|
||||
col = colorsys.rgb_to_hsv(color[0]/255.0, color[1]/255.0, color[2]/255.0)
|
||||
|
||||
r['exec'].start(
|
||||
random.randint(0, iWidth),
|
||||
random.randint(0, iHeight),
|
||||
random.uniform(0.2, 0.8),
|
||||
col,
|
||||
random.randint(min_len, max_len),
|
||||
iHeight
|
||||
)
|
||||
|
||||
for y in range(0, iHeight):
|
||||
for x in range(0, iWidth):
|
||||
for r in tr:
|
||||
if x == r['x']:
|
||||
led = bytearray(r['data'][y])
|
||||
break
|
||||
led = bytearray((0,0,0))
|
||||
ledData += led
|
||||
|
||||
hyperion.setImage(iWidth,iHeight,ledData)
|
||||
time.sleep(sleepTime)
|
||||
|
||||
|
148
effects/waves.py
148
effects/waves.py
@@ -1,77 +1,71 @@
|
||||
import hyperion, time, math, random
|
||||
|
||||
randomCenter = bool(hyperion.args.get('random-center', False))
|
||||
centerX = float(hyperion.args.get('center_x', -0.15))
|
||||
centerY = float(hyperion.args.get('center_y', -0.25))
|
||||
rotationTime = float(hyperion.args.get('rotation_time', 90))
|
||||
colors = hyperion.args.get('colors', ((255,0,0),(255,255,0),(0,255,0),(0,255,255),(0,0,255),(255,0,255)))
|
||||
reverse = bool(hyperion.args.get('reverse', False))
|
||||
reverseTime = int(hyperion.args.get('reverse_time', 0))
|
||||
#rotate = bool(hyperion.args.get('rotate', True))
|
||||
positions = []
|
||||
|
||||
# calc center if random
|
||||
if randomCenter:
|
||||
centerX = random.uniform(0.0, 1.0)
|
||||
centerY = random.uniform(0.0, 1.0)
|
||||
|
||||
rCenterX = int(round(float(hyperion.imageWidth())*centerX))
|
||||
rCenterY = int(round(float(hyperion.imageHeight())*centerY))
|
||||
|
||||
#calc interval
|
||||
sleepTime = max(1/(255/rotationTime), 0.016)
|
||||
|
||||
#calc diagonal
|
||||
if centerX < 0.5:
|
||||
cX = 1.0-centerX
|
||||
else:
|
||||
cX = 0.0+centerX
|
||||
|
||||
if centerY < 0.5:
|
||||
cY = 1.0-centerY
|
||||
else:
|
||||
cY = 0.0+centerY
|
||||
|
||||
diag = int(round(math.sqrt(((cX*hyperion.imageWidth())**2)+((cY*hyperion.imageHeight())**2))))
|
||||
# some diagonal overhead
|
||||
diag = int(diag*1.3)
|
||||
|
||||
# calc positions
|
||||
pos = 0
|
||||
step = int(255/len(colors))
|
||||
for _ in colors:
|
||||
positions.append(pos)
|
||||
pos += step
|
||||
|
||||
# target time
|
||||
targetTime = time.time()+float(reverseTime)
|
||||
|
||||
#hyperion.imageCOffset(int(hyperion.imageWidth()/2), int(hyperion.imageHeight()/2))
|
||||
|
||||
while not hyperion.abort():
|
||||
# verify reverseTime, randomize reverseTime based on reverseTime up to reversedTime*2
|
||||
if reverseTime >= 1:
|
||||
now = time.time()
|
||||
if now > targetTime:
|
||||
reverse = not reverse
|
||||
targetTime = time.time()+random.uniform(float(reverseTime), float(reverseTime*2.0))
|
||||
# apply rotate
|
||||
#if rotate:
|
||||
# hyperion.imageCRotate(1)
|
||||
# prepare bytearray with colors and positions
|
||||
gradientBa = bytearray()
|
||||
it = 0
|
||||
for color in colors:
|
||||
gradientBa += bytearray((positions[it],color[0],color[1],color[2]))
|
||||
it += 1
|
||||
|
||||
hyperion.imageRadialGradient(rCenterX,rCenterY, diag, gradientBa,0)
|
||||
|
||||
# increment positions
|
||||
for i, pos in enumerate(positions):
|
||||
if reverse:
|
||||
positions[i] = pos - 1 if pos >= 1 else 255
|
||||
else:
|
||||
positions[i] = pos + 1 if pos <= 254 else 0
|
||||
hyperion.imageShow()
|
||||
time.sleep(sleepTime)
|
||||
import hyperion, time, math, random
|
||||
|
||||
randomCenter = bool(hyperion.args.get('random-center', False))
|
||||
centerX = float(hyperion.args.get('center_x', -0.15))
|
||||
centerY = float(hyperion.args.get('center_y', -0.25))
|
||||
rotationTime = float(hyperion.args.get('rotation_time', 90))
|
||||
colors = hyperion.args.get('colors', ((255,0,0),(255,255,0),(0,255,0),(0,255,255),(0,0,255),(255,0,255)))
|
||||
reverse = bool(hyperion.args.get('reverse', False))
|
||||
reverseTime = int(hyperion.args.get('reverse_time', 0))
|
||||
positions = []
|
||||
|
||||
# calc center if random
|
||||
if randomCenter:
|
||||
centerX = random.uniform(0.0, 1.0)
|
||||
centerY = random.uniform(0.0, 1.0)
|
||||
|
||||
rCenterX = int(round(float(hyperion.imageWidth())*centerX))
|
||||
rCenterY = int(round(float(hyperion.imageHeight())*centerY))
|
||||
|
||||
#calc interval
|
||||
sleepTime = max(1/(255/rotationTime), 0.016)
|
||||
|
||||
#calc diagonal
|
||||
if centerX < 0.5:
|
||||
cX = 1.0-centerX
|
||||
else:
|
||||
cX = 0.0+centerX
|
||||
|
||||
if centerY < 0.5:
|
||||
cY = 1.0-centerY
|
||||
else:
|
||||
cY = 0.0+centerY
|
||||
|
||||
diag = int(round(math.hypot(cX*hyperion.imageWidth(),cY*hyperion.imageHeight())))
|
||||
# some diagonal overhead
|
||||
diag = int(diag*1.3)
|
||||
|
||||
# calc positions
|
||||
pos = 0
|
||||
step = int(255/len(colors))
|
||||
for _ in colors:
|
||||
positions.append(pos)
|
||||
pos += step
|
||||
|
||||
# target time
|
||||
targetTime = time.time()+float(reverseTime)
|
||||
while not hyperion.abort():
|
||||
# verify reverseTime, randomize reverseTime based on reverseTime up to reversedTime*2
|
||||
if reverseTime >= 1:
|
||||
now = time.time()
|
||||
if now > targetTime:
|
||||
reverse = not reverse
|
||||
targetTime = time.time()+random.uniform(float(reverseTime), float(reverseTime*2.0))
|
||||
|
||||
# prepare bytearray with colors and positions
|
||||
gradientBa = bytearray()
|
||||
it = 0
|
||||
for color in colors:
|
||||
gradientBa += bytearray((positions[it],color[0],color[1],color[2]))
|
||||
it += 1
|
||||
|
||||
hyperion.imageRadialGradient(rCenterX,rCenterY, diag, gradientBa,0)
|
||||
|
||||
# increment positions
|
||||
for i, pos in enumerate(positions):
|
||||
if reverse:
|
||||
positions[i] = pos - 1 if pos >= 1 else 255
|
||||
else:
|
||||
positions[i] = pos + 1 if pos <= 254 else 0
|
||||
hyperion.imageShow()
|
||||
time.sleep(sleepTime)
|
||||
|
@@ -1,30 +1,30 @@
|
||||
import hyperion, time
|
||||
|
||||
# Get the parameters
|
||||
sleepTime = float(hyperion.args.get('sleepTime', 1000))/1000.0
|
||||
length = hyperion.args.get('length', 1)
|
||||
color1 = hyperion.args.get('color1', (255,255,255))
|
||||
color2 = hyperion.args.get('color2', (255,0,0))
|
||||
|
||||
# Initialize the led data
|
||||
i = 0
|
||||
ledDataOdd = bytearray()
|
||||
while i < hyperion.ledCount:
|
||||
for l in range(length):
|
||||
if i<hyperion.ledCount:
|
||||
ledDataOdd += bytearray((int(color1[0]), int(color1[1]), int(color1[2])))
|
||||
i += 1
|
||||
|
||||
for l in range(length):
|
||||
if i<hyperion.ledCount:
|
||||
ledDataOdd += bytearray((int(color2[0]), int(color2[1]), int(color2[2])))
|
||||
i += 1
|
||||
|
||||
ledDataEven = ledDataOdd[3*length:] + ledDataOdd[0:3*length]
|
||||
|
||||
# Start the write data loop
|
||||
while not hyperion.abort():
|
||||
hyperion.setColor(ledDataOdd)
|
||||
time.sleep(sleepTime)
|
||||
hyperion.setColor(ledDataEven)
|
||||
time.sleep(sleepTime)
|
||||
import hyperion, time
|
||||
|
||||
# Get the parameters
|
||||
sleepTime = float(hyperion.args.get('sleepTime', 1000))/1000.0
|
||||
length = hyperion.args.get('length', 1)
|
||||
color1 = hyperion.args.get('color1', (255,255,255))
|
||||
color2 = hyperion.args.get('color2', (255,0,0))
|
||||
|
||||
# Initialize the led data
|
||||
i = 0
|
||||
ledDataOdd = bytearray()
|
||||
while i < hyperion.ledCount:
|
||||
for unused in range(length):
|
||||
if i<hyperion.ledCount:
|
||||
ledDataOdd += bytearray((int(color1[0]), int(color1[1]), int(color1[2])))
|
||||
i += 1
|
||||
|
||||
for unused in range(length):
|
||||
if i<hyperion.ledCount:
|
||||
ledDataOdd += bytearray((int(color2[0]), int(color2[1]), int(color2[2])))
|
||||
i += 1
|
||||
|
||||
ledDataEven = ledDataOdd[3*length:] + ledDataOdd[0:3*length]
|
||||
|
||||
# Start the write data loop
|
||||
while not hyperion.abort():
|
||||
hyperion.setColor(ledDataOdd)
|
||||
time.sleep(sleepTime)
|
||||
hyperion.setColor(ledDataEven)
|
||||
time.sleep(sleepTime)
|
||||
|
Reference in New Issue
Block a user