Skip to content

Commit 6965241

Browse files
committed
adding try/except to DVI hello world
Adding a try/except to workaround a MemoryError in CircuitPython 9 beta2 as noted in #2746
1 parent f46ef2e commit 6965241

File tree

1 file changed

+23
-12
lines changed
  • CircuitPython_DVI_Hello_World

1 file changed

+23
-12
lines changed

CircuitPython_DVI_Hello_World/code.py

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import math
88
from random import randint
99
import time
10+
import supervisor
1011
import displayio
1112
import picodvi
1213
import board
@@ -26,20 +27,30 @@
2627

2728
# check for DVI Feather
2829
if 'CKP' in dir(board):
29-
fb = picodvi.Framebuffer(320, 240,
30-
clk_dp=board.CKP, clk_dn=board.CKN,
31-
red_dp=board.D0P, red_dn=board.D0N,
32-
green_dp=board.D1P, green_dn=board.D1N,
33-
blue_dp=board.D2P, blue_dn=board.D2N,
34-
color_depth=8)
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()
3541
# otherwise assume Pico
3642
else:
37-
fb = picodvi.Framebuffer(320, 240,
38-
clk_dp=board.GP12, clk_dn=board.GP13,
39-
red_dp=board.GP10, red_dn=board.GP11,
40-
green_dp=board.GP8, green_dn=board.GP9,
41-
blue_dp=board.GP6, blue_dn=board.GP7,
42-
color_depth=8)
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()
4354
display = framebufferio.FramebufferDisplay(fb)
4455

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

0 commit comments

Comments
 (0)