Skip to content

Commit d628b2f

Browse files
authored
Merge pull request #3084 from adafruit/TheKitty-patch-12
Create DVI_Framebuffer.py
2 parents be32939 + fc6bad3 commit d628b2f

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# SPDX-FileCopyrightText: 2025 Anne Barela for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
#
5+
# Set up a DVI display using Framebufferio and displayio
6+
# Text and drawing is all done vis displayio
7+
#
8+
import sys
9+
import microcontroller
10+
import board
11+
import displayio
12+
import terminalio
13+
import framebufferio
14+
import picodvi
15+
from adafruit_display_text import label
16+
17+
# Initialize displayio
18+
displayio.release_displays()
19+
try:
20+
fb = picodvi.Framebuffer(640, 480, clk_dp=board.CKP, clk_dn=board.CKN,
21+
red_dp=board.D0P, red_dn=board.D0N,
22+
green_dp=board.D1P, green_dn=board.D1N,
23+
blue_dp=board.D2P, blue_dn=board.D2N,
24+
color_depth=4)
25+
except ValueError as e:
26+
print("Framebuffer error: ", e)
27+
# Per picodvi/Framebuffer_RP2350.c only 320x240 at 8 & 16 bits work
28+
# Show error
29+
sys.exit(e)
30+
31+
display = framebufferio.FramebufferDisplay(fb)
32+
display_group = displayio.Group()
33+
34+
display.root_group = display_group
35+
36+
# Create labels
37+
# pylint: disable=line-too-long
38+
text = " 1 2 3 4 5 6 7 8 9 0 1 2"
39+
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFFFF)
40+
text_area.x = 0
41+
text_area.y = 5
42+
display_group.append(text_area)
43+
# pylint: disable=line-too-long
44+
text = "123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"
45+
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFFFF)
46+
text_area.x = 0
47+
text_area.y = 15
48+
display_group.append(text_area)
49+
text = f"Microcontroller speed: {microcontroller.cpu.frequency}"
50+
text_area = label.Label(terminalio.FONT, text=text, color=0xFFFFFF)
51+
text_area.x = 5
52+
text_area.y = 40
53+
display_group.append(text_area)
54+
55+
while True:
56+
pass

0 commit comments

Comments
 (0)