@@ -213,15 +213,15 @@ def blit(self, x1, y1, w, h, buff):
213213tdisp = DummyDisplay (color_format = lv .COLOR_FORMAT .RGB888 )
214214
215215
216- alloc_buffer = lambda buffersize : memoryview (bytearray (buffer_size ))
216+ # alloc_buffer = lambda buffersize: memoryview(bytearray(buffer_size))
217217
218- factor = 10 ### Must be 1 if using an RGBBus
219- double_buf = True ### Must be False if using an RGBBus
218+ # factor = 10 ### Must be 1 if using an RGBBus
219+ # double_buf = True ### Must be False if using an RGBBus
220220
221- buffer_size = tdisp .width * tdisp .height * (tdisp .color_depth // 8 ) // factor
221+ # buffer_size = tdisp.width * tdisp.height * (tdisp.color_depth // 8) // factor
222222
223- fbuf1 = alloc_buffer (buffer_size )
224- fbuf2 = alloc_buffer (buffer_size ) if double_buf else None
223+ # fbuf1 = alloc_buffer(buffer_size)
224+ # fbuf2 = alloc_buffer(buffer_size) if double_buf else None
225225
226226
227227def get_display (
@@ -241,7 +241,22 @@ def get_display(
241241 except Exception as e :
242242 if sys .platform not in ["darwin" , "linux" ]:
243243 sys .print_exception (e )
244- if hasattr (disp , "width" ) and hasattr (disp , "height" ):
245- disp .width = width
246- disp .height = height
244+ assert hasattr (disp , "width" ) is True , "expected width attribute in display driver"
245+ assert (
246+ hasattr (disp , "height" ) is True
247+ ), "expected height attribute in display driver"
248+
249+ assert (
250+ hasattr (disp , "color_depth" ) is True
251+ ), "expected color_depth attribute in display driver"
252+
253+ alloc_buffer = lambda buffersize : memoryview (bytearray (buffer_size ))
254+
255+ factor = 10 ### Must be 1 if using an RGBBus
256+ double_buf = True ### Must be False if using an RGBBus
257+
258+ buffer_size = disp .width * disp .height * (disp .color_depth // 8 ) // factor
259+
260+ fbuf1 = alloc_buffer (buffer_size )
261+ fbuf2 = alloc_buffer (buffer_size ) if double_buf else None
247262 return TestDisplayDriver (disp , fbuf1 , fbuf2 , color_format , mode , pointer )
0 commit comments