@@ -63,15 +63,36 @@ def ShowNeoPixels(*pixels):
6363 sm .put (grb , 8 ) # a word is 32 bits, so, pre-shift out (discard) 8 bits, leaving 24 bits of the GRB
6464 time .sleep_us (300 ) # make sure the NeoPixels is reset for the next round
6565
66- Pixels = []
67- for i in range (NUM_PIXELS ):
68- Pixels .append (None )
66+ print ("PIO ready!" )
6967
7068except :
71- print ( "Cannot initialize NeoPixels!" )
72- Pixels = None
69+ ShowNeoPixels = None
70+ print ( "PIO not supported!" )
7371
7472
73+ if ShowNeoPixels is None :
74+
75+ try :
76+ from machine import Pin
77+ from neopixel import NeoPixel
78+
79+ np = NeoPixel (Pin (NEO_PIXELS_IN_PIN ), NUM_PIXELS )
80+
81+ def ShowNeoPixels (* pixels ):
82+ pixel_count = len (pixels )
83+ for i in range (pixel_count ):
84+ pixel = pixels [i ]
85+ if not pixel :
86+ pixel = (0 , 0 , 0 )
87+ np [i ] = pixel
88+ np .write ()
89+ except :
90+ ShowNeoPixels = None
91+
92+ Pixels = []
93+ for i in range (NUM_PIXELS ):
94+ Pixels .append (None )
95+
7596from dumbdisplay .core import *
7697from dumbdisplay .layer_lcd import *
7798from dumbdisplay .layer_graphical import *
@@ -160,11 +181,6 @@ def ShowNeoPixels(*pixels):
160181b_7seg_layer .showHexNumber (b )
161182color_layer .backgroundColor (RGB_COLOR (r , g , b ))
162183
163- if Pixels is None :
164- auto_advance_tab .disabled (True )
165- advance_button .disabled (True )
166-
167-
168184last_ms = time .ticks_ms ()
169185
170186while True :
@@ -200,7 +216,7 @@ def ShowNeoPixels(*pixels):
200216 # if advance button is clicked (has "feedback"), advance the colors of the pixels
201217 advance = True
202218
203- if Pixels :
219+ if ShowNeoPixels is not None :
204220 if advance :
205221 # shift pixels colors ... the 1st one will then be set to the color of (r, g, b)
206222 for i in range (NUM_PIXELS - 1 , 0 , - 1 ):
0 commit comments