Skip to content

Commit 13323a0

Browse files
authored
Merge pull request #18 from makermelissa/master
Updated PyPortal example to work with latest stable CircuitPython
2 parents 8369185 + ea45562 commit 13323a0

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
1+
*.mpy
2+
.idea
13
__pycache__
24
_build
35
*.pyc
46
.env
57
build*
68
bundles
9+
*.DS_Store
10+
.eggs
11+
dist
12+
**/*.egg-info

examples/display_text_pyportal.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,23 @@
1+
"""
2+
This example show the use of the backlight as well as using labels to simulate
3+
a terminal using a font on the PyPortal
4+
"""
5+
16
import os
27
import time
38
import board
4-
import pulseio
5-
import microcontroller
69
import displayio
710

811
from adafruit_bitmap_font import bitmap_font
912
from adafruit_display_text.label import Label
1013

11-
backlight = pulseio.PWMOut(microcontroller.pin.PB21) #pylint: disable=no-member
12-
13-
max_brightness = 2 ** 15
14-
1514
fonts = list(filter(lambda x: x.endswith("bdf") and not x.startswith("."), os.listdir("/")))
1615
fonts = [bitmap_font.load_font(x) for x in fonts]
1716

18-
1917
print("fade up")
2018
# Fade up the backlight
2119
for b in range(100):
22-
backlight.duty_cycle = b * max_brightness // 100
20+
board.DISPLAY.brightness = b / 100
2321
time.sleep(0.01) # default (0.01)
2422

2523
demos = ["CircuitPython = Code + Community", "accents - üàêùéáçãÍóí", "others - αψ◌"]
@@ -40,14 +38,14 @@
4038
# Wait for the image to load.
4139
board.DISPLAY.wait_for_frame()
4240

43-
# Wait forever
41+
# Wait for 10 minutes (600 seconds)
4442
time.sleep(600)
4543

4644
# Fade down the backlight
47-
for b in range(50, -1, -1):
48-
backlight.duty_cycle = b * max_brightness // 100
49-
time.sleep(0.005) # default (0.005)
45+
for b in range(100, -1, -1):
46+
board.DISPLAY.brightness = b / 100
47+
time.sleep(0.01) # default (0.01)
5048

5149
print("fade down")
5250

53-
# splash.pop()
51+
time.sleep(10)

0 commit comments

Comments
 (0)