Skip to content

Commit ebd60a5

Browse files
committed
Hopefully corrects issue with RGB Bus
1 parent cbc43d4 commit ebd60a5

File tree

2 files changed

+20
-73
lines changed

2 files changed

+20
-73
lines changed

api_drivers/py_api_drivers/frozen/display/display_driver_framework.py

Lines changed: 20 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -175,11 +175,9 @@ def __init__(
175175
display_height *
176176
lv.color_format_get_size(color_space)
177177
)
178+
buf_size = int(buf_size // 10)
178179
gc.collect()
179180

180-
if not isinstance(data_bus, lcd_bus.RGBBus):
181-
buf_size = int(buf_size // 10)
182-
183181
for flags in (
184182
lcd_bus.MEMORY_INTERNAL | lcd_bus.MEMORY_DMA,
185183
lcd_bus.MEMORY_SPIRAM | lcd_bus.MEMORY_DMA,
@@ -214,14 +212,7 @@ def __init__(
214212
self._init_bus()
215213

216214
def _init_bus(self):
217-
if isinstance(self._data_bus, lcd_bus.RGBBus):
218-
buffer_size = int(
219-
self.display_width *
220-
self.display_height *
221-
lv.color_format_get_size(self._color_space)
222-
)
223-
else:
224-
buffer_size = len(self._frame_buffer1)
215+
buffer_size = len(self._frame_buffer1)
225216

226217
self._data_bus.init(
227218
self.display_width,
@@ -235,13 +226,24 @@ def _init_bus(self):
235226

236227
self._disp_drv.set_flush_cb(self._flush_cb)
237228

229+
full_screen_size = (
230+
self.display_width *
231+
self.display_height *
232+
lv.color_format_get_size(self._color_space)
233+
)
234+
if full_screen_size == len(self._frame_buffer1):
235+
render_mode = lv.DISPLAY_RENDER_MODE.FULL # NOQA
236+
else:
237+
render_mode = lv.DISPLAY_RENDER_MODE.PARTIAL # NOQA
238+
239+
self._disp_drv.set_buffers(
240+
self._frame_buffer1,
241+
self._frame_buffer2,
242+
len(self._frame_buffer1),
243+
render_mode
244+
)
245+
238246
if isinstance(self._data_bus, lcd_bus.RGBBus):
239-
self._disp_drv.set_buffers(
240-
self._frame_buffer2,
241-
self._frame_buffer1,
242-
len(self._frame_buffer1),
243-
lv.DISPLAY_RENDER_MODE.DIRECT # NOQA
244-
)
245247
# we don't need to set column and page addresses for the RGBBus.
246248
# The tx_params function in C code for the RGB Bus is a dummy
247249
# function that only has the purpose of keeping the API the same
@@ -252,28 +254,9 @@ def _init_bus(self):
252254
'_set_memory_location',
253255
self._dummy_set_memory_location
254256
)
255-
else:
256-
full_screen_size = (
257-
self.display_width *
258-
self.display_height *
259-
lv.color_format_get_size(self._color_space)
260-
)
261-
if full_screen_size == len(self._frame_buffer1):
262-
render_mode = lv.DISPLAY_RENDER_MODE.FULL # NOQA
263-
else:
264-
render_mode = lv.DISPLAY_RENDER_MODE.PARTIAL # NOQA
265-
266-
self._disp_drv.set_buffers(
267-
self._frame_buffer1,
268-
self._frame_buffer2,
269-
len(self._frame_buffer1),
270-
render_mode
271-
)
272257

273258
self._data_bus.register_callback(self._flush_ready_cb)
274-
275259
self.set_default()
276-
277260
self._disp_drv.add_event_cb(
278261
self._on_size_change,
279262
lv.EVENT.RESOLUTION_CHANGED, # NOQA
@@ -292,34 +275,7 @@ def _on_size_change(self, _):
292275

293276
self._rotation = rotation
294277

295-
if self._disp_drv.sw_rotate:
296-
rotation *= 900
297-
298-
for layer in (
299-
self._disp_drv.get_layer_top(),
300-
self._disp_drv.get_layer_sys(),
301-
self._disp_drv.layer_bottom()
302-
):
303-
layer.update_layout()
304-
width = layer.get_width()
305-
height = layer.get_height()
306-
307-
layer.set_style_transform_pivot_x(int(width / 2), 0)
308-
layer.set_style_transform_pivot_y(int(height / 2), 0)
309-
layer.set_style_transform_rotation(rotation, 0)
310-
311-
for i in range(self._disp_drv.screen_cnt):
312-
scrn = self._disp_drv.screens[i]
313-
314-
scrn.update_layout()
315-
width = scrn.get_width()
316-
height = scrn.get_height()
317-
318-
scrn.set_style_transform_pivot_x(int(width / 2), 0)
319-
scrn.set_style_transform_pivot_y(int(height / 2), 0)
320-
scrn.set_style_transform_rotation(rotation, 0)
321-
322-
elif self._initilized:
278+
if not isinstance(self._data_bus, lcd_bus.RGBBus) and self._initilized:
323279
self._param_buf[0] = (self._madctl(
324280
self._color_byte_order, self._ORIENTATION_TABLE, ~rotation
325281
))

ext_mod/lcd_bus/esp32_src/rgb_bus.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -384,14 +384,6 @@
384384
#endif
385385
mp_lcd_rgb_bus_obj_t *self = (mp_lcd_rgb_bus_obj_t *)obj;
386386

387-
if (buffer_size != self->buffer_size) {
388-
mp_raise_msg_varg(
389-
&mp_type_ValueError,
390-
MP_ERROR_TEXT("Frame buffer size is not correct for the display size (%d)"),
391-
buffer_size
392-
);
393-
}
394-
395387
if (bpp == 16 && rgb565_byte_swap) {
396388
/*
397389
We change the pins aound when the bus width is 16 and wanting to
@@ -433,7 +425,6 @@
433425
printf("h_res=%lu\n", self->panel_io_config.timings.h_res);
434426
printf("v_res=%lu\n", self->panel_io_config.timings.v_res);
435427
printf("bits_per_pixel=%d\n", self->panel_io_config.bits_per_pixel);
436-
printf("bounce_buffer_size_px=%d\n", self->panel_io_config.bounce_buffer_size_px);
437428
printf("rgb565_byte_swap=%d\n", self->rgb565_byte_swap);
438429
#endif
439430
mp_lcd_err_t ret = esp_lcd_new_rgb_panel(&self->panel_io_config, &self->panel_handle);

0 commit comments

Comments
 (0)