Skip to content

Commit

Permalink
Fix larson.py for #56
Browse files Browse the repository at this point in the history
  • Loading branch information
Gadgetoid committed Jul 18, 2017
1 parent f4f8a07 commit c2048e0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions examples/larson.py
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
#!/usr/bin/env python

import time
import math

import blinkt

blinkt.set_clear_on_exit()

REDS = [0, 0, 0, 0, 0, 16, 64, 255, 64, 16, 0, 0, 0, 0, 0]
REDS = [0, 0, 0, 0, 0, 16, 64, 255, 64, 16, 0, 0, 0, 0, 0, 0]

start_time = time.time()

while True:
delta = (time.time() - start_time) * 16

# Sine wave, spends a little longer at min/max
# offset = int(round(((math.sin(delta) + 1) / 2) * 7))
# delta = (time.time() - start_time) * 8
# offset = int(round(((math.sin(delta) + 1) / 2) * (blinkt.NUM_PIXELS - 1)))

# Triangle wave, a snappy ping-pong effect
offset = int(abs((delta % 16) - 8))
delta = (time.time() - start_time) * 16
offset = int(abs((delta % len(REDS)) - blinkt.NUM_PIXELS))

for i in range(8):
for i in range(blinkt.NUM_PIXELS):
blinkt.set_pixel(i , REDS[offset + i], 0, 0)

blinkt.show()
Expand Down

0 comments on commit c2048e0

Please sign in to comment.