From: E. A. Graham Jr Date: Fri, 2 Aug 2024 18:53:43 +0000 (-0700) Subject: A work-around for using byte-string as the data X-Git-Tag: 2.1.2^2~6 X-Git-Url: https://git.ayoreis.com/hackapet/Adafruit_Blinka_Displayio.git/commitdiff_plain/a7c4f8b9e3a58b0da8dcacdc3e5414427f8b487f 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` --- 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(