File tree Expand file tree Collapse file tree 3 files changed +38
-7
lines changed Expand file tree Collapse file tree 3 files changed +38
-7
lines changed Original file line number Diff line number Diff line change 1
- """Eventual example for NeoPixel SPI"""
1
+ import time
2
+ import board
3
+ import neopixel_spi as neopixel
4
+
5
+ NUM_PIXELS = 12
6
+ PIXEL_ORDER = neopixel .GRB
7
+ COLORS = (0xFF0000 , 0x00FF00 , 0x0000FF )
8
+ DELAY = 0.1
9
+
10
+ spi = board .SPI ()
11
+
12
+ pixels = neopixel .NeoPixel_SPI (spi ,
13
+ NUM_PIXELS ,
14
+ pixel_order = PIXEL_ORDER ,
15
+ auto_write = False )
16
+
17
+ while True :
18
+ for color in COLORS :
19
+ for i in range (NUM_PIXELS ):
20
+ pixels [i ] = color
21
+ pixels .show ()
22
+ time .sleep (DELAY )
23
+ pixels .fill (0 )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 43
43
* Adafruit's Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
44
44
"""
45
45
46
+ # The following creates a mock neopixel_write module to allow importing
47
+ # the CircuitPython NeoPixel module without actually providing neopixel_write.
48
+ #pylint: disable=wrong-import-position
46
49
import sys
47
- sys .modules ['neopixel_write' ] = __import__ ('faux_write' )
50
+ from types import ModuleType
51
+ mock_neopixel_write = ModuleType ('mock_neopixel_write' )
52
+ exec ('def neopixel_write(): pass' , mock_neopixel_write .__dict__ )
53
+ sys .modules ['neopixel_write' ] = mock_neopixel_write
54
+ #pylint: enable=wrong-import-position
55
+
48
56
from neopixel import NeoPixel
49
57
50
58
__version__ = "0.0.0-auto.0"
60
68
GRBW = (1 , 0 , 2 , 3 )
61
69
"""Green Red Blue White"""
62
70
71
+ def neopixel_write ():
72
+ """This is a stub function to satisfy the base NeoPixel library.
73
+ It should never be called.
74
+ """
75
+ raise RuntimeError ("Function should never be called." )
76
+
63
77
class NeoPixel_SPI (NeoPixel ):
64
78
"""
65
79
A sequence of neopixels.
You can’t perform that action at this time.
0 commit comments