Skip to content

Commit 007ef35

Browse files
authored
Merge pull request #12 from trevorwslee/develop
Develop
2 parents 4a4760e + e9da424 commit 007ef35

18 files changed

+247
-52
lines changed

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@
1010
/experiments/pyclock
1111

1212

13-
#/_test.py
14-
#/_test.ipynb
13+
#/_dev_test.py
14+
#/_dev_test.ipynb
1515
/.micropico
1616
/_my_secret.py
1717

18+
uDumbDisplay.code-workspace

MicroPythonDumbDisplay.code-workspace

Lines changed: 0 additions & 14 deletions
This file was deleted.

README.md

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

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

12-
As hinted previously, even it is originally targeted for MicroPython, it should be useful with regular Python 3, like in Raspberry Pi environment
12+
As hinted previously, even it is originally targeted for Micro-Python, it should be useful with regular Python 3, like in Raspberry Pi environment
1313
or even with desktop / laptop.
14-
As a result, it can be an alternative way to prototype Android app driven remotely with Python 3 from desktop / laptop.
14+
Consequently, it 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.
1515

1616

1717
Enjoy
1818

1919
- [DumbDisplay MicroPython Library (v0.5.0)](#dumbdisplay-micropython-library-v050)
2020
- [Installation](#installation)
2121
- [Getting Started](#getting-started)
22+
- [Examples](#examples)
23+
- [DumbDisplay `io` Object](#dumbdisplay-io-object)
24+
- [Layer Feedback](#layer-feedback)
25+
- [Auto-pin Layers](#auto-pin-layers)
2226
- [Selected Demos](#selected-demos)
2327
- [Thank You!](#thank-you)
2428
- [License](#license)
@@ -77,6 +81,10 @@ The basic Python script setup is:
7781
dd = DumbDisplay()
7882
l = LayerLedGrid(dd)
7983
```
84+
|[`demo_LayerLedGrid()` in `dd_demo.py`](dd_demo.py)|
85+
|:--:|
86+
|<img style="width: 300px; height: 300px;" src="screenshots/layer_ledgrid_2x2.png"></img>|
87+
8088
- `LayerLcd` -- a TEXT based LCD with configurable number of lines of configurable number of characters
8189
<br>e.g.
8290
```
@@ -85,6 +93,10 @@ The basic Python script setup is:
8593
dd = DumbDisplay()
8694
l = LayerLcd(dd)
8795
```
96+
|[`demo_LayerLcd()` in `dd_demo.py`](dd_demo.py)|
97+
|:--:|
98+
|<img style="width: 300px; height: 300px;" src="screenshots/layer_lcd.png"></img>|
99+
88100
- `LayerGraphical` -- a graphical LCD that you can draw to, with common drawing operations
89101
<br>e.g.
90102
```
@@ -93,6 +105,10 @@ The basic Python script setup is:
93105
dd = DumbDisplay()
94106
l = LayerGraphical(dd)
95107
```
108+
|[`demo_LayerGraphical()` in `dd_demo.py`](dd_demo.py)|
109+
|:--:|
110+
|<img style="width: 300px; height: 300px;" src="screenshots/layer_graphical.png"></img>|
111+
96112
- `LayerSelection` -- a group / grid of TEXT based LCD mostly for showing selection choices
97113
<br>e.g.
98114
```
@@ -101,6 +117,10 @@ The basic Python script setup is:
101117
dd = DumbDisplay()
102118
l = LayerSelection(dd)
103119
```
120+
|[`demo_LayerSelection()` in `dd_demo.py`](dd_demo.py)|
121+
|:--:|
122+
|<img style="width: 300px; height: 300px;" src="screenshots/layer_selection_1x3.png"></img>|
123+
104124
- `Layer7SegmentRow` -- a single 7-segment digit, or a row of **n** 7-segments digits
105125
<br>e.g.
106126
```
@@ -109,6 +129,10 @@ The basic Python script setup is:
109129
dd = DumbDisplay()
110130
l = Layer7SegmentRow(dd)
111131
```
132+
|[`demo_Layer7SegmentRow()` in `dd_demo.py`](dd_demo.py)|
133+
|:--:|
134+
|<img style="width: 300px; height: 300px;" src="screenshots/layer_7segment_3d.png"></img>|
135+
112136
- `LayerPlotter` -- a "plotter"
113137
<br>e.g.
114138
```
@@ -117,8 +141,25 @@ The basic Python script setup is:
117141
dd = DumbDisplay()
118142
l = LayerPlotter(dd)
119143
```
144+
|[`demo_LayerPlotter()` in `dd_demo.py`](dd_demo.py)|
145+
|:--:|
146+
|<img style="width: 300px; height: 300px;" src="screenshots/layer_plotter.png"></img>|
147+
148+
4. if you have multiple layers, you can "auto pin" them together; otherwise, multiple layers will be stacked on top of each other
149+
<br>e.g.
150+
```
151+
AutoPin('V', AutoPin('H', l_ledgrid, l_lcd), AutoPin('H', l_selection, l_7segmentrow), l_graphical).pin(dd)
152+
```
153+
|[`demo_AutoPin()` in `dd_demo.py`](dd_demo.py)|
154+
|:--:|
155+
|<img style="width: 400px; height: 400px;" src="screenshots/autopin_layers.png"></img>|
156+
157+
158+
# Examples
120159
121160
161+
## DumbDisplay `io` Object
162+
122163
For example (using Python networking support with `io4Inet` as `io` for the DumbDisplay object)
123164
```
124165
from dumbdisplay.core import *
@@ -148,7 +189,10 @@ dd.writeComment("DONE")
148189
```
149190
150191
151-
A simple sample that polls for feedbacks, can be like
192+
## Layer Feedback
193+
194+
195+
A simple sample that polls for feedback (say user pressing the layer) from a layer, can be like
152196
```
153197
from dumbdisplay.core import *
154198
from dumbdisplay.io_inet import *
@@ -164,6 +208,10 @@ while True:
164208
l.toggle(feedback.x, feedback.y)
165209
```
166210
211+
212+
## Auto-pin Layers
213+
214+
167215
A more complete simple sample that also shows "auto pin" as well, can be like
168216
```
169217
from dumbdisplay.core import *
File renamed without changes.

_test.py renamed to _dev_test.py

Lines changed: 19 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,18 @@
33
import math
44

55

6-
from dumbdisplay.core import *
76
from dumbdisplay_examples.utils import create_example_wifi_dd
87

98

9+
1010
def run_debug():
11-
#import projects.testing.main as test
1211
import experiments.testing.main as test
1312
test.runDebug()
1413

14+
def run_debugBlepriority(ble_name: str):
15+
import experiments.testing.main as test
16+
test.runDebugBlePriority(ble_name)
17+
1518
def run_doodle():
1619
import samples.doodle.main
1720

@@ -22,34 +25,9 @@ def run_melody():
2225
import samples.melody.main
2326

2427

25-
def test_very_simple():
26-
#import time
27-
from dumbdisplay.layer_ledgrid import LayerLedGrid
28-
dd = DumbDisplay() # default io is io4Inet()
29-
l = LayerLedGrid(dd, 2, 1)
30-
l.offColor("green")
31-
l.turnOn()
32-
for _ in range(1000):
33-
time.sleep(1)
34-
l.toggle(0, 0)
35-
l.toggle(1, 0)
36-
dd.writeComment("DONE")
37-
38-
39-
def test_plotter():
40-
from dumbdisplay.layer_plotter import LayerPlotter
41-
dd = DumbDisplay() # default io is io4Inet()
42-
l = LayerPlotter(dd, 300, 100)
43-
l.label("X", sin="Sin")
44-
for x in range(1000):
45-
sin = math.sin(x)
46-
l.set(x, sin=sin)
47-
time.sleep(0.5)
48-
49-
5028
def test_margin():
5129
from dumbdisplay.layer_ledgrid import LayerLedGrid
52-
dd = DumbDisplay() # default io is io4Inet()
30+
dd = create_example_wifi_dd()
5331
l = LayerLedGrid(dd)
5432
dd.backgroundColor("yellow")
5533
l.backgroundColor("pink")
@@ -59,7 +37,7 @@ def test_margin():
5937
l.margin(0.4, 0.3, 0.2, 0.1)
6038
while True:
6139
print("... ", end="")
62-
dd.timeslice()
40+
dd.sleep(1)
6341
print("...")
6442
if dd.isReconnecting():
6543
break # since haven't setup for reconnection (like with recordLayerSetupCommands) ... may as well break out of the loop
@@ -103,18 +81,27 @@ def test_find_packages():
10381

10482

10583
if __name__ == "__main__":
84+
#test_LayerLedGrid(2, 2)
85+
#test_LayerLcd()
86+
#test_LayerGraphical()
87+
#test_Layer7SegmentRow()
88+
#test_LayerSelection()
89+
#test_LayerPlotter()
90+
91+
test_AutoPin()
92+
10693
#run_passive_blink_app()
10794
#run_sliding_puzzle_app()
108-
run_mnist_app()
95+
#run_mnist_app()
10996

11097
#run_debug()
11198
#run_doodle()
11299
#run_graphical()
113100
#run_melody()
114101

115102
#test_margin()
116-
#test_very_simple()
117-
#test_plotter()
103+
104+
#run_debugBlepriority("MyBLEDevice")
118105

119106
#test_read_readme()
120107
#test_find_packages()

0 commit comments

Comments
 (0)