-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmasker.py
62 lines (50 loc) · 1.82 KB
/
masker.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import numpy as np
from config import *
def bottom_up(m):
'''
Creates a mask of which leds to turn on given an amplitude.
This mask lights a strip of LEDs starting at the bottom and reaching higher
with increasing amplitude
Arguments:
m (float): The amplitude in 0 to 1
Returns:
A [LED_1_COUNT x 3] array of zeros and ones
'''
num_leds_on = m * LED_1_COUNT
return np.tile(np.arange(LED_1_COUNT) < num_leds_on, (3,1)).T
def top_down(m):
'''
Creates a mask of which leds to turn on given an amplitude.
This mask lights a strip of LEDs starting at the top and reaching lower
with increasing amplitude
Arguments:
m (float): The amplitude in 0 to 1
Returns:
A [LED_1_COUNT x 3] array of zeros and ones
'''
num_leds_on = m * LED_1_COUNT
return np.tile(LED_1_COUNT - np.arange(LED_1_COUNT) < num_leds_on, (3,1)).T
def middle_out(m):
'''
Creates a mask of which leds to turn on given an amplitude.
This mask lights a strip of LEDs starting at the middle and reaching out
with increasing amplitude
Arguments:
m (float): The amplitude in 0 to 1
Returns:
A [LED_1_COUNT x 3] array of zeros and ones
'''
num_leds_on = m * LED_1_COUNT
return np.tile(np.abs(LED_1_COUNT/2.0 - np.arange(LED_1_COUNT)) < num_leds_on/2., (3,1)).T
def clamp(m):
'''
Creates a mask of which leds to turn on given an amplitude.
This mask lights a strip of LEDs starting at the top and bottom and reaching towards
the middle with increasing amplitude
Arguments:
m (float): The amplitude in 0 to 1
Returns:
A [LED_1_COUNT x 3] array of zeros and ones
'''
num_leds_on = (1. - m) * LED_1_COUNT
return 1 - np.tile(np.abs(LED_1_COUNT/2.0 - np.arange(LED_1_COUNT)) < num_leds_on/2., (3,1)).T