-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstripes.py
More file actions
79 lines (63 loc) · 2 KB
/
stripes.py
File metadata and controls
79 lines (63 loc) · 2 KB
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
import openrazer.client
import colorsys
import random
import time
import sys
device_manager = openrazer.client.DeviceManager()
devices = device_manager.devices
for device in devices:
if not device.fx.advanced:
print("Skipping device " + device.name + " (" + device.serial + ")")
devices.remove(device)
print("Setting {} to stripes effect".format(device.name))
#Color Options
red = [255,0,0]
green = [0,255,0]
blue = [0,0,255]
white = [255,255,255]
def step1():
try:
for device in devices:
rows, cols = device.fx.advanced.rows, device.fx.advanced.cols
even = [0,2,4]
odd = [1,3,5]
for i in even:
for col in range(cols):
device.fx.advanced.matrix[i, col] = green
for i in odd:
for col in range(cols):
device.fx.advanced.matrix[i, col] = blue
device.fx.advanced.draw()
except:
print("is device connected? Sleeping for 30 seconds, will try again!")
time.sleep(30)
pass
def step2():
try:
for device in devices:
rows, cols = device.fx.advanced.rows, device.fx.advanced.cols
even = [0,2,4]
odd = [1,3,5]
for i in even:
for col in range(cols):
device.fx.advanced.matrix[i, col] = blue
for i in odd:
for col in range(cols):
device.fx.advanced.matrix[i, col] = green
device.fx.advanced.draw()
except:
print("is device connected? Sleeping for 30 seconds, will try again!")
time.sleep(30)
pass
# define which function to run and how long to sleep between color changes
def run():
while True:
try:
step1()
time.sleep(1)
step2()
time.sleep(1)
except KeyboardInterrupt:
print(" You Press CTRL+C GOOD BYE")
sys.exit(0)
run()