]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
Merge pull request #243 from caternuson/win_hid_fix 3.8.0
authorLimor "Ladyada" Fried <limor@ladyada.net>
Mon, 3 Feb 2020 02:46:30 +0000 (21:46 -0500)
committerGitHub <noreply@github.com>
Mon, 3 Feb 2020 02:46:30 +0000 (21:46 -0500)
Add HID delay

src/adafruit_blinka/microcontroller/mcp2221/mcp2221.py

index aae81e5088df6d583bf6f142b20cedc10f4d5c11..8247006153d35be26993ed41c030520bfd6c2487 100644 (file)
@@ -1,6 +1,10 @@
+import os
 import time
 import hid
 
+# Small values seem to help on some Windows setups
+MCP2221_HID_DELAY = float(os.environ.get('BLINKA_MCP2221_HID_DELAY', 0))
+
 # from the C driver
 # http://ww1.microchip.com/downloads/en/DeviceDoc/mcp2221_0_1.tar.gz
 # others (???) determined during driver developement
@@ -51,6 +55,7 @@ class MCP2221:
         # remaing bytes = 64 byte report data
         # https://github.com/libusb/hidapi/blob/083223e77952e1ef57e6b77796536a3359c1b2a3/hidapi/hidapi.h#L185
         self._hid.write(b'\0' + report + b'\0'*(64-len(report)))
+        time.sleep(MCP2221_HID_DELAY)
         if response:
             # return is 64 byte response report
             return self._hid.read(64)