-
Notifications
You must be signed in to change notification settings - Fork 8
/
ssere.py
73 lines (60 loc) · 1.93 KB
/
ssere.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
import os
import sys
import traceback
import keys
import colors
import device
from time import sleep
from usb.core import USBError
with device.Device() as device:
for idx in range(5):
device.oled_text("GRIMM---\n %s \n#######" % idx)
sleep(1.0)
device.oled_blank()
sleep(2)
device.oled_image("./images/grimm.png")
def switch_configs(device):
print("set_config(2)")
device.set_config(2)
sleep(5)
print("set_config(1)")
device.set_config(1)
def cycle_regions(device):
for region, region_keys in keys.KEY_REGIONS.items():
for color in [colors.COLOR_RED, colors.COLOR_GREEN, colors.COLOR_BLUE]:
print("illuminating region", region, "color", color)
COLOR_PAYLOAD = []
for addr in region_keys:
COLOR_PAYLOAD += [addr]
COLOR_PAYLOAD += color
for addr in keys.others(region_keys):
COLOR_PAYLOAD += [addr]
COLOR_PAYLOAD += colors.COLOR_BLACK
device.send_colors(COLOR_PAYLOAD)
sleep(0.8)
def cycle_allkeys(device):
seen = set()
for cur in set(keys.KEYMAP.values()):
continue
sleep(0.1)
print("cur", hex(cur))
for idx in range(5):
device.oled
sleep(1.0)
seen.add(cur)
try:
COLOR_PAYLOAD = []
# COLOR_PAYLOAD = [KEY_ADDR[tgt_idx]] + colors.COLOR_ORANGE
for addr in set(keys.KEYMAP.values()):
COLOR_PAYLOAD.append(addr)
if addr in seen:
COLOR_PAYLOAD += colors.COLOR_ORANGE
else:
COLOR_PAYLOAD += colors.COLOR_BLACK
device.send_colors(COLOR_PAYLOAD)
print("sending report done")
except USBError as e:
print("failed to send report", e)
traceback.print_exc()
except Exception as e1:
print("generic error", e1)