Updating from lvgl V6 to V7

Hello!
I am porting my project from lvgl v6 to the latest available using https://github.com/lvgl/lv_micropython
I am using an M5stack fire (esp32 with spram) and for some reason now I am getting “AttributeError: ‘module’ object has no attribute ‘indev_drv_init’” (this was working before). Any reason for this? I looked around to see if this was changed but can’t find any evidence.
Also getting some missing attributes like AttributeError: ‘module’ object has no attribute ‘pcnt_unit_config’ which was also working and I am almost sure it was supposed to be present in the latest espidf version. Anyone else with this problem?
Thank you!

Hi @Tiago_Almeida!

Version 7 contains some breaking changes and require you to change your code.

A new feature is “struct functions”: when a function can be associated with a struct it is now a member function of that struct.

In your case, for example, init is now a member function of indev_drv_t. same with pcnt.
See how display and touch drivers are initialized on lv_binding_micropython README.

1 Like

Ah ! Brilliant, those are working now thank you!

What about tasks? When we want to run a task only once I used to do, for example, lv.task_once(task1) but now I am getting AttributeError: ‘module’ object has no attribute ‘task_once’. I was supposing that it was the same case and that now I would do something like task1.task_once() or task1.once() but it is not working.
How can I make a task run only once in V7?

In v.7 you need to call set_repeat_count(1).
set_repeat_count is a member function of task.

1 Like

Thanks! I figure it out meanwhile comparing documentations. But in V7 docs task_once is still there. But on the API is right.
But task_once() would delete the task in the end. Does set_repeat_count do it?

If not, how do you delete a task now? I can see that you have the del() method. But doing task.del() reports wrong syntax.

It’s still in the docs, but only exists as a compatibility layer with v6.
In lv_binding_micropython this compatibility layer is disabled. You can enable it if you want by setting LV_USE_API_EXTENSION_V6 in lv_conf.h

Yes. See lv_task_exec.

This is a good catch.
del is a reserved word in Python, so task.del would give you an error.
I would need to fix the binding script to rename “del” to “delete” in such cases, but until then you can do something like this:

del_func = getattr(task, 'del')
del_func()