Closed eudoxos closed 2 years ago
In general issues/PRs to LVGL C API should be opened under https://github.com/lvgl/lvgl.
But are you sure this is needed in this case? Why not compare buf_act
in Python?
buf1_active = (draw_buf.buf_act == draw_buf.buf1)
I've just added a very simple fix to allow that.
In general issues/PRs to LVGL C API should be opened under https://github.com/lvgl/lvgl.
Right, I just was not sure if this was not more python-related. And it was actually. Your solution is perfect. I need to check better the API for Blob.
Actually, I can just use __dereference__
to get memoryview
on the current buffer (based on this post of yours), without keeping the buffers around as python objects... (as you see, I love the :=
operator in python ;) )
disp_draw_buf=lv.disp_draw_buf_t()
disp_draw_buf.init(fb1:=bytearray(HRES*2*32),bytearray(HRES*2*32),len(fb1)//lv.color_t.__SIZE__)
def disp_drv_flush_cb(disp_drv,area,color):
lcd.blit(area.x1,area.y1,w:=(area.x2-area.x1+1),h:=(area.y2-area.y1+1),disp_drv.draw_buf.buf_act.__dereference__(2*w*h),is_blocking=False)
disp_drv.flush_ready()
...
Actually, I can just use
__dereference__
to getmemoryview
on the current buffer
Right. Blob
and Struct
in lv_bindings context are really nothing more than thin wrappers around a C pointer.
Closing - please reopen if there are any further problems.
lv_disp_draw_buf_t
has thebuf_act
pointer which is swapped as buffers are used in alternation when double-buffering. Please consider making the information about which buffer is active available to Python (perhaps a a bool, returningbuf_act==buf1
). Otherwise pure-python display drivers have to track that in python-side variable independently, as e.g. here.I have a tentative fix which looks like this (in
src/hal/lv_hal_disp.c
) but perhaps there is some way for this already?