-
Notifications
You must be signed in to change notification settings - Fork 1
/
pattern.py
31 lines (26 loc) · 858 Bytes
/
pattern.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import numpy
class Pattern1D():
'''
param n: number of LEDs
'''
def __init__(self, n) -> None:
self.n = n
# set to true, if the pattern has finished (optional)
self.should_finish = False
# the (approximate) interval [ms] at which the pattern is polled
self.interval = 10
'''
draw() takes as input a time t in milliseconds, and returns a numpy integer array of shape (n, 3)
that contains the color of each LED at time t
'''
def draw(self, t):
pass
class Pattern3D(Pattern1D):
'''
param n: number of LEDs
param coords: numpy array of shape (n, 3). coords[i] contains the coordinates for LED i.
coordinates are normalized to [0, 1]
'''
def __init__(self, n, coords) -> None:
super().__init__(n)
self.coords = coords