@@ -435,18 +435,24 @@ class St77xx_lvgl(object):
435435 * sets the driver callback to the disp_drv_flush_cb method.
436436
437437 '''
438- def disp_drv_flush_cb (self ,disp_drv ,area ,color ):
438+ def disp_drv_flush_cb (self ,disp_drv ,area ,color_p ):
439439 # print(f"({area.x1},{area.y1}..{area.x2},{area.y2})")
440440 self .rp2_wait_dma () # wait if not yet done and DMA is being used
441441 # blit in background
442- self .blit (area .x1 ,area .y1 ,w := (area .x2 - area .x1 + 1 ),h := (area .y2 - area .y1 + 1 ),color .__dereference__ (2 * w * h ),is_blocking = False )
442+ size = w * h
443+ data_view = color_p .__dereference__ (size * self .pixel_size )
444+ if self .rgb565_swap_func :
445+ self .rgb565_swap_func (data_view , size )
446+ self .blit (area .x1 ,area .y1 ,w := (area .x2 - area .x1 + 1 ),h := (area .y2 - area .y1 + 1 ),data_view ,is_blocking = False )
443447 self .disp_drv .flush_ready ()
444448
445449 def __init__ (self ,doublebuffer = True ,factor = 4 ):
446450 import lvgl as lv
447451 import lv_utils
448452
449453 color_format = lv .COLOR_FORMAT .RGB565
454+ self .pixel_size = lv .color_format_get_size (color_format )
455+ self .rgb565_swap_func = None if self .bgr else lv .draw_sw_rgb565_swap
450456
451457 if not lv .is_initialized (): lv .init ()
452458
0 commit comments