Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions library/unicornhatmini/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

from colorsys import hsv_to_rgb

import RPi.GPIO as GPIO

__version__ = '0.0.2'


Expand Down Expand Up @@ -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.no_cs = False
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])
Expand All @@ -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."""
Expand Down