Skip to content

Commit 2353b2d

Browse files
authored
Merge pull request #6 from trevorwslee/develop
going for v0.3.0
2 parents ae56dea + b2694cd commit 2353b2d

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

samples/neopixels/main.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
import time
2-
3-
41
NUM_PIXELS = 4
52
NEO_PIXELS_IN_PIN = 22
63

74
try:
85

6+
# set to True if don't want to use PIO
97
if False:
108
raise Exception("I don't want to use PIO")
119

@@ -74,7 +72,7 @@ def ShowNeoPixels(*pixels):
7472

7573

7674
if ShowNeoPixels is None:
77-
75+
# in case cannot / wouldn't drive NeoPixels with PIO, define an adapter here to use the standard APIs
7876
try:
7977
from machine import Pin
8078
from neopixel import NeoPixel
@@ -92,9 +90,9 @@ def ShowNeoPixels(*pixels):
9290
except:
9391
ShowNeoPixels = None
9492

95-
Pixels = []
96-
for i in range(NUM_PIXELS):
97-
Pixels.append(None)
93+
94+
Pixels = [None] * NUM_PIXELS
95+
9896

9997
from dumbdisplay.core import *
10098
from dumbdisplay.layer_lcd import *
@@ -130,15 +128,17 @@ def ShowNeoPixels(*pixels):
130128
advance_button.writeCenteredLine(">>>")
131129
advance_button.enableFeedback("fl")
132130

133-
131+
# create 7-seg layer for the R HEX value
134132
r_7seg_layer = Layer7SegmentRow(dd,2)
135133
r_7seg_layer.border(10, "black")
136134
r_7seg_layer.backgroundColor("white", 50)
137135

136+
# create 7-seg layer for the G HEX value
138137
g_7seg_layer = Layer7SegmentRow(dd,2)
139138
g_7seg_layer.border(10, "black")
140139
g_7seg_layer.backgroundColor("white", 50)
141140

141+
# create 7-seg layer for the B HEX value
142142
b_7seg_layer = Layer7SegmentRow(dd,2)
143143
b_7seg_layer.border(10, "black")
144144
b_7seg_layer.backgroundColor("white", 50)
@@ -254,6 +254,7 @@ def ShowNeoPixels(*pixels):
254254
if r != old_r or g != old_g or b != old_b:
255255
# set the background color of the color layer to the new (r, g, b) color
256256
color_layer.backgroundColor(RGB_COLOR(r, g, b))
257+
# shows the R/G/B values on the 7-seg layers
257258
r_7seg_layer.showHexNumber(r)
258259
g_7seg_layer.showHexNumber(g)
259260
b_7seg_layer.showHexNumber(b)

0 commit comments

Comments
 (0)