Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: lv_disp_drv_t_flush_cb #290

Open
lbuque opened this issue Sep 17, 2023 · 2 comments
Open

KeyError: lv_disp_drv_t_flush_cb #290

lbuque opened this issue Sep 17, 2023 · 2 comments

Comments

@lbuque
Copy link

lbuque commented Sep 17, 2023

I want to use lvgl in rgb panel.

lv_micropython: master
lv_binding: https://github.com/imliubo/lv_binding_micropython/tree/dev_esp32_s3
esp-idf: v4.4.1

import lvgl as lv
import tft_config
# import lv_utils

tft = tft_config.config()

def disp_drv_flush_cb(disp_drv, area, color_p):
    print("hahah")
    w = (area.x2-area.x1+1)
    h = (area.y2-area.y1+1)
    tft.bitmap(
        area.x1,
        area.y1,
        area.x2,
        area.y2,
        disp_drv.draw_buf.buf_act.__dereference__(2*w*h)
    )
    disp_drv.flush_ready()

lv.init()
# if not lv_utils.event_loop.is_running():
#     event_loop=lv_utils.event_loop()
#     print(event_loop.is_running())

# create a display 0 buffer
disp_buf0 = lv.disp_draw_buf_t()
buf1_0 = bytearray(480 * 10)
disp_buf0.init(buf1_0, None, len(buf1_0) // lv.color_t.__SIZE__)

# register display 0 driver
disp_drv_0 = lv.disp_drv_t()
disp_drv_0.init()
disp_drv_0.draw_buf = disp_buf0
disp_drv_0.flush_cb = disp_drv_flush_cb
disp_drv_0.hor_res = 480
disp_drv_0.ver_res = 272
disp_drv_0.user_data = {"display_index": 0}
disp = disp_drv_0.register()

lv.disp_t.set_default(disp)

scr0 = lv.obj()
# create button widget on screen 0
btn0 = lv.btn(scr0)
btn0.align(lv.ALIGN.CENTER, 0, -50)
label0 = lv.label(btn0)
label0.set_text("LVGL Screen 0")
lv.scr_load(scr0)

while True:
    lv.task_handler()

Running the above code, I get the following error:

Traceback (most recent call last):
  File "<stdin>", line 51, in <module>
KeyError: lv_disp_drv_t_flush_cb

Did I do something wrong there?

@amirgon
Copy link
Collaborator

amirgon commented Sep 17, 2023

Did I do something wrong there?

Remove this line:

disp_drv_0.user_data = {"display_index": 0}

user_data is used internally by MP binding when handling callbacks.

@amirgon amirgon closed this as completed Sep 17, 2023
@amirgon amirgon reopened this Sep 17, 2023
@PGNetHun
Copy link
Collaborator

@lbuque
do you still have question/problem regarding this, or can I close the ticket?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants