Update led-badge-11x44.py

pull/1/head
mik-at 6 years ago committed by GitHub
parent 3cd794a878
commit 0dd737bb03
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 15
      led-badge-11x44.py

@ -23,6 +23,9 @@
import sys, os, re, time, argparse import sys, os, re, time, argparse
from array import array from array import array
if sys.platform == "darwin":
import pyhidapi
else:
import usb.core import usb.core
__version = "0.6" __version = "0.6"
@ -335,8 +338,15 @@ parser.add_argument('--mode-help', action='version', help=argparse.SUPPRESS, ver
(No "rotation" or "smothering"(?) effect can be expected, though) (No "rotation" or "smothering"(?) effect can be expected, though)
""" % sys.argv[0]) """ % sys.argv[0])
args = parser.parse_args() args = parser.parse_args()
if sys.platform == "darwin":
pyhidapi.hid_init()
dev = pyhidapi.hid_open(0x0416, 0x5020)
else:
dev = usb.core.find(idVendor=0x0416, idProduct=0x5020) dev = usb.core.find(idVendor=0x0416, idProduct=0x5020)
if sys.platform == "darwin":
print("using pyhidapi")
else:
if dev is None: if dev is None:
print("No led tag with vendorID 0x0416 and productID 0x5020 found.") print("No led tag with vendorID 0x0416 and productID 0x5020 found.")
print("Connect the led tag and run this tool as root.") print("Connect the led tag and run this tool as root.")
@ -371,5 +381,8 @@ if needpadding:
# print(buf) # print(buf)
for i in range(int(len(buf)/64)): for i in range(int(len(buf)/64)):
time.sleep(0.1) time.sleep(0.1)
if sys.platform == "darwin":
pyhidapi.hid_write(dev, buf[i*64:i*64+64])
else:
dev.write(1, buf[i*64:i*64+64]) dev.write(1, buf[i*64:i*64+64])

Loading…
Cancel
Save