-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:lit-illumination-technology/lit_c…
…ore into master
- Loading branch information
Showing
2 changed files
with
47 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,55 @@ | ||
import colorsys | ||
import random | ||
|
||
name = "Chase" | ||
|
||
start_message = name + " started!" | ||
|
||
description = "The string is sequentially covered by different colors" | ||
description = ( | ||
"The string is sequentially covered by random colors" | ||
) | ||
|
||
|
||
def create_heads(lights, args): | ||
num_heads = int(args["number"]) | ||
colors = [random.random() for _ in range(0, num_heads)] | ||
head_locations = [i * (-lights.size // num_heads) for i in range(0, num_heads)] | ||
return [head_locations, colors] | ||
|
||
|
||
schema = {} | ||
schema = { | ||
"number": { | ||
"value": { | ||
"type": "number", # TODO integer type (or step) | ||
"min": 1, | ||
"max": 20, | ||
"default": 3, | ||
}, | ||
"user_input": True, | ||
"required": False, | ||
"index": 0, | ||
}, | ||
"color": { | ||
"value": { | ||
"type": "color", # TODO integer type (or step) | ||
"default": {"type": "Random Colors"}, | ||
}, | ||
"user_input": True, | ||
"required": False, | ||
}, | ||
"heads": { | ||
"value": {"type": "tuple list", "default_gen": create_heads}, | ||
"user_input": False, | ||
}, | ||
} | ||
|
||
|
||
def update(lights, step, state): | ||
hue = (0.2 * (step // lights.size)) % 1 | ||
lights.set_pixel_hsv(step % lights.size, hue, 1, 1) | ||
heads = state["heads"] | ||
for i in range(len(heads[0])): | ||
if heads[0][i] >= 0: | ||
lights.set_pixel_hsv(heads[0][i], heads[1][i], 1, 1) | ||
heads[0][i] += 1 | ||
if heads[0][i] >= lights.size: | ||
heads[0][i] = 0 | ||
heads[1][i] = colorsys.rgb_to_hsv(state["color"].get_color(step)) |
This file was deleted.
Oops, something went wrong.