You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
904 B
37 lines
904 B
#!/usr/bin/env python3 |
|
# Ported by Peter |
|
# Palun! |
|
|
|
from lib.Program import Program |
|
import time |
|
import random |
|
|
|
|
|
def name(): |
|
return 'DiskoPidu' |
|
|
|
|
|
class DiskoPidu(Program): |
|
|
|
def disco(self, segmentLength, wait_ms): |
|
color = random.randint(0, 0xffffff) |
|
totalLength = self._lm.count_pixels() |
|
for p in range(totalLength): |
|
if p % segmentLength == 0: |
|
color = random.randint(0, 0xffffff) |
|
self._lm.set_pixel_color(p, color) |
|
self._lm.show() |
|
time.sleep(wait_ms / 1000.0) |
|
|
|
# Main program logic follows: |
|
def run(self, args=None): |
|
loop = False |
|
if 'loop' in args and args['loop']: |
|
loop = args['loop'] |
|
|
|
while self.get_loop().status(): |
|
self._lm.get_tempo().wait() |
|
self.disco(10, 0) |
|
|
|
if not loop: |
|
break
|
|
|