Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
#!/usr/bin/env python
import hidapi
import binascii
import time
hidapi.hid_init()
print 'Loaded hidapi library from: {:s}\n'.format(hidapi.hid_lib_path())
devices = hidapi.hid_enumerate(0x17cc, 0x1140)
if len(devices) == 0:
print "No maschine attached"
exit(1)
device = hidapi.hid_open(0x17cc, 0x1140)
quiet_state = "20000000100020003000400050006000700080009000a000b000c000d000e000f0000000100020003000400050006000700080009000a000b000c000d000e000f0"
to_bytearray = lambda display: [bytearray(line.replace(" ", "").decode("hex")) for line in display]
write_display = lambda display: [hidapi.hid_write(device, line) for line in to_bytearray(display)]
def clear_display(no):
for i in range(0, 8):
hidapi.hid_write(device, (bytearray((("e00000%02x00200008" % (8 * i) + ((265 - 8) * "00")).replace("e0", "e%d" %no)).decode("hex"))))