Skip to content

Commit

Permalink
Support multiple SPI devices when using hardware mode
Browse files Browse the repository at this point in the history
  • Loading branch information
LoganK committed Feb 3, 2018
1 parent 2102ea0 commit b244e1c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion apa102.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ def __init__(self,
order='rgb',
mosi=10,
sclk=11,
bus=0,
device=0,
max_speed_hz=8000000,
led_order=None):
"""Initializes the library."""
Expand All @@ -151,7 +153,7 @@ def __init__(self,
import Adafruit_GPIO.SPI as SPI
# MOSI 10 and SCLK 11 is hardware SPI, which needs to be set-up differently
if mosi == 10 and sclk == 11:
self.spi = SPI.SpiDev(0, 0, max_speed_hz) # Bus 0, chip select 0
self.spi = SPI.SpiDev(bus, device, max_speed_hz)
else:
import Adafruit_GPIO as GPIO
self.spi = SPI.BitBang(GPIO.get_platform_gpio(), sclk, mosi)
Expand Down

0 comments on commit b244e1c

Please sign in to comment.