forked from robotics-4-all/tektrain-robot-sw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_neopixel_rgb.py
47 lines (36 loc) · 1.25 KB
/
test_neopixel_rgb.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
import unittest
import time
from pidevices.actuators.neopixel_rgb import LedController
class TestLedController(unittest.TestCase):
def test_write(self):
led_count = 19
led_controller = LedController(led_count, 13, 700000, 255, led_channel=1)
print("Color wipe red")
led_controller.write([[255, 0, 0, 150]], wipe=True)
time.sleep(5)
led_controller.write([[0, 0, 0, 150]], wipe=True)
#led_controller.restart()
print("All colors per three led.")
r = [255, 0, 0, 150]
g = [0, 255, 0, 150]
b = [0, 0, 255, 150]
white = [0, 0, 0, 105]
r_index = 0
g_index = 1
b_index = 2
data = [white for i in range(led_count)]
for j in range(4):
data[r_index] = r
data[g_index] = g
data[b_index] = b
led_controller.write(data)
time.sleep(1)
data[r_index] = white
data[g_index] = white
data[b_index] = white
r_index = (r_index+1) % led_count
g_index = (g_index+1) % led_count
b_index = (b_index+1) % led_count
led_controller.write([[0, 0, 0, 150]], wipe=True)
if __name__ == "__main__":
unittest.main()