Skip to content

Some fixes #6

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

Merged
merged 5 commits into from
Dec 15, 2019
Merged
Show file tree
Hide file tree
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
24 changes: 23 additions & 1 deletion examples/neopixel_spi_simpletest.py
Original file line number Diff line number Diff line change
@@ -1 +1,23 @@
"""Eventual example for NeoPixel SPI"""
import time
import board
import neopixel_spi as neopixel

NUM_PIXELS = 12
PIXEL_ORDER = neopixel.GRB
COLORS = (0xFF0000, 0x00FF00, 0x0000FF)
DELAY = 0.1

spi = board.SPI()

pixels = neopixel.NeoPixel_SPI(spi,
NUM_PIXELS,
pixel_order=PIXEL_ORDER,
auto_write=False)

while True:
for color in COLORS:
for i in range(NUM_PIXELS):
pixels[i] = color
pixels.show()
time.sleep(DELAY)
pixels.fill(0)
12 changes: 11 additions & 1 deletion neopixel_spi.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
"""

# The following creates a mock neopixel_write module to allow importing
# the CircuitPython NeoPixel module without actually providing neopixel_write.
#pylint: disable=wrong-import-position, exec-used
import sys
from types import ModuleType
MOCK_MODULE = ModuleType('mock_neopixel_write')
exec('def neopixel_write(): pass', MOCK_MODULE.__dict__)
sys.modules['neopixel_write'] = MOCK_MODULE
#pylint: enable=wrong-import-position, exec-used

from neopixel import NeoPixel

__version__ = "0.0.0-auto.0"
Expand Down Expand Up @@ -96,7 +106,7 @@ def __init__(self, spi, n, *, bpp=3, brightness=1.0, auto_write=True, pixel_orde
except AttributeError:
# use nominal
freq = self.FREQ
self.RESET = bytes([0]*round(freq*self.TRST))
self.RESET = bytes([0]*round(freq * self.TRST / 8))
self.n = n
if pixel_order is None:
self.order = GRBW
Expand Down