Skip to content

Commit a2f461f

Browse files
committed
Move display splash screen code to base display class
1 parent 471115f commit a2f461f

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

cv2_drivers/displays/cv2_display.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,3 +137,10 @@ def savePinModeAlt(self, pin):
137137

138138
# Return the mode and alt as a tuple
139139
return (mode, alt)
140+
141+
def splash(self):
142+
try:
143+
self.imshow(cv2.imread("splash.png"))
144+
return True
145+
except Exception:
146+
return False

examples/cv2_hardware_init/__init__.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,31 @@
33
# script to automatically initialize the hardware when the board boots up. See:
44
# https://micropython.org/resources/docs/en/latest/reference/reset_boot.html#id4
55

6+
# Import the display driver
67
try:
78
from .display import display
89
except:
910
print("Display initialization failed, skipping...")
1011

12+
# Optional - show a splash image on the display if one is available, or clear
13+
# the display of any previous content
14+
if not display.splash():
15+
if hasattr(display, 'clear'):
16+
display.clear()
17+
18+
# Import the camera driver
1119
try:
1220
from .camera import camera
1321
except:
1422
print("Camera initialization failed, skipping...")
1523

24+
# Import the touch screen driver
1625
try:
1726
from .touch_screen import touch_screen
1827
except:
1928
print("Touch screen initialization failed, skipping...")
2029

30+
# Mount the SD card
2131
try:
2232
# We don't actually need to import anything here, just want to run the
2333
# sd_card module so the SD card gets mounted to the filesystem. So just
@@ -26,15 +36,3 @@
2636
del sdcard
2737
except:
2838
print("SD card initialization failed, skipping...")
29-
30-
# Optional - show a splash image on the display if one is available, or clear
31-
# the display of any previous content
32-
try:
33-
# Load and display a splash image, if one is available
34-
import cv2
35-
splash_image = cv2.imread("splash.png")
36-
cv2.imshow(display, splash_image)
37-
except Exception:
38-
# No splash image, instead clear the display if the driver supports it
39-
if hasattr(display, 'clear'):
40-
display.clear()

0 commit comments

Comments
 (0)