Skip to content

Commit 430eecd

Browse files
committed
python: Make it work on linux
linux doesn't include the usage page id Signed-off-by: Daniel Schaefer <dhs@frame.work>
1 parent a7913c9 commit 430eecd

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

python/lamp_array.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,10 @@ def print_lamp_details(device):
3131
array_attributes = h.get_feature_report(LAMP_ARRAY_ATTRIBUTES_REPORT_ID, 0x100)
3232
# Cut off report ID in first byte and convert to bytearray
3333
array_attributes = bytes(array_attributes[1:])
34-
print(array_attributes.hex())
35-
print(len(array_attributes))
3634

3735
(cnt, width, height, depth, kind, interval) = \
3836
struct.unpack(LAMP_ARRAY_ATTRIBUTES_FORMAT, array_attributes)
3937

40-
print(interval)
41-
4238
print("Lamp Array")
4339
print(f" Count: {cnt}")
4440
print(f" Width: {width}um")
@@ -81,12 +77,22 @@ def print_lamp_details(device):
8177

8278

8379
def main():
84-
devices = find_devs(show=False, verbose=False)
80+
verbose = False
81+
devices = find_devs(show=False, verbose=verbose)
8582
for device in devices:
86-
positions = print_lamp_details(device)
87-
import matplotlib.pyplot as plt
88-
plt.scatter(x=positions[0], y=positions[1])
89-
plt.show()
83+
try:
84+
positions = print_lamp_details(device)
85+
import matplotlib.pyplot as plt
86+
plt.scatter(x=positions[0], y=positions[1])
87+
plt.show()
88+
except struct.error as e:
89+
if verbose:
90+
print(e)
91+
continue
92+
except OSError as e:
93+
if verbose:
94+
print(e)
95+
continue
9096

9197
def format_bcd(fw_ver):
9298
fw_ver_major = (fw_ver & 0xFF00) >> 8

0 commit comments

Comments
 (0)