Skip to content

Commit f6b39aa

Browse files
committed
updated
1 parent e9da424 commit f6b39aa

6 files changed

Lines changed: 175 additions & 161 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@
1616
/_my_secret.py
1717

1818
uDumbDisplay.code-workspace
19+
/OLD.md

README.md

Lines changed: 16 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# DumbDisplay MicroPython Library (v0.5.0)
22

33
DumbDisplay MicroPython Library -- workable with Python 3 -- is a port of the [DumbDisplay Arduino Library](https://github.com/trevorwslee/Arduino-DumbDisplay)
4-
to Micro-Python / Python 3 for the [DumbDisplay Android app](https://play.google.com/store/apps/details?id=nobody.trevorlee.dumbdisplay)
4+
to MicroPython / Python 3 for the [DumbDisplay Android app](https://play.google.com/store/apps/details?id=nobody.trevorlee.dumbdisplay)
55

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

99
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 Micro-Python, it should be useful with regular Python 3, like in Raspberry Pi environment
12+
As hinted previously, even it is originally targeted for MicroPython, it should be useful with regular Python 3, like in Raspberry Pi environment
1313
or even with desktop / laptop.
1414
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

@@ -19,19 +19,16 @@ Enjoy
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)
2622
- [Selected Demos](#selected-demos)
23+
- [Notes](#notes)
2724
- [Thank You!](#thank-you)
2825
- [License](#license)
2926
- [Change History](#change-history)
3027

3128

3229
# Installation
3330

34-
For Micro-Python, please refer to the [above-mentioned YouTube video](https://www.youtube.com/watch?v=KVU26FyXs5M)
31+
For MicroPython, please refer to the [above-mentioned YouTube video](https://www.youtube.com/watch?v=KVU26FyXs5M)
3532
for examples of using DumbDisplay MicroPython Library for microcontroller programming.
3633

3734
If your targeted is desktop / laptop, you can install the package like:
@@ -64,8 +61,8 @@ The basic Python script setup is:
6461
- you can import the "core" components with ```from dumbdisplay.core import *```
6562
- or you can choose to import "all" components (including layers to be mentioned later) with ```from dumbdisplay.full import *```
6663
2. import IO mechanism, for creating IO object [to pass to DumbDisplay object], like
67-
- `io4Inet` (the default) -- Python networking support (not available for Micro-Python)
68-
- `io4Wifi` -- Micro-Python WiFi support (for Raspberry Pi Pico W, ESP32, etc.)
64+
- `io4Inet` (the default) -- Python networking support (not available for MicroPython)
65+
- `io4Wifi` -- MicroPython WiFi support (for Raspberry Pi Pico W, ESP32, etc.)
6966
<br>e.g.
7067
```
7168
from dumbdisplay.core import *
@@ -155,117 +152,6 @@ The basic Python script setup is:
155152
|<img style="width: 400px; height: 400px;" src="screenshots/autopin_layers.png"></img>|
156153
157154
158-
# Examples
159-
160-
161-
## DumbDisplay `io` Object
162-
163-
For example (using Python networking support with `io4Inet` as `io` for the DumbDisplay object)
164-
```
165-
from dumbdisplay.core import *
166-
from dumbdisplay.io_inet import *
167-
from dumbdisplay.layer_ledgrid import *
168-
dd = DumbDisplay(io4Inet()) # actually, default io is io4Inet()
169-
l = LayerLedGrid(dd)
170-
l.turnOn()
171-
```
172-
173-
174-
A simple sample that explicitly makes use of WiFi `io4Wifi` as `io` for the DumbDisplay object, can be like
175-
```
176-
from dumbdisplay.core import *
177-
from dumbdisplay.io_wifi import *
178-
from dumbdisplay.layer_ledgrid import *
179-
import time
180-
dd = DumbDisplay(io4Wifi("ssid", "password"))
181-
l = LayerLedGrid(dd, 2, 1)
182-
l.offColor("green")
183-
l.turnOn()
184-
for _ in range(10):
185-
time.sleep(1)
186-
l.toggle(0, 0)
187-
l.toggle(1, 0)
188-
dd.writeComment("DONE")
189-
```
190-
191-
192-
## Layer Feedback
193-
194-
195-
A simple sample that polls for feedback (say user pressing the layer) from a layer, can be like
196-
```
197-
from dumbdisplay.core import *
198-
from dumbdisplay.io_inet import *
199-
from dumbdisplay.layer_ledgrid import *
200-
dd = DumbDisplay() # default io is io4Inet()
201-
l = LayerLedGrid(dd, 20, 20)
202-
l.enableFeedback("fa")
203-
l.offColor(RGB_COLOR(0xcc, 0xcc, 0xcc))
204-
while True:
205-
feedback = l.getFeedback()
206-
if feedback is not None:
207-
print("l FB: {}: {},{}".format(feedback.type, feedback.x, feedback.y))
208-
l.toggle(feedback.x, feedback.y)
209-
```
210-
211-
212-
## Auto-pin Layers
213-
214-
215-
A more complete simple sample that also shows "auto pin" as well, can be like
216-
```
217-
from dumbdisplay.core import *
218-
from dumbdisplay.io_inet import *
219-
from dumbdisplay.layer_lcd import *
220-
from dumbdisplay.layer_graphical import *
221-
222-
_last_x = -1
223-
_color = "red"
224-
def feedback_handler(layer, type, x, y):
225-
global _last_x, _last_y, _color
226-
if layer == l:
227-
if _last_x != -1:
228-
l.drawLine(_last_x, _last_y, x, y, _color)
229-
_last_x = x
230-
_last_y = y
231-
else:
232-
if layer == l_r:
233-
_color = "red"
234-
elif layer == l_g:
235-
_color = "green"
236-
elif layer == l_b:
237-
_color = "blue"
238-
_last_x = -1
239-
240-
241-
dd = DumbDisplay() # default io is io4Inet()
242-
l_r = LayerLcd(dd)
243-
l_g = LayerLcd(dd)
244-
l_b = LayerLcd(dd)
245-
l = LayerGraphical(dd, 150, 100)
246-
l_r.backgroundColor("red")
247-
l_g.backgroundColor("green")
248-
l_b.backgroundColor("blue")
249-
l.backgroundColor("white")
250-
l.border(3, "black")
251-
l_r.enableFeedback("f", feedback_handler=feedback_handler)
252-
l_g.enableFeedback("f", feedback_handler=feedback_handler)
253-
l_b.enableFeedback("f", feedback_handler=feedback_handler)
254-
l.enableFeedback("fs:rpt50", feedback_handler=feedback_handler)
255-
AutoPin('V', AutoPin('H', l_r, l_g, l_b), l).pin(dd)
256-
while True:
257-
dd.timeslice()
258-
```
259-
260-
Notes:
261-
* If seeing ESP32 brownout detection issue, try
262-
```
263-
import machine
264-
machine.reset_cause()
265-
```
266-
* If DumbDisplay Android app fails to make connection to desktop / laptop, check your desktop firewall settings; try switching desktop WIFI to use 2.4 GHz.
267-
268-
269155
# Selected Demos
270156
271157
Here is a few Raspberry Pi Pico PIO demos that might interest you
@@ -282,6 +168,16 @@ Here is a few Raspberry Pi Pico PIO demos that might interest you
282168
|![](screenshots/dd-mnist.jpg)|![](screenshots/dd-sliding-puzzle.jpg)|
283169
284170
171+
# Notes
172+
* If seeing ESP32 brownout detection issue, try
173+
```
174+
import machine
175+
machine.reset_cause()
176+
```
177+
* If DumbDisplay Android app fails to make connection to desktop / laptop, check your desktop firewall settings; try switching desktop WIFI to use 2.4 GHz.
178+
179+
180+
285181
286182
# Thank You!
287183

0 commit comments

Comments
 (0)