From 2cc1ccb842be3e47ba2b4aa422603e47fd4a7d5d Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Mon, 19 Aug 2019 10:13:51 -0700 Subject: [PATCH 1/2] Updated PyPortal example to work with latest stable CircuitPython --- .gitignore | 6 ++++++ examples/display_text_pyportal.py | 25 ++++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 0dd8629..cc1a9c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,12 @@ +*.mpy +.idea __pycache__ _build *.pyc .env build* bundles +*.DS_Store +.eggs +dist +**/*.egg-info diff --git a/examples/display_text_pyportal.py b/examples/display_text_pyportal.py index 9c1b4f9..f94845f 100644 --- a/examples/display_text_pyportal.py +++ b/examples/display_text_pyportal.py @@ -1,25 +1,23 @@ +""" +This example show the use of the backlight as well as using labels to simulate +a terminal using a font on the PyPortal +""" + import os import time import board -import pulseio -import microcontroller import displayio from adafruit_bitmap_font import bitmap_font from adafruit_display_text.label import Label -backlight = pulseio.PWMOut(microcontroller.pin.PB21) #pylint: disable=no-member - -max_brightness = 2 ** 15 - fonts = list(filter(lambda x: x.endswith("bdf") and not x.startswith("."), os.listdir("/"))) fonts = [bitmap_font.load_font(x) for x in fonts] - print("fade up") # Fade up the backlight for b in range(100): - backlight.duty_cycle = b * max_brightness // 100 + board.DISPLAY.brightness = b / 100 time.sleep(0.01) # default (0.01) demos = ["CircuitPython = Code + Community", "accents - üàêùéáçãÍóí", "others - αψ◌"] @@ -40,14 +38,15 @@ # Wait for the image to load. board.DISPLAY.wait_for_frame() -# Wait forever +# Wait for 10 minutes (600 seconds) time.sleep(600) # Fade down the backlight -for b in range(50, -1, -1): - backlight.duty_cycle = b * max_brightness // 100 - time.sleep(0.005) # default (0.005) +for b in range(100, -1, -1): + board.DISPLAY.brightness = b / 100 + time.sleep(0.01) # default (0.01) print("fade down") - # splash.pop() +while True: + pass From ea45562020a431c86a9a961348e07e0eb8bcccc1 Mon Sep 17 00:00:00 2001 From: Melissa LeBlanc-Williams Date: Mon, 19 Aug 2019 19:35:31 -0700 Subject: [PATCH 2/2] Updated with PR suggestions --- examples/display_text_pyportal.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/display_text_pyportal.py b/examples/display_text_pyportal.py index f94845f..5725d4e 100644 --- a/examples/display_text_pyportal.py +++ b/examples/display_text_pyportal.py @@ -48,5 +48,4 @@ print("fade down") -while True: - pass +time.sleep(10)