-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsections-randomRGB.py
More file actions
162 lines (130 loc) · 4.74 KB
/
sections-randomRGB.py
File metadata and controls
162 lines (130 loc) · 4.74 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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
import openrazer.client
import colorsys
import random
import time
import sys
#####################################
#CONFIG COLORS & TIME BETWEEN CHANGES
#Color Options
red = [255,0,0]
green = [0,255,0]
blue = [0,0,255]
white = [255,255,255]
#colors to be randomly chosen
#colors = [red,green,blue,white]
colors = [red,green,blue]
#colors = [red,blue,white]
#time in seconds between color changes
sleepTime = 1
#####################################
device_manager = openrazer.client.DeviceManager()
devices = device_manager.devices
print("Found {} Razer devices".format(len(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 rainbow rgb".format(device.name))
def customMatrix():
try:
for device in devices:
#rows - there is a max of 6 rows starting at 0-5
fRow = [0]
topRows = [1,2]
bottomRows = [3,4,5]
#f key groups
fGroup1 = [3,4,5,6]
fGroup2 = [7,8,9,10]
fGroup3 = [11,12,13,14]
#cols left, middle, right
leftCols = [0,1,2,3,4,5]
middleCols = [6,7,8,9,10]
rightCols = [11,12,13,14]
#Control keys - ins,home,page up. starts at 15
controlKeyCols = [15,16,17]
controlMidRows =[1,2]
# keypad
keypadCols = [18,19,20,21]
#esc key
color = random.choice(colors)
device.fx.advanced.matrix[0, 1] = color
#F1-F4
color = random.choice(colors)
for i in fRow:
for c in fGroup1:
device.fx.advanced.matrix[i, c] = color
#F5 - F8
color = random.choice(colors)
for i in fRow:
for c in fGroup2:
device.fx.advanced.matrix[i, c] = color
#F9 - F12
color = random.choice(colors)
for i in fRow:
for c in fGroup3:
device.fx.advanced.matrix[i, c] = color
#left alphanumeric keys top & bottom
color = random.choice(colors)
for i in topRows:
for c in leftCols:
device.fx.advanced.matrix[i, c] = color
color = random.choice(colors)
for i in bottomRows:
for c in leftCols:
device.fx.advanced.matrix[i, c] = color
#middle alphanumeric keys top & bottom
color = random.choice(colors)
for i in topRows:
for c in middleCols:
device.fx.advanced.matrix[i, c] = color
color = random.choice(colors)
for i in bottomRows:
for c in middleCols:
device.fx.advanced.matrix[i, c] = color
#right alphanumeric keys top & bottom
color = random.choice(colors)
for i in topRows:
for c in rightCols:
device.fx.advanced.matrix[i, c] = color
color = random.choice(colors)
for i in bottomRows:
for c in rightCols:
device.fx.advanced.matrix[i, c] = color
#control keys top & bottom
color = random.choice(colors)
for i in fRow:
for c in controlKeyCols:
device.fx.advanced.matrix[i, c] = color
color = random.choice(colors)
for i in controlMidRows:
for c in controlKeyCols:
device.fx.advanced.matrix[i, c] = color
# Arrow Keys
color = random.choice(colors)
for i in bottomRows:
for c in controlKeyCols:
device.fx.advanced.matrix[i, c] = color
#keypad top & bottom
color = random.choice(colors)
for i in topRows:
for c in keypadCols:
device.fx.advanced.matrix[i, c] = color
color = random.choice(colors)
for i in bottomRows:
for c in keypadCols:
device.fx.advanced.matrix[i, c] = color
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:
customMatrix()
time.sleep(sleepTime)
except KeyboardInterrupt:
print(" You Press CTRL+C GOOD BYE")
sys.exit(0)
run()