Skip to content

Commit e2bc259

Browse files
committed
commit
1 parent 30dc08c commit e2bc259

6 files changed

Lines changed: 118 additions & 5 deletions

File tree

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@
22

33
DumbDisplay for Micro-Python is a port of the Arduino DumbDisplay library -- https://github.com/trevorwslee/Arduino-DumbDisplay
44

5-
Although the porting is not complete, nevertheless, a large portion of DumbDisplay functionalities have been ported. Hopefully, this should already be helpful for friends that develop programs for micro-controller boards in MicroPython.
5+
Although the porting is not complete, nevertheless, a large portion of DumbDisplay functionalities have been ported. Hopefully, this should already be helpful for friends that develop programs for micro-controller boards in Micro-Python.
66

7-
Note that even though it is targeted for MicroPython, it is still usable with regular Python 3, like in Raspberry Pi environment.
7+
Note that even though it is targeted for Micro-Python, it is still usable with regular Python 3, like in Raspberry Pi environment,
8+
or even desktop/laptop.
89

910

1011
The basic script setup is:

dumbdisplay/_dumbdisplay.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ def writeComment(self, comment: str):
7777
'''write out a comment to DD'''
7878
self._connect()
7979
self._sendCommand(None, '// ' + comment)
80+
print("# " + comment)
8081
def recordLayerCommands(self):
8182
'''
8283
start recording layer commands (of any layers)

run_sample_graphical.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
if __name__ == "__main__":
2+
import samples.graphical.main

samples/doodle/main.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
from dumbdisplay.layer_graphical import *
66

77

8+
# initialize some global variables
89
_last_x = -1
910
_color = "red"
1011

12+
# feedback handler
1113
def feedback_handler(layer, type, x, y):
1214
global _last_x, _last_y, _color
1315
if layer == l:
@@ -25,21 +27,39 @@ def feedback_handler(layer, type, x, y):
2527
_last_x = -1
2628

2729

30+
# create DumbDisplay connected using Inet (Python Internet connection)
2831
dd = DumbDisplay(io4Inet())
32+
33+
# create 3 LCD layer as 3 tabs for changing color
2934
l_r = LayerLcd(dd)
3035
l_g = LayerLcd(dd)
3136
l_b = LayerLcd(dd)
32-
l = LayerGraphical(dd, 150, 100)
37+
38+
# set the background color of the 3 tabs
3339
l_r.backgroundColor("red")
3440
l_g.backgroundColor("green")
3541
l_b.backgroundColor("blue")
42+
43+
44+
# create the main graphical [LCD] layer
45+
l = LayerGraphical(dd, 150, 100)
46+
47+
# set the background color as well as border for the graphical layer
3648
l.backgroundColor("white")
3749
l.border(3, "black")
50+
51+
# enable feedback for the 3 tabs
3852
l_r.enableFeedback("f", feedback_handler)
3953
l_g.enableFeedback("f", feedback_handler)
4054
l_b.enableFeedback("f", feedback_handler)
55+
56+
#enable feedback for the core graphical layer, note that it is set to "auto repeat" every 50 milli-seconds
4157
l.enableFeedback("fs:rpt50", feedback_handler)
58+
59+
# "auto pin" the different layers
4260
AutoPin('V', AutoPin('H', l_r, l_g, l_b), l).pin(dd)
61+
62+
# the main loop does nothing, but uses DumbDisplay's delay, so that DumbDisplay has a chnace to do it's work
4363
while True:
4464
dd.delay(1)
4565

samples/graphical/main.py

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
2+
from dumbdisplay.core import *
3+
from dumbdisplay.io_inet import *
4+
from dumbdisplay.layer_graphical import LayerGraphical
5+
6+
# create DumbDisplay connected using Inet (Python Internet connection)
7+
dd = DumbDisplay(io4Inet())
8+
9+
# create 4 graphical [LCD] layers
10+
l1 = LayerGraphical(dd, 150, 101)
11+
l2 = LayerGraphical(dd, 150, 101)
12+
l3 = LayerGraphical(dd, 150, 101)
13+
l4 = LayerGraphical(dd, 150, 101)
14+
15+
# "auto pin" the 4 layers -- 2 by 2
16+
AutoPin('H', AutoPin('V', l1, l2), AutoPin('V', l3, l4)).pin(dd)
17+
18+
19+
while True:
20+
dd.writeComment("start")
21+
22+
# set fill screen with color
23+
l1.fillScreen("azure")
24+
l2.fillScreen("azure")
25+
l3.fillScreen("azure")
26+
l4.fillScreen("azure")
27+
28+
# draw triangles
29+
left = 0
30+
right = 150
31+
top = 0
32+
bottom = 100
33+
mid = 50
34+
for i in range(0, 15):
35+
left += 3
36+
top += 3
37+
right -= 3
38+
bottom -= 3
39+
x1 = left
40+
y1 = mid
41+
x2 = right
42+
y2 = top
43+
x3 = right
44+
y3 = bottom
45+
r = 25 * i
46+
g = 255 - (10 * i)
47+
b = 2 * i
48+
l1.drawTriangle(x1, y1, x2, y2, x3, y3, RGB_COLOR(r, g, b))
49+
50+
# draw lines
51+
i = 0
52+
while True:
53+
delta = 5 * i
54+
x1 = 150
55+
y1 = 0
56+
x2 = -150 + delta
57+
y2 = delta
58+
l2.drawLine(x1, y1, x2, y2, "blue")
59+
if x2 > 150:
60+
break
61+
i += 1
62+
63+
# draw rectangles
64+
for i in range(0, 15):
65+
delta = 3 * i
66+
x = delta
67+
y = delta
68+
w = 150 - 2 * x
69+
h = 100 - 2 * y
70+
l3.drawRect(x, y, w, h, "plum")
71+
72+
# draw circles
73+
radius = 10
74+
for i in range(0, 8):
75+
x = 2 * radius * i
76+
for j in range(0, 6):
77+
y = 2 * radius * j
78+
r = radius
79+
l4.drawCircle(x, y, r, "teal")
80+
l4.drawCircle(x + r, y + r, r, "gold", True)
81+
82+
dd.writeComment("done ... will repeat in 5 second")
83+
dd.delay(5)
84+
l1.clear()
85+
l2.clear()
86+
l3.clear()
87+
l4.clear()
88+
89+

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55

66
setuptools.setup(
77
name='uDumbDisplayLib',
8-
version='0.1.0',
8+
version='0.2.0',
99
author='Trevor Lee',
1010
author_email='trev_lee@hotmail.com',
11-
description='DumbDisplay Micro-Python Library',
11+
description='Micro-Python DumbDisplay Library',
1212
long_description=long_description,
1313
long_description_content_type="text/markdown",
1414
url='https://github.com/trevorwslee/MicroPython-DumbDisplay',

0 commit comments

Comments
 (0)