Skip to content

Commit 2d4f747

Browse files
committed
remove try/except, check for 'DISPLAY' in dir(board)
1 parent 6965241 commit 2d4f747

File tree

1 file changed

+22
-28
lines changed
  • CircuitPython_DVI_Hello_World

1 file changed

+22
-28
lines changed

CircuitPython_DVI_Hello_World/code.py

Lines changed: 22 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import math
88
from random import randint
99
import time
10-
import supervisor
1110
import displayio
1211
import picodvi
1312
import board
@@ -23,35 +22,30 @@
2322
from adafruit_display_shapes.triangle import Triangle
2423
from adafruit_display_shapes.line import Line
2524

26-
displayio.release_displays()
27-
28-
# check for DVI Feather
29-
if 'CKP' in dir(board):
30-
try:
31-
fb = picodvi.Framebuffer(320, 240,
32-
clk_dp=board.CKP, clk_dn=board.CKN,
33-
red_dp=board.D0P, red_dn=board.D0N,
34-
green_dp=board.D1P, green_dn=board.D1N,
35-
blue_dp=board.D2P, blue_dn=board.D2N,
36-
color_depth=8)
37-
except MemoryError as e:
38-
print("Error:\n", str(e))
39-
time.sleep(5)
40-
supervisor.reload()
25+
# check for DVI Feather with built-in display
26+
if 'DISPLAY' in dir(board):
27+
display = board.DISPLAY
28+
29+
# check for DVI feather without built-in display
30+
elif 'CKP' in dir(board):
31+
displayio.release_displays()
32+
fb = picodvi.Framebuffer(320, 240,
33+
clk_dp=board.CKP, clk_dn=board.CKN,
34+
red_dp=board.D0P, red_dn=board.D0N,
35+
green_dp=board.D1P, green_dn=board.D1N,
36+
blue_dp=board.D2P, blue_dn=board.D2N,
37+
color_depth=8)
38+
display = framebufferio.FramebufferDisplay(fb)
4139
# otherwise assume Pico
4240
else:
43-
try:
44-
fb = picodvi.Framebuffer(320, 240,
45-
clk_dp=board.GP12, clk_dn=board.GP13,
46-
red_dp=board.GP10, red_dn=board.GP11,
47-
green_dp=board.GP8, green_dn=board.GP9,
48-
blue_dp=board.GP6, blue_dn=board.GP7,
49-
color_depth=8)
50-
except MemoryError as e:
51-
print("Error:\n", str(e))
52-
time.sleep(5)
53-
supervisor.reload()
54-
display = framebufferio.FramebufferDisplay(fb)
41+
displayio.release_displays()
42+
fb = picodvi.Framebuffer(320, 240,
43+
clk_dp=board.GP12, clk_dn=board.GP13,
44+
red_dp=board.GP10, red_dn=board.GP11,
45+
green_dp=board.GP8, green_dn=board.GP9,
46+
blue_dp=board.GP6, blue_dn=board.GP7,
47+
color_depth=8)
48+
display = framebufferio.FramebufferDisplay(fb)
5549

5650
bitmap = displayio.Bitmap(display.width, display.height, 3)
5751

0 commit comments

Comments
 (0)