Skip to content

Commit 15fa250

Browse files
committed
updated
1 parent 2f5a479 commit 15fa250

File tree

2 files changed

+71
-48
lines changed

2 files changed

+71
-48
lines changed

README.md

Lines changed: 53 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ to MicroPython / Python 3 for the [DumbDisplay Android app](https://play.google.
77
For a video introduction, please watch the YouTube video: [Introducing DumbDisplay MicroPython Library --
88
with ESP32, Raspberry Pi Pico, and Raspberry Pi Zero](https://www.youtube.com/watch?v=KVU26FyXs5M)
99

10-
Although the porting is work in progress, nevertheless, most of the core of DumbDisplay functionalities have been ported.
10+
Although the porting is still work-in-progress, a large portion of the core of DumbDisplay functionalities have been ported.
1111
Hopefully, this should already be helpful for friends that develop programs for microcontroller boards in MicroPython.
1212

13-
As hinted previously, even DumbDisplay MicroPython Library is originally targeted for MicroPython, it should be useable with regular Python 3, like in Raspberry Pi environment
14-
or even with desktop / laptop.
15-
16-
Consequently, DumbDisplay MicroPython Library might be an alternative way to prototype simple Android app driven remotely with Python 3 from desktop / laptop, say for displaying experiment result data and getting simple interaction with the user.
13+
As hinted previously, even DumbDisplay MicroPython Library is originally targeted for MicroPython, it should be useable with regular Python 3, like in Raspberry Pi environment or even with desktop / laptop.
14+
Consequently, DumbDisplay MicroPython Library might be an alternative way to prototype simple Android app driven remotely with Python 3 from desktop / laptop, say for displaying experiment result data and getting simple interactions from the user.
1715

1816

1917
Enjoy
@@ -60,43 +58,46 @@ pip install git+https://github.com/trevorwslee/MicroPython-DumbDisplay
6058
6159
# Getting Started
6260
63-
The basic Python script setup is:
64-
1. import core, for creating `DumbDisplay` object
61+
To use DumbDisplay MicroPython Library, the basic Python script setup is:
62+
63+
1. Import core components, for creating `DumbDisplay` object
6564
<br>e.g.
6665
```
6766
from dumbdisplay.core import *
6867
dd = DumbDisplay()
6968
```
70-
- you can import the "core" components with ```from dumbdisplay.core import *```
71-
- or you can choose to import "all" components (including layers to be mentioned later) with ```from dumbdisplay.full import *```
72-
2. import IO mechanism, for creating IO object [to pass to DumbDisplay object], like
69+
- you can import the core components with ```from dumbdisplay.core import *```
70+
- or you can choose to import all components (including layers to be mentioned later) with ```from dumbdisplay.full import *```
71+
72+
2. Import IO mechanism, for creating IO object [to pass to DumbDisplay object] like
7373
<br>e.g.
7474
```
7575
from dumbdisplay.core import *
7676
from dumbdisplay.ios import *
77-
dd = DumbDisplay(io4Wifi("ssid", "password")) # the default is io4Inet()
77+
dd = DumbDisplay(io=io4Wifi("ssid", "password")) # the default is io4Inet()
7878
```
79-
- the default IO mechanism is `io4Inet()`, which uses Python networking support (not available for MicroPython)
80-
3. import layers, for creating layer objects [passing DumbDisplay object to them]
79+
- the default `io` is `io4Inet()`, which uses Python networking support (not available for MicroPython)
80+
81+
3. Import layer, for creating layer object [passing DumbDisplay object to it]
8182
<br>e.g.
8283
```
8384
from dumbdisplay.core import *
8485
from dumbdisplay.layer_ledgrid import *
8586
dd = DumbDisplay()
8687
l = LayerLedGrid(dd)
8788
```
88-
- you can choose to import "all" layers with ```from dumbdisplay.full import *```
89+
- you can choose to import all types of layers with ```from dumbdisplay.full import *```
8990
9091
9192
# More Details
9293
9394
## IO Mechanism
9495
95-
When create a `DumbDisplay` object, an IO object is needed (even though there is a default IO object)
96+
When create a `DumbDisplay` object, an IO object is needed
9697
- `io4Inet` (the default) -- Python networking support (not available for MicroPython)
9798
- `io4Wifi` -- MicroPython WiFi support (for Raspberry Pi Pico W, ESP32, etc.)
98-
- `io4Ble` -- MicroPython BLE support (for Raspberry Pi Pico W, ESP32, etc.)
9999
- `io4Uart` -- MicroPython UART support (for Raspberry Pi Pico W, ESP32, etc.)
100+
- `io4Ble` -- MicroPython BLE support (for ESP32, etc.)
100101
101102
E.g.
102103
```
@@ -107,78 +108,96 @@ dd = DumbDisplay(io4Wifi("ssid", "password"))
107108
108109
## Layers
109110
110-
Other then the `DumbDisplay`, you will need to create one or more layer objects to represent the UI:
111-
- `LayerLedGrid` -- a single LED, or a grid of multiple LEDs (**n** columns by **m** rows)
112-
<br>e.g.
111+
Other then the `DumbDisplay` object, you will need to create one or more layer objects to represent the visible portion of the UI:
112+
113+
- `LayerLedGrid` -- a single LED, or a row / column / grid of multiple LEDs (**n** columns by **m** rows)
113114
```
114115
from dumbdisplay.core import *
115116
from dumbdisplay.layer_ledgrid import *
116117
dd = DumbDisplay()
117118
l = LayerLedGrid(dd)
118119
```
120+
example:
119121
|[`demo_LayerLedGrid()` in `dd_demo.py`](dd_demo.py)|
120122
|:--:|
121123
|<img style="width: 300px; height: 300px;" src="screenshots/layer_ledgrid_2x2.png"></img>|
122124
123125
- `LayerLcd` -- a TEXT based LCD with configurable number of lines of configurable number of characters
124-
<br>e.g.
125126
```
126127
from dumbdisplay.core import *
127128
from dumbdisplay.layer_lcd import *
128129
dd = DumbDisplay()
129130
l = LayerLcd(dd)
130131
```
132+
133+
example:
131134
|[`demo_LayerLcd()` in `dd_demo.py`](dd_demo.py)|
132135
|:--:|
133136
|<img style="width: 300px; height: 300px;" src="screenshots/layer_lcd.png"></img>|
134137
135-
- `LayerGraphical` -- a graphical LCD that you can draw to, with common drawing operations
136-
<br>e.g.
138+
- `LayerGraphical` -- a graphical LCD that you can draw to with common drawing directives
137139
```
138140
from dumbdisplay.core import *
139141
from dumbdisplay.layer_graphical import *
140142
dd = DumbDisplay()
141143
l = LayerGraphical(dd)
142144
```
145+
146+
example:
143147
|[`demo_LayerGraphical()` in `dd_demo.py`](dd_demo.py)|
144148
|:--:|
145149
|<img style="width: 300px; height: 300px;" src="screenshots/layer_graphical.png"></img>|
146150
147-
- `LayerSelection` -- a group / grid of TEXT based LCD mostly for showing selection choices
148-
<br>e.g.
151+
- `LayerSelection` -- a row / column / grid of TEXT based LCDs mostly for showing selection choices
149152
```
150153
from dumbdisplay.core import *
151154
from dumbdisplay.layer_selection import *
152155
dd = DumbDisplay()
153156
l = LayerSelection(dd)
154157
```
158+
159+
example:
155160
|[`demo_LayerSelection()` in `dd_demo.py`](dd_demo.py)|
156161
|:--:|
157162
|<img style="width: 300px; height: 300px;" src="screenshots/layer_selection_1x3.png"></img>|
158163
159164
- `Layer7SegmentRow` -- a single 7-segment digit, or a row of **n** 7-segments digits
160-
<br>e.g.
161165
```
162166
from dumbdisplay.core import *
163167
from dumbdisplay.layer_7segrow import *
164168
dd = DumbDisplay()
165169
l = Layer7SegmentRow(dd)
166170
```
171+
172+
example:
167173
|[`demo_Layer7SegmentRow()` in `dd_demo.py`](dd_demo.py)|
168174
|:--:|
169175
|<img style="width: 300px; height: 300px;" src="screenshots/layer_7segment_3d.png"></img>|
170176
171-
- `LayerPlotter` -- a "plotter"
172-
<br>e.g.
177+
- `LayerPlotter` -- a "plotter" for plotting real-time data
173178
```
174179
from dumbdisplay.core import *
175180
from dumbdisplay.layer_plotter import *
176181
dd = DumbDisplay()
177182
l = LayerPlotter(dd)
178183
```
184+
185+
example:
179186
|[`demo_LayerPlotter()` in `dd_demo.py`](dd_demo.py)|
180187
|:--:|
181188
|<img style="width: 300px; height: 300px;" src="screenshots/layer_plotter.png"></img>|
189+
190+
as shown in th example, two types of data are fed to the plotter -- `X` and `Sin`
191+
```
192+
l.label("X", sin="Sin")
193+
```
194+
And the real-time values of `X` and `Sin` are fed like
195+
```
196+
for x in range(1000):
197+
sin = math.sin(x)
198+
l.set(x, sin=sin)
199+
time.sleep(0.8)
200+
```
182201
183202
- `LayerJoystick` -- a joystick; also can be a horizontal or vertical slider
184203
```
@@ -187,11 +206,12 @@ Other then the `DumbDisplay`, you will need to create one or more layer objects
187206
dd = DumbDisplay()
188207
l = LayerJoystick(dd)
189208
```
209+
190210
|[`demo_LayerJoystick()` in `dd_demo.py`](dd_demo.py)|
191211
|:--:|
192-
|<img style="width: 300px; height: 300px;" src="screenshots/layer_joystick.png"></img>|
212+
|<img style="width: 300px; height: 300px;" src="screenshots/layer_joystick.png"></img>|
193213
194-
As shown in the example
214+
as shown in the example
195215
* you can configure the joystick to be a horizontal or vertical slider by changing the `directions` parameter to `LayerJoystick`
196216
- param `maxStickValue`: the max value of the stick; e.g. 255 or 1023 (the default); min is 15
197217
- param `directions`: "lr" or "hori": left-to-right; "tb" or "vert": top-to-bottom; "rl": right-to-left; "bt": bottom-to-top;
@@ -207,11 +227,11 @@ Other then the `DumbDisplay`, you will need to create one or more layer objects
207227
## Auto-Pinning of Layers
208228
209229
In case of multiple layers, you can "auto pin" them together; otherwise, multiple layers will be stacked on top of each other
210-
211-
E.g.
212230
```
213231
AutoPin('V', AutoPin('H', l_ledgrid, l_lcd), AutoPin('H', l_selection, l_7segmentrow), l_graphical).pin(dd)
214232
```
233+
234+
Example:
215235
|[`demo_AutoPin()` in `dd_demo.py`](dd_demo.py)|
216236
|:--:|
217237
|<img style="width: 400px; height: 400px;" src="screenshots/autopin_layers.png"></img>|
@@ -272,14 +292,14 @@ Please take [`demo_Feedback_callback()` in `dd_demo.py`](dd_demo.py) as an examp
272292
273293
# Selected Demos
274294
275-
Here is a few Raspberry Pi Pico PIO demos that might interest you
295+
Here are two Raspberry Pi Pico PIO demos
276296
277297
|[Respberry Pi Pico W Generating Tones With Programmable I/O (PIO) Using MicroPython](https://www.instructables.com/Respberry-Pi-Pico-W-Generating-Tones-With-Programm/)|[Respberry Pi Pico W NeoPixels Experiments With Programmable I/O (PIO) Using MicroPython](https://www.instructables.com/Respberry-Pi-Pico-W-NeoPixels-Experiments-With-Pro/)|
278298
|--|--|
279299
|![](screenshots/u_melody_dd.jpg)|![](screenshots/u_neopixeldd_dd.jpg)|
280300
281301
282-
[`PyTorchIntroductoryExperiments`](https://github.com/trevorwslee/PyTorchIntroductoryExperiments) shows two regular Python 3 demos that might interest you
302+
[`PyTorchIntroductoryExperiments`](https://github.com/trevorwslee/PyTorchIntroductoryExperiments) shows two regular Python 3 demos
283303
284304
|||
285305
|--|--|

dd_demo.py

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -291,18 +291,21 @@ def run_mnist_app():
291291

292292

293293
if __name__ == "__main__":
294-
# demo_LayerLedGrid(2, 2)
295-
# demo_LayerLcd()
296-
# demo_LayerGraphical()
297-
# demo_Layer7SegmentRow()
298-
# demo_LayerSelection()
299-
# demo_LayerPlotter()
300-
demo_LayerJoystick(directions="") # directions can be "", "lr" or "tb"
301-
302-
# demo_AutoPin()
303-
# demo_Feedback()
304-
# demo_Feedback_callback()
305-
306-
# run_passive_blink_app()
307-
# run_sliding_puzzle_app()
308-
# run_mnist_app()
294+
demo_Feedback()
295+
296+
if True:
297+
demo_LayerLedGrid(2, 2)
298+
demo_LayerLcd()
299+
demo_LayerGraphical()
300+
demo_Layer7SegmentRow()
301+
demo_LayerSelection()
302+
demo_LayerPlotter()
303+
demo_LayerJoystick(directions="") # directions can be "", "lr" or "tb"
304+
305+
demo_AutoPin()
306+
demo_Feedback()
307+
demo_Feedback_callback()
308+
309+
run_passive_blink_app()
310+
run_sliding_puzzle_app()
311+
run_mnist_app()

0 commit comments

Comments
 (0)