From 7e6dae43ed74837a6d7fd9de27e0fde286d1c037 Mon Sep 17 00:00:00 2001 From: Kancelot To Date: Fri, 26 Sep 2025 20:49:06 +1000 Subject: [PATCH 1/2] Rely on spidev for chip select --- library/unicornhatmini/__init__.py | 8 -------- 1 file changed, 8 deletions(-) diff --git a/library/unicornhatmini/__init__.py b/library/unicornhatmini/__init__.py index 3954b98..bf42480 100644 --- a/library/unicornhatmini/__init__.py +++ b/library/unicornhatmini/__init__.py @@ -7,8 +7,6 @@ from colorsys import hsv_to_rgb -import RPi.GPIO as GPIO - __version__ = '0.0.2' @@ -45,16 +43,12 @@ def __init__(self, spi_max_speed_hz=600000): self.left_matrix = (spidev.SpiDev(0, 0), 8, 0) self.right_matrix = (spidev.SpiDev(0, 1), 7, 28 * 8) - GPIO.setwarnings(False) - GPIO.setmode(GPIO.BCM) - self.buf = [0 for _ in range(28 * 8 * 2)] self._rotation = 0 for device, pin, offset in self.left_matrix, self.right_matrix: device.no_cs = True device.max_speed_hz = spi_max_speed_hz - GPIO.setup(pin, GPIO.OUT, initial=GPIO.HIGH) self.xfer(device, pin, [CMD_SOFT_RESET]) self.xfer(device, pin, [CMD_GLOBAL_BRIGHTNESS, 0x01]) self.xfer(device, pin, [CMD_SCROLL_CTRL, 0x00]) @@ -76,9 +70,7 @@ def _exit(self): self._shutdown() def xfer(self, device, pin, command): - GPIO.output(pin, GPIO.LOW) device.xfer2(command) - GPIO.output(pin, GPIO.HIGH) def set_pixel(self, x, y, r, g, b): """Set a single pixel.""" From 6a0a8f551b20ae164ab1ba6a4340554b478917d4 Mon Sep 17 00:00:00 2001 From: Kancelot To Date: Fri, 26 Sep 2025 21:02:11 +1000 Subject: [PATCH 2/2] Rely on spidev for chip select --- library/unicornhatmini/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/unicornhatmini/__init__.py b/library/unicornhatmini/__init__.py index bf42480..adf204c 100644 --- a/library/unicornhatmini/__init__.py +++ b/library/unicornhatmini/__init__.py @@ -47,7 +47,7 @@ def __init__(self, spi_max_speed_hz=600000): self._rotation = 0 for device, pin, offset in self.left_matrix, self.right_matrix: - device.no_cs = True + device.no_cs = False device.max_speed_hz = spi_max_speed_hz self.xfer(device, pin, [CMD_SOFT_RESET]) self.xfer(device, pin, [CMD_GLOBAL_BRIGHTNESS, 0x01])