Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import board
- import displayio
- import os
- import gc
- import pulseio
- import random
- import time
- import microcontroller
- import sys
- sys.path.append('/Adafruit_CircuitPython_BitmapFont')
- sys.path.append('/Adafruit_CircuitPython_Display_Text')
- print(sys.path)
- from adafruit_bitmap_font import bitmap_font
- from adafruit_display_text.text_area import TextArea
- backlight = pulseio.PWMOut(board.TFT_BACKLIGHT)
- max_brightness = 2 ** 15
- fonts = list(filter(lambda x: x.endswith("bdf") and not x.startswith("."), os.listdir("/")))
- font = bitmap_font.load_font(fonts[0])
- start = time.monotonic()
- code_points = set()
- code_points.update(range(0x30, 0x7a))
- code_points.add(0x20)
- font.load_glyphs(code_points)
- print("pre-load time:", time.monotonic() - start)
- print("fade up")
- # Fade up the backlight
- for b in range(100):
- backlight.duty_cycle = b * max_brightness // 100
- time.sleep(0.01) # default (0.01)
- demos = ["Hackaday", "0123456789"]
- splash = displayio.Group(max_size=len(fonts) * len(demos))
- board.DISPLAY.show(splash)
- max_y = 0
- y = 2
- print("Font load {}".format(font.name))
- start = time.monotonic()
- area = TextArea(font, text=" Hack A Day")
- print("text load time:", time.monotonic() - start)
- area.y = y
- splash.append(area.group)
- # Wait for the image to load.
- board.DISPLAY.wait_for_frame()
- for i in range(1000):
- area = TextArea(font, text='Skulls: {0:<10}'.format(i))
- area.y = 200
- #area.x = 100
- if i != 0:
- splash.pop()
- splash.append(area.group)
- board.DISPLAY.wait_for_frame()
- #time.sleep(1)
- gc.collect()
- print("mem free:", gc.mem_free())
- # 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)
- print("fade down")
- # splash.pop()
Add Comment
Please, Sign In to add comment