Skip to content

Commit f9762f6

Browse files
committed
Add optional buffer parameter to HSTX DVI driver
1 parent 3e96de0 commit f9762f6

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

red_vision/displays/dvi_rp2_hstx.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,8 @@ def __init__(
123123
pin_d1_p = 16,
124124
pin_d1_n = 17,
125125
pin_d2_p = 12,
126-
pin_d2_n = 13
126+
pin_d2_n = 13,
127+
buffer = None,
127128
):
128129
"""
129130
Initializes the DVI HSTX display driver.
@@ -144,6 +145,7 @@ def __init__(
144145
pin_d1_n (int, optional): TMDS data 1 lane negative pin (default: 17)
145146
pin_d2_p (int, optional): TMDS data 2 lane positive pin (default: 12)
146147
pin_d2_n (int, optional): TMDS data 2 lane negative pin (default: 13)
148+
buffer (ndarray, optional): Pre-allocated frame buffer.
147149
"""
148150
# Set pin numbers.
149151
self._pin_clk_p = pin_clk_p
@@ -171,10 +173,13 @@ def __init__(
171173
self._height_scale = self._V_ACTIVE_LINES // height
172174

173175
# Create the image buffer.
174-
self._buffer = np.zeros(
175-
(height, width, self._bytes_per_pixel),
176-
dtype = np.uint8
177-
)
176+
if buffer is not None:
177+
self._buffer = buffer
178+
else:
179+
self._buffer = np.zeros(
180+
(height, width, self._bytes_per_pixel),
181+
dtype = np.uint8
182+
)
178183

179184
# Configure HSTX peripheral.
180185
self._configure_hstx()

0 commit comments

Comments
 (0)