How to use the hidapi.hid_open function in hidapi

To help you get started, we’ve selected a few hidapi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hansfbaier / open-maschine / proof-of-concept / View on Github external
#!/usr/bin/env python

import hidapi
import binascii
import time

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"

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()
github ampledata / roip / roip / View on Github external
def open(self) -> None:
        """Opens the connection to the RoIP device."""
        self.hid_device = hidapi.hid_open(self.device[0], self.device[1])'Opened hid_device="%s"', self.hid_device)
github sde1000 / python-dali / dali / driver / View on Github external
def __init__(self):
            self.device = hidapi.hid_open(HASSEB_USB_VENDOR, HASSEB_USB_PRODUCT, None)
            self.device_found = 1
            self.device_found = None