From 608a22429b2ad2b070868c70e71978a3252a3058 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20Weigert?= Date: Sat, 25 May 2019 10:34:27 +0200 Subject: [PATCH] hidapi seems more reliable when it gets the entire buffer at once. --- led-badge-11x44.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/led-badge-11x44.py b/led-badge-11x44.py index 37cb91d..a1573ba 100755 --- a/led-badge-11x44.py +++ b/led-badge-11x44.py @@ -458,11 +458,12 @@ if needpadding: buf.extend( (0,) * (64-needpadding) ) # print(buf) # array('B', [119, 97, 110, 103, 0, 0, 0, 0, 48, 48, 48, 48, 48, 48, 48, 48, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 126, 255, 255, 255, 255, 126, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]) -for i in range(int(len(buf)/64)): - time.sleep(0.1) - if have_pyhidapi: - pyhidapi.hid_write(dev, buf[i*64:i*64+64]) - else: + +if have_pyhidapi: + pyhidapi.hid_write(dev, buf) +else: + for i in range(int(len(buf)/64)): + time.sleep(0.1) dev.write(1, buf[i*64:i*64+64]) if have_pyhidapi: