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"))))
led_state = bytearray("820a0a0a 0a0a0a0a 0a0a0a0a 0a0a0a0a 0a0a0a0a 0a0a0a0a 0a3f3f3f 3f3f3f3f".replace(" ", "").decode("hex"))
hidapi.hid_write(device, led_state)
def import_image(display_no, fname):
import textwrap
result_str = open(fname, "r").read()
def open(self) -> None:
"""Opens the connection to the RoIP device."""
hidapi.hid_init()
self.hid_device = hidapi.hid_open(self.device[0], self.device[1])
self._logger.info('Opened hid_device="%s"', self.hid_device)
def __init__(self):
try:
self.device = hidapi.hid_open(HASSEB_USB_VENDOR, HASSEB_USB_PRODUCT, None)
self.device_found = 1
except:
self.device_found = None