0. はじめに
Raspberry Pi Pico で DVI 出力する方法を探しても、Pico SDK や Arduino の例は見つかるが、CircuitPython の例が見つからなかったので、調べた結果をここにまとめておく。
1. Adafruit DVI Breakout Board
↓こちらで購入した
実態は HDMI 端子だ。音声が無いから DVI(Digital Visual Interface)と言う??
2. Picoとの接続
Adafruitの商品説明ページにあった、以下の写真と同じ接続にした。
DVIボード | Pico |
---|---|
TXC- | GP15 |
TXC+ | GP14 |
TX0- | GP13 |
TX0+ | GP12 |
TX1- | GP19 |
TX1+ | GP18 |
TX2- | GP17 |
TX2+ | GP16 |
GND x3 | GND |
3. テストコード
以下のコードでDVI出力を確認できた。
当然のことながら、Adafruitの各種ライブラリを使用している。
CircuitPython
import displayio
displayio.release_displays()
import time
import board
import picodvi
import framebufferio
w=320
h=240
cd=8
fb = picodvi.Framebuffer(
width=w, height=h, color_depth=cd,
clk_dp=board.GP14, clk_dn=board.GP15,
red_dp=board.GP12, red_dn=board.GP13,
green_dp=board.GP18, green_dn=board.GP19,
blue_dp=board.GP16, blue_dn=board.GP17)
display = framebufferio.FramebufferDisplay(fb)
splash = displayio.Group()
display.root_group = splash
from adafruit_display_shapes.rect import Rect
from adafruit_display_shapes.circle import Circle
from adafruit_display_shapes.roundrect import RoundRect
from adafruit_display_shapes.triangle import Triangle
from adafruit_display_shapes.line import Line
from adafruit_display_shapes.polygon import Polygon
# Make a background color fill
color_bitmap = displayio.Bitmap(320, 240, 1)
color_palette = displayio.Palette(1)
color_palette[0] = 0xFFFFFF
bg_sprite = displayio.TileGrid(color_bitmap, x=0, y=0, pixel_shader=color_palette)
splash.append(bg_sprite)
###################################################
splash.append(Line(220, 130, 270, 210, 0xFF0000))
splash.append(Line(270, 210, 220, 210, 0xFF0000))
splash.append(Line(220, 210, 270, 130, 0xFF0000))
splash.append(Line(270, 130, 220, 130, 0xFF0000))
# Draw a blue star
polygon = Polygon(
[
(255, 40),
(262, 62),
(285, 62),
# (265, 76),
# (275, 100),
# (255, 84),
# (235, 100),
# (245, 76),
# (225, 62),
# (248, 62),
],
outline=0x0000FF,
)
splash.append(polygon)
triangle = Triangle(170, 50, 120, 140, 210, 160, fill=0x00FF00, outline=0xFF00FF)
splash.append(triangle)
rect = Rect(80, 20, 41, 41, fill=0x0)
splash.append(rect)
circle = Circle(100, 100, 20, fill=0x00FF00, outline=0xFF00FF)
splash.append(circle)
rect2 = Rect(50, 100, 61, 81, outline=0x0, stroke=3)
splash.append(rect2)
roundrect = RoundRect(10, 10, 61, 81, 10, fill=0x0, outline=0xFF00FF, stroke=6)
splash.append(roundrect)
time.sleep(3)
while True:
stack = []
for _ in range(10):
stack.append(splash.pop())
time.sleep(1)
for s in stack:
splash.append(s)
time.sleep(1)
WQHDモニターにHDMI接続した。
モニター側での解像度は 640x480(60Hz)。
もっと高解像度にできるのかは、今後 調査と実験が必要。
4. 環境
-
Raspberry Pi Pico W
-
Adafruit CircuitPython 9.0.4 on 2024-04-16
- adafruit-circuitpython-raspberry_pi_pico_w-ja-9.0.4.uf2
- adafruit-circuitpython-raspberry_pi_pico_w-ja-9.0.4.uf2
-
Bundles
- adafruit-circuitpython-bundle-9.x-mpy-20240521.zip
- adafruit-circuitpython-bundle-9.x-mpy-20240521.zip
-
Community Bundle
- circuitpython-community-bundle-9.x-mpy-20240521.zip