2
2
#
3
3
# Copyright (c) 2016 Damien P. George
4
4
# Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
5
+ # Copyright (c) 2019 Carter Nelson
6
+ # Copyright (c) 2019 Roy Hooper
5
7
#
6
8
# Permission is hereby granted, free of charge, to any person obtaining a copy
7
9
# of this software and associated documentation files (the "Software"), to deal
25
27
`neopixel` - NeoPixel strip driver
26
28
====================================================
27
29
28
- * Author(s): Damien P. George & Scott Shawcroft
30
+ * Author(s): Damien P. George, Scott Shawcroft, Carter Nelson, Roy Hooper
29
31
"""
30
32
31
- import math
32
-
33
33
try :
34
34
# imports needed for main NeoPixel class
35
35
import digitalio
59
59
60
60
61
61
class NeoPixel (_pixelbuf .PixelBuf ):
62
-
63
- bpp = None
64
- n = 0
65
62
"""
66
63
A sequence of neopixels.
67
64
@@ -102,17 +99,18 @@ class NeoPixel(_pixelbuf.PixelBuf):
102
99
pixels[::2] = [RED] * (len(pixels) // 2)
103
100
time.sleep(2)
104
101
"""
102
+
105
103
def __init__ (self , pin , n , * , bpp = 3 , brightness = 1.0 , auto_write = True , pixel_order = None ):
104
+ self .bpp = bpp
105
+ self .n = n
106
106
self ._configure (n , bpp , brightness , auto_write , pixel_order )
107
107
self .pin = digitalio .DigitalInOut (pin )
108
108
self .pin .direction = digitalio .Direction .OUTPUT
109
109
110
- def _configure (self , n , bpp = 3 , brightness = 1.0 , auto_write = True , pixel_order = None ):
111
- self .bpp = bpp
112
- self .n = n
110
+ def _configure (self , n , bpp = 3 , brightness = 1.0 , auto_write = True , pixel_order = None ): # pylint: disable=too-many-arguments
113
111
if not pixel_order :
114
112
pixel_order = GRB if bpp == 3 else GRBW
115
- else :
113
+ else :
116
114
self .bpp = bpp = len (pixel_order )
117
115
if isinstance (pixel_order , tuple ):
118
116
order_chars = RGBW
@@ -159,7 +157,7 @@ def show(self):
159
157
160
158
class NeoPixel_SPI (NeoPixel ):
161
159
"""
162
- A sequence of neopixels.
160
+ A sequence of neopixels using SPI .
163
161
164
162
:param ~busio.SPI spi: The SPI bus to output neopixel data on.
165
163
:param int n: The number of neopixels in the chain
@@ -180,7 +178,7 @@ class NeoPixel_SPI(NeoPixel):
180
178
pixels = neopixel.NeoPixel_SPI(board.SPI(), 10)
181
179
pixels.fill(0xff0000)
182
180
"""
183
- #pylint: disable=invalid-name, super-init-not-called
181
+ # pylint: disable=invalid-name, super-init-not-called, import-outside-toplevel
184
182
185
183
FREQ = 6400000 # 800kHz * 8, actual may be different
186
184
TRST = 80e-6 # Reset code low level time
0 commit comments