-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
110 lines (91 loc) · 3.36 KB
/
test.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/usr/bin/env python3
import sys
from time import sleep
from blinkstick_python.blinkstick import blinkstick
print("Python Package: " + blinkstick.get_blinkstick_package_version())
for bstick in blinkstick.find_all():
print("Serial: " + bstick.get_serial())
print("Variant: " + bstick.get_variant_string())
print("Manufacturer: " + bstick.get_manufacturer())
print("Description: " + bstick.get_description())
# See .coveragerc for details
# print("Setting Info Block 1")
# bstick.set_info_block1("Olaf Reitmaier")
info1 = bstick.get_info_block1()
print("Info Block 1: " + info1)
# See .coveragerc for details
# print("Setting Info Block 2")
# bstick.set_info_block2("[email protected]")
info2 = bstick.get_info_block2()
print("Info Block 2: " + info2)
bstick = None
print("---")
print("Finding first device...")
led = blinkstick.find_first()
if led:
if sys.platform != "win32":
print("LEDs Count: " + str(led.get_led_count())) # -1 <=> Unsupported
print("---")
print("Turning on 🟥 RED...")
led.set_error_reporting(False)
led.set_color(hex="#f00") # name="red" , expands to hex="#ff0000"
print("Color: " + led.get_color(color_format="hex"))
print("Color: " + str(led.get_color(color_format="rgb")))
sleep(3)
print("---")
print("Turning on 🟧 ORANGE...")
led.set_error_reporting(True)
led.set_color(name="orange")
print("Color: " + led.get_color(color_format="hex"))
print("Color: " + str(led.get_color(color_format="rgb")))
sleep(3)
print("---")
print("Turning on 🟥 RED? (Max RGB Value=128) ...")
led.get_max_rgb_value(None) # This function must be fixed
led.set_max_rgb_value(128)
led.set_color(red=255, green=0, blue=0) # name="red"
print("Color: " + led.get_color(color_format="hex"))
print("Color: " + str(led.get_color(color_format="rgb")))
sleep(3)
led.set_max_rgb_value(255)
led.get_max_rgb_value(None)
print("---")
print("Inverse of ⬛ BLACK is ⬜ WHITE ...")
led.get_inverse()
led.set_inverse(True)
led.set_color(name="black")
print("Color: " + led.get_color(color_format="hex"))
print("Color: " + str(led.get_color(color_format="rgb")))
sleep(3)
led.set_inverse(False)
print("---")
print("Pulsing on 🟦 BLUE...")
led.pulse(name="blue", duration=1000, repeats=3)
print("Color: " + led.get_color(color_format="hex"))
print("Color: " + str(led.get_color(color_format="rgb")))
sleep(1)
print("---")
print("Blinking on 🟩 GREEN...")
led.blink(name="green", delay=1000, repeats=3)
print("Color: " + led.get_color(color_format="hex"))
print("Color: " + str(led.get_color(color_format="rgb")))
sleep(3)
print("---")
print("Morphing from 🟦 BLUE => 🟨 YELLOW ...")
led.set_color(name="blue")
sleep(1)
led.morph(name="yellow", duration=6000, steps=100)
print("Color: " + led.get_color(color_format="hex"))
print("Color: " + str(led.get_color(color_format="rgb")))
sleep(3)
print("---")
print("Random 2x🎁 COLORS ...")
led.set_color(name="random")
sleep(3)
led.set_random_color()
print("Color: " + led.get_color(color_format="hex"))
print("Color: " + str(led.get_color(color_format="rgb")))
sleep(3)
print("Turning ⬇️ OFF")
led.turn_off()
led = None