Skip to content

Commit 3c7e161

Browse files
authored
Create SImple_Terminal.py
1 parent 78cc309 commit 3c7e161

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2021 Randall Bohn (dexter)
2+
# SPDX-FileCopyrightText: Copyright (c) 2021 Anne Barela for Adafruit Industries
3+
#
4+
# SPDX-License-Identifier: MIT
5+
#
6+
# Simple terminalio.Terminal use with the built-in terminalio.FONT
7+
# for a DVI display from an RP2350 HSTX connection
8+
#
9+
# Modeled on https://github.com/circuitpython/CircuitPython_Module_Examples/
10+
# blob/801475f745fe2a61738f1abed3bd01007118efa3/terminalio/
11+
# terminalio_terminal_example.py#L5
12+
13+
import board
14+
import displayio
15+
import terminalio
16+
import picodvi
17+
import framebufferio
18+
19+
displayio.release_displays()
20+
# Set up a 320x240x8 bit display space
21+
fb = picodvi.Framebuffer(320, 240, clk_dp=board.CKP, clk_dn=board.CKN,
22+
red_dp=board.D0P, red_dn=board.D0N,
23+
green_dp=board.D1P, green_dn=board.D1N,
24+
blue_dp=board.D2P, blue_dn=board.D2N,
25+
color_depth=8)
26+
display = framebufferio.FramebufferDisplay(fb)
27+
28+
group = displayio.Group()
29+
display.root_group = group
30+
31+
palette = displayio.Palette(2) # A simple color palette
32+
palette[0] = 0x220000 # not so dark Black
33+
palette[1] = 0x00FFFF # Cyan
34+
35+
ROWS = 12
36+
COLS = 40
37+
38+
w, h = terminalio.FONT.get_bounding_box()
39+
40+
termgrid = displayio.TileGrid(
41+
terminalio.FONT.bitmap,
42+
pixel_shader=palette,
43+
y=20,
44+
width=COLS,
45+
height=ROWS,
46+
tile_width=w,
47+
tile_height=h,
48+
)
49+
group.append(termgrid)
50+
term = terminalio.Terminal(termgrid, terminalio.FONT)
51+
52+
term.write("Terminal %dx%d:\r\n" % (COLS, ROWS))
53+
term.write(" %dx%d pixels.\r\n" % (COLS * w, ROWS * h))
54+
term.write("Both carriage return and line feed \r\n are required.\r\n")
55+
56+
while(True):
57+
pass

0 commit comments

Comments
 (0)