Skip to content

Commit

Permalink
Merge pull request #182 from wridgers/add-cylon-effect
Browse files Browse the repository at this point in the history
Add cylon effect
  • Loading branch information
julianschill authored Nov 16, 2024
2 parents 121c9bb + f35c139 commit 5fa8672
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
7 changes: 7 additions & 0 deletions docs/LED_Effect.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,13 @@ the "head" of the comet and the remaining colors are blended into the "tail"
Palette: Color of "head" and gradient of "tail"
Identical settings as Comet, but with multiple lights chasing each other.

#### Cylon
Effect Rate: 1 How fast the cylon sweeps
Cutoff: 0 Not used but must be provided
Palette: Color of sweeping LED
A light moves between each end of the strip. Multiple colors can be provided;
the color will change after each sweep.

#### Heater
Effect Rate: 1 Minimum temperature to activate effect
Cutoff: 0 Disable effect once temp is reached
Expand Down
34 changes: 34 additions & 0 deletions src/led_effect.py
Original file line number Diff line number Diff line change
Expand Up @@ -857,6 +857,40 @@ def __init__(self, **kwargs):

self.frameCount = len(self.thisFrame)

#Cylon, single LED bounces from start to end of strip
class layerCylon(_layerBase):
def __init__(self, **kwargs):
super(ledEffect.layerCylon, self).__init__(**kwargs)

self.paletteColors = colorArray(COLORS, self.paletteColors)

if self.effectRate <= 0:
raise Exception("effect rate for cylon must be > 0")

# How many frames per sweep animation.
frames = int(self.effectRate / self.frameRate)

direction = True

for _ in range(len(self.paletteColors) % 2 + 1):
for c in range(0, len(self.paletteColors)):
color = self.paletteColors[c]

for frame in range(frames):
pct = frame / (frames - 1)
newFrame = []

p = int(round((self.ledCount - 2) * pct) if direction else 1 + round(((self.ledCount - 2) * (1 - pct))))

for i in range(self.ledCount):
newFrame += color if p == i else [0.0] * COLORS

self.thisFrame.append(newFrame)

direction = not direction

self.frameCount = len(self.thisFrame)

#Color gradient over all LEDs
class layerGradient(_layerBase):
def __init__(self, **kwargs):
Expand Down

0 comments on commit 5fa8672

Please sign in to comment.