Skip to content

Commit 4b997ee

Browse files
committed
updated
1 parent 77d12d2 commit 4b997ee

18 files changed

Lines changed: 230 additions & 49 deletions

.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
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

MicroPythonDumbDisplay.code-workspace

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

README.md

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ or even with desktop / laptop.
1414
As a result, it can be an alternative way to prototype Android app driven remotely with Python 3 from desktop / laptop.
1515

1616

17-
Enjoy
17+
Enjoyz
1818

1919
- [DumbDisplay MicroPython Library (v0.5.0)](#dumbdisplay-micropython-library-v050)
2020
- [Installation](#installation)
@@ -77,6 +77,10 @@ The basic Python script setup is:
7777
dd = DumbDisplay()
7878
l = LayerLedGrid(dd)
7979
```
80+
|[`demo_LayerLedGrid()` in `dd_demo.py`](dd_demo.py)|
81+
|--|
82+
|<img style="width: 200px; height: 200px;" src="screenshots/layer_ledgrid_2x2.png"></img>|
83+
8084
- `LayerLcd` -- a TEXT based LCD with configurable number of lines of configurable number of characters
8185
<br>e.g.
8286
```
@@ -85,6 +89,10 @@ The basic Python script setup is:
8589
dd = DumbDisplay()
8690
l = LayerLcd(dd)
8791
```
92+
|[`demo_LayerLcd()` in `dd_demo.py`](dd_demo.py)|
93+
|--|
94+
|<img style="width: 200px; height: 200px;" src="screenshots/layer_lcd.png"></img>|
95+
8896
- `LayerGraphical` -- a graphical LCD that you can draw to, with common drawing operations
8997
<br>e.g.
9098
```
@@ -93,6 +101,10 @@ The basic Python script setup is:
93101
dd = DumbDisplay()
94102
l = LayerGraphical(dd)
95103
```
104+
|[`demo_LayerGraphical()` in `dd_demo.py`](dd_demo.py)|
105+
|--|
106+
|<img style="width: 200px; height: 200px;" src="screenshots/layer_graphical.png"></img>|
107+
96108
- `LayerSelection` -- a group / grid of TEXT based LCD mostly for showing selection choices
97109
<br>e.g.
98110
```
@@ -101,6 +113,10 @@ The basic Python script setup is:
101113
dd = DumbDisplay()
102114
l = LayerSelection(dd)
103115
```
116+
|[`demo_LayerSelection()` in `dd_demo.py`](dd_demo.py)|
117+
|--|
118+
|<img style="width: 200px; height: 200px;" src="screenshots/layer_selection_1x3.png"></img>|
119+
104120
- `Layer7SegmentRow` -- a single 7-segment digit, or a row of **n** 7-segments digits
105121
<br>e.g.
106122
```
@@ -109,6 +125,10 @@ The basic Python script setup is:
109125
dd = DumbDisplay()
110126
l = Layer7SegmentRow(dd)
111127
```
128+
|[`demo_Layer7SegmentRow()` in `dd_demo.py`](dd_demo.py)|
129+
|--|
130+
|<img style="width: 200px; height: 200px;" src="screenshots/layer_7segment_3d.png"></img>|
131+
112132
- `LayerPlotter` -- a "plotter"
113133
<br>e.g.
114134
```
@@ -117,6 +137,21 @@ The basic Python script setup is:
117137
dd = DumbDisplay()
118138
l = LayerPlotter(dd)
119139
```
140+
|[`demo_LayerPlotter()` in `dd_demo.py`](dd_demo.py)|
141+
|--|
142+
|<img style="width: 200px; height: 200px;" src="screenshots/layer_plotter.png"></img>|
143+
144+
4. if you have multiple layers, you can "auto pin" them together
145+
<br>e.g.
146+
```
147+
AutoPin('V', AutoPin('H', l_ledgrid, l_lcd), AutoPin('H', l_selection, l_7segmentrow), l_graphical).pin(dd)
148+
```
149+
|[`demo_AutoPin()` in `dd_demo.py`](dd_demo.py)|
150+
|--|
151+
|<img style="width: 300px; height: 300px;" src="screenshots/autopin_layers.png"></img>|
152+
153+
154+
120155
121156
122157
For example (using Python networking support with `io4Inet` as `io` for the DumbDisplay object)
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()

dd_demo.py

Lines changed: 158 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,158 @@
1+
import random
2+
import time
3+
import math
4+
5+
6+
from dumbdisplay_examples.utils import create_example_wifi_dd
7+
8+
9+
def demo_LayerLedGrid(col_count = 1, row_count = 1, sub_col_count = 1, sub_row_count = 1):
10+
from dumbdisplay.layer_ledgrid import LayerLedGrid
11+
dd = create_example_wifi_dd()
12+
l = LayerLedGrid(dd, col_count=col_count, row_count=row_count, sub_col_count= sub_col_count, sub_row_count=sub_row_count)
13+
l.border(0.05, "blue")
14+
l.offColor("green")
15+
while True:
16+
dd.timeslice()
17+
18+
19+
def demo_LayerLcd():
20+
from dumbdisplay.layer_lcd import LayerLcd
21+
dd = create_example_wifi_dd()
22+
l = LayerLcd(dd)
23+
l.border(1, "blue")
24+
l.writeCenteredLine("Hello There!")
25+
l.writeCenteredLine("How are you?", y=1)
26+
while True:
27+
dd.timeslice()
28+
29+
30+
def demo_LayerGraphical():
31+
from dumbdisplay.layer_graphical import LayerGraphical
32+
dd = create_example_wifi_dd()
33+
l = LayerGraphical(dd, 150, 100)
34+
l.backgroundColor("azure")
35+
l.border(3, "blue")
36+
for i in range(0, 15):
37+
delta = 3 * i
38+
x = delta
39+
y = delta
40+
w = 150 - 2 * x
41+
h = 100 - 2 * y
42+
l.drawRect(x, y, w, h, "plum")
43+
while True:
44+
dd.timeslice()
45+
46+
47+
def demo_Layer7SegmentRow():
48+
from dumbdisplay.layer_7segrow import Layer7SegmentRow
49+
dd = create_example_wifi_dd()
50+
l = Layer7SegmentRow(dd, 3)
51+
l.border(10, "blue")
52+
l.showNumber(777)
53+
while True:
54+
dd.timeslice()
55+
56+
57+
def demo_LayerSelection():
58+
from dumbdisplay.layer_selection import LayerSelection
59+
dd = create_example_wifi_dd()
60+
l = LayerSelection(dd, 12, 1, 1, 3)
61+
l.border(1, "blue")
62+
for selection_idx in range(3):
63+
l.textCentered(f"Selection {selection_idx + 1}", vert_selection_idx=selection_idx)
64+
l.selected(True, vert_selection_idx=1)
65+
while True:
66+
dd.timeslice()
67+
68+
69+
def demo_LayerPlotter():
70+
from dumbdisplay.layer_plotter import LayerPlotter
71+
dd = create_example_wifi_dd()
72+
l = LayerPlotter(dd, 300, 100)
73+
l.border(5, "blue")
74+
l.label("X", sin="Sin")
75+
for x in range(1000):
76+
sin = math.sin(x)
77+
l.set(x, sin=sin)
78+
time.sleep(0.8)
79+
while True:
80+
dd.timeslice()
81+
82+
83+
def demo_AutoPin():
84+
from dumbdisplay.full import LayerLedGrid, LayerLcd, LayerGraphical, Layer7SegmentRow, LayerSelection, AutoPin
85+
dd = create_example_wifi_dd()
86+
87+
l_ledgrid = LayerLedGrid(dd, 3, 2)
88+
l_ledgrid.border(0.05, "blue")
89+
l_ledgrid.offColor("green")
90+
91+
l_lcd = LayerLcd(dd)
92+
l_lcd.border(1, "blue")
93+
l_lcd.writeCenteredLine("Hello There!")
94+
l_lcd.writeCenteredLine("How are you?", y=1)
95+
96+
l_7segmentrow = Layer7SegmentRow(dd, 2)
97+
l_7segmentrow.border(10, "blue")
98+
l_7segmentrow.showNumber(88)
99+
100+
l_selection = LayerSelection(dd, 10, 1, 2, 3)
101+
l_selection.border(1, "blue")
102+
for selection_idx in range(6):
103+
l_selection.textCentered(f"Choice {selection_idx + 1}", hori_selection_idx=selection_idx)
104+
l_selection.selected(True, 1, 2)
105+
106+
l_graphical = LayerGraphical(dd, 150, 100)
107+
l_graphical.backgroundColor("azure")
108+
l_graphical.border(3, "blue")
109+
radius = 10
110+
for i in range(0, 8):
111+
x = 2 * radius * i
112+
for j in range(0, 6):
113+
y = 2 * radius * j
114+
r = radius
115+
l_graphical.drawCircle(x, y, r, "teal")
116+
l_graphical.drawCircle(x + r, y + r, r, "gold", True)
117+
118+
AutoPin('V', AutoPin('H', l_ledgrid, l_lcd), AutoPin('H', l_selection, l_7segmentrow), l_graphical).pin(dd)
119+
120+
while True:
121+
dd.timeslice()
122+
123+
124+
def run_passive_blink_app():
125+
from dumbdisplay_examples.passive_blink.passive_blink_app import PassiveBlinkApp
126+
print(f"*** PassiveBlinkApp ***")
127+
app = PassiveBlinkApp()
128+
app.run()
129+
130+
131+
def run_sliding_puzzle_app():
132+
from dumbdisplay_examples.sliding_puzzle.sliding_puzzle_app import SlidingPuzzleApp
133+
print(f"*** SlidingPuzzleApp ***")
134+
suggest_move_from_dir_func = lambda board_manager: random.randint(0, 3)
135+
app = SlidingPuzzleApp(dd=create_example_wifi_dd(), suggest_move_from_dir_func=suggest_move_from_dir_func)
136+
app.run()
137+
138+
def run_mnist_app():
139+
from dumbdisplay_examples.mnist.mnist_app import MnistApp
140+
print(f"*** MnistApp ***")
141+
inference_func = lambda board_manager: random.randint(0, 9)
142+
app = MnistApp(dd=create_example_wifi_dd(), inference_func=inference_func)
143+
app.run()
144+
145+
146+
if __name__ == "__main__":
147+
# test_LayerLedGrid(2, 2)
148+
# test_LayerLcd()
149+
# test_LayerGraphical()
150+
# test_Layer7SegmentRow()
151+
# test_LayerSelection()
152+
# test_LayerPlotter()
153+
154+
demo_AutoPin()
155+
156+
# run_passive_blink_app()
157+
# run_sliding_puzzle_app()
158+
# run_mnist_app()

experiments/testing/debug.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,15 @@
77
def loop():
88
dbgLoop(io4WifiOrInet(WIFI_SSID, WIFI_PWD))
99

10+
def loopBlePriority(ble_name: str):
11+
try:
12+
from dumbdisplay.io_ble import io4Ble
13+
io = io4Ble(ble_name)
14+
except:
15+
io = io4WifiOrInet(WIFI_SSID, WIFI_PWD)
16+
dbgLoop(io)
17+
18+
1019
if __name__ == "__main__":
1120
loop()
1221

experiments/testing/main.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ def runDebug():
55
from experiments.testing import debug
66
debug.loop()
77

8+
9+
def runDebugBlePriority(ble_name: str):
10+
from experiments.testing import debug
11+
debug.loopBlePriority(ble_name)
12+
13+
814
def runPicoDebug():
915
from experiments.testing import pico_debug
1016
pico_debug.loop()

screenshots/autopin_layers.png

198 KB
Loading

screenshots/layer_7segment_3d.png

18.7 KB
Loading

0 commit comments

Comments
 (0)