Last active
July 27, 2024 01:50
-
-
Save anecdata/0e426cc9d150c078f7f0b276afa6ff57 to your computer and use it in GitHub Desktop.
TileGrid terminalio
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import board | |
import displayio | |
import terminalio | |
display = board.DISPLAY # or equivalent external display library | |
splash = displayio.Group() | |
fontx, fonty = terminalio.FONT.get_bounding_box() | |
term_palette = displayio.Palette(2) | |
term_palette[0] = 0x000000 | |
term_palette[1] = 0xffffff | |
logbox = displayio.TileGrid(terminalio.FONT.bitmap, | |
x=0, | |
y=0, | |
width=display.width // fontx, | |
height=display.height // fonty, | |
tile_width=fontx, | |
tile_height=fonty, | |
pixel_shader=term_palette) | |
splash.append(logbox) | |
logterm = terminalio.Terminal(logbox, terminalio.FONT) | |
display.show(splash) | |
print("Hello Serial!", file=sys.stdout) # serial console | |
print("\r\nHello displayio!", file=logterm, end="") # displayio |
logterm.write("")
is equivalent to print("", file=logterm, end="")
https://docs.circuitpython.org/en/latest/shared-bindings/terminalio/index.html
terminalio.Terminal with color:
https://gist.github.com/anecdata/d208b41828a2103b3039e4ccaf5d8cf3
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Font colors and other ESC codes:
https://github.com/s-light/CircuitPython_ansi_escape_code
via https://discord.com/channels/327254708534116352/537365702651150357/1069384809220165713