From a7c4f8b9e3a58b0da8dcacdc3e5414427f8b487f Mon Sep 17 00:00:00 2001 From: "E. A. Graham Jr" Date: Fri, 2 Aug 2024 11:53:43 -0700 Subject: [PATCH] A work-around for using byte-string as the data Fixes #137 -- a byte-string is not representable as a `list` for adding, so this just re-wraps the iterable in a "real" `list` --- .gitignore | 2 ++ i2cdisplaybus/__init__.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2c6ddfd..4fc1bd3 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ bundles dist **/*.egg-info .vscode +venv +.venv diff --git a/i2cdisplaybus/__init__.py b/i2cdisplaybus/__init__.py index c8d6441..b004e54 100644 --- a/i2cdisplaybus/__init__.py +++ b/i2cdisplaybus/__init__.py @@ -87,7 +87,9 @@ class I2CDisplayBus: done. """ self._begin_transaction() - self._send(DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, bytes([command] + data)) + # re-wrap in case of byte-string + buffer = list(data) if isinstance(data, bytes) else data + self._send(DISPLAY_COMMAND, CHIP_SELECT_UNTOUCHED, bytes([command] + buffer)) self._end_transaction() def _send( -- 2.49.0