Skip to content

Commit ce73a85

Browse files
committed
going for v0.3.0
1 parent 4bf0345 commit ce73a85

3 files changed

Lines changed: 45 additions & 28 deletions

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# DumbDisplay MicroPython Library (v0.3.0)
1+
# DumbDisplay MicroPython Library (v0.3.1)
22

33
DumbDisplay MicroPython Library is a port of the [DumbDisplay Arduino Library](https://github.com/trevorwslee/Arduino-DumbDisplay)
44
for the [DumbDisplay Android app](https://play.google.com/store/apps/details?id=nobody.trevorlee.dumbdisplay)
@@ -126,6 +126,9 @@ Notes:
126126
127127
# Change History
128128
129+
v0.3.1
130+
- added LayerJoystick
131+
129132
v0.3.0
130133
- checked Raspberry Pi Pico W WIFI support
131134
- ported more options from Arduino DumbDisplay library

dumbdisplay/_ddimpl.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,9 @@ def _checkForFeedback(self):
278278
feedback = self._readFeedback()
279279
if feedback is not None:
280280
if len(feedback) > 0:
281+
self._onFeedbackSignal()
281282
if feedback[0:1] == '<':
282-
self._onFeedbackKeepAlive()
283+
#self._onFeedbackKeepAlive()
283284
if len(feedback) == 1:
284285
pass
285286
#self._onFeedbackKeepAlive()
@@ -339,7 +340,7 @@ def _readFeedback(self) -> str:
339340
feedback = self._connected_iop.read()
340341
#self._connected_iop.clear()
341342
return feedback
342-
def _onFeedbackKeepAlive(self):
343+
def _onFeedbackSignal(self):
343344
if self._connected_iop:
344345
self._connected_iop.keepAlive()
345346
def _validateConnection(self):

samples/neopixels/main.py

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,12 @@ def ShowNeoPixels(*pixels):
9494

9595
import time
9696

97+
# crate a tab (LayerLcd) to control whether auto advance the pixel's color from the previous pixel to the next pixel
98+
auto_advance_tab = LayerLcd(dd, 12, 1)
99+
auto_advance_tab.writeCenteredLine("Auto Advance")
100+
auto_advance_tab.enableFeedback("fl")
97101

98-
auto_advance_button = LayerLcd(dd, 12, 1)
99-
auto_advance_button.writeCenteredLine("Auto Advance")
100-
auto_advance_button.enableFeedback("fl")
101-
102+
# crate a button (LayerLcd) to manually advance the pixel's color from the previous pixel to the next pixel
102103
advance_button = LayerLcd(dd, 3, 1)
103104
advance_button.border(1, "blue", "round")
104105
advance_button.writeCenteredLine(">>>")
@@ -124,16 +125,15 @@ def ShowNeoPixels(*pixels):
124125
b_slider_layer.border(3, "darkblue", "round", 1)
125126
b_slider_layer.colors("blue", RGB_COLOR(0x44, 0x44, 0xff), "black", "darkgray")
126127

127-
# auto "pin" the above layers vertically
128+
# auto "pin" the above layers
128129
AutoPin('V',
129-
AutoPin('H', auto_advance_button, advance_button),
130-
color_layer,
131-
r_slider_layer,
132-
g_slider_layer,
133-
b_slider_layer).pin(dd)
130+
AutoPin('H', auto_advance_tab, advance_button),
131+
color_layer,
132+
r_slider_layer,
133+
g_slider_layer,
134+
b_slider_layer).pin(dd)
134135

135136
auto_advance = None
136-
137137
r = 0
138138
g = 0
139139
b = 0
@@ -142,29 +142,35 @@ def ShowNeoPixels(*pixels):
142142

143143
while True:
144144

145-
if auto_advance is None or auto_advance_button.getFeedback():
145+
if auto_advance is None or auto_advance_tab.getFeedback():
146+
# if it is not initialized, or if auto advance tab is clicked (has "feedback"), set auto advance accordingly
146147
if auto_advance is None:
147-
auto_advance = True
148+
auto_advance = False # initially, manual advance
148149
else:
149150
auto_advance = not auto_advance
151+
# set auto advance tab's border, pixel color and background pixel color according to whether auto advance is on or off
150152
if auto_advance:
151-
auto_advance_button.border(1, "blue", "round")
152-
auto_advance_button.pixelColor("red")
153-
auto_advance_button.bgPixelColor("green")
153+
auto_advance_tab.border(1, "blue", "round")
154+
auto_advance_tab.pixelColor("red")
155+
auto_advance_tab.bgPixelColor("green")
154156
advance_button.disabled(True)
155157
else:
156-
auto_advance_button.border(1, "blue", "hair")
157-
auto_advance_button.pixelColor("darkgray")
158-
auto_advance_button.bgPixelColor("gray")
158+
auto_advance_tab.border(1, "blue", "hair")
159+
auto_advance_tab.pixelColor("darkgray")
160+
auto_advance_tab.bgPixelColor("gray")
159161
advance_button.disabled(False)
162+
160163
advance = False
161164
if auto_advance:
165+
# check if need to auto advance the colors of the pixels
162166
diff_ms = time.ticks_ms() - last_ms
163167
if diff_ms >= 200:
168+
# if it has been 200ms, auto advance the colors of the pixels
164169
advance = True
165170
last_ms = time.ticks_ms()
166171
else:
167172
if advance_button.getFeedback():
173+
# if advance button is clicked (has "feedback"), advance the colors of the pixels
168174
advance = True
169175

170176
if Pixels:
@@ -190,16 +196,23 @@ def ShowNeoPixels(*pixels):
190196
if fb:
191197
# if there is "feedback" from the B slider, its x position will be the new value for b
192198
b = fb.x
199+
200+
sync_sliders = False
193201
fb: Feedback = color_layer.getFeedback()
194202
if fb:
203+
# if there is "feedback" from the color layer, its x position will be the new value for r, and its y position will be the new value for g
195204
r = fb.x
196205
g = fb.y
206+
sync_sliders = True
207+
197208
if r != old_r or g != old_g or b != old_b:
198209
# set the background color of the color layer to the new (r, g, b) color
199210
color_layer.backgroundColor(RGB_COLOR(r, g, b))
200-
if r != old_r:
201-
r_slider_layer.moveToPos(r, 0)
202-
if g != old_g:
203-
g_slider_layer.moveToPos(g, 0)
204-
if b != old_b:
205-
b_slider_layer.moveToPos(b, 0)
211+
if sync_sliders:
212+
# check to see if RGB needs to be synced with the sliders
213+
if r != old_r:
214+
r_slider_layer.moveToPos(r, 0)
215+
if g != old_g:
216+
g_slider_layer.moveToPos(g, 0)
217+
if b != old_b:
218+
b_slider_layer.moveToPos(b, 0)

0 commit comments

Comments
 (0)