Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

try to import bitbangio if busio SPI is not available #40

Open
wants to merge 1 commit into
base: master
from
Open
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -85,17 +85,23 @@ def __init__(self, clock, data, n, *, brightness=1.0, auto_write=True,
pixel_order=BGR, baudrate=4000000):
self._spi = None
try:
self._spi = busio.SPI(clock, MOSI=data)
try:
self._spi = busio.SPI(clock, MOSI=data)
except (NotImplementedError, ValueError):
import bitbangio
self._spi = bitbangio.SPI(clock, MOSI=data)

while not self._spi.try_lock():
pass
self._spi.configure(baudrate=baudrate)

except (NotImplementedError, ValueError):
except (NotImplementedError, ValueError, ImportError):
self.dpin = digitalio.DigitalInOut(data)
self.cpin = digitalio.DigitalInOut(clock)
self.dpin.direction = digitalio.Direction.OUTPUT
self.cpin.direction = digitalio.Direction.OUTPUT
self.cpin.value = False

self._n = n
# Supply one extra clock cycle for each two pixels in the strip.
self.end_header_size = n // 16
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.