-
Notifications
You must be signed in to change notification settings - Fork 163
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
Integration as external c module with unmodified micropython. #242
base: master
Are you sure you want to change the base?
Conversation
Thank you @andrewleech for this contribution! I would like to adapt this change in lv_micropython. I'm trying to keep lv_micropython aligned to official Micropython releases. Latest release v1.19 does not yet contain these breaking API changes that you fixed (
|
b4f481b
to
f4df5db
Compare
Hi @amirgon , ah yes I'd been watching that PR and it certainly looks like a worthy change, hopefully it can be ready for merge soon! I see there's a few failing unit tests there, that on its own would be enough to block merge :-( perhaps adding a But in the mean time yes there's no harm in working from a fork of upstream (with minimal change) I often do this at work when I'm using new features I'm writing! I suspect a new realease of Micropython may be imminent, so it's probably fine to hold off with this until that's released - there's probably a few things to clean up with the PR anyway. Most notably; I'm failing to get esp32 to build. I've fixed the way root pointers are handled and updated the cmake scripts enough to support the rp2 build but am getting tripped up on the esp32 one. It's giving cmake failures like:
however adding some status messages shows that the |
Hi, @andrewleech Any updates on this Topic?
|
I'm pretty sure I got rp2 working, but esp cmake is weirdly different to rp2 and I never managed to make it build. I generally really dislike esp. I've never had a good experience with them, always crashing / Guru Meditation Error anytime I try to do anything interesting. I'm also not a huge cmake fan, things there just seem even harder to get working than Makefile, though maybe that's just me. As such I'm really not motivated to get esp working... I'm always going to choose rp2 or stm for my projects. But as for the MR, well micropython v1.20 hasn't been released yet (there's some upstream rp2 ble issues getting in the way) but once it does I'll probably try to get this rebased and ready to go... for some platforms at least! |
@andrewleech I'm starting to look at this in the context of #272. Why did you choose to register root pointers with I imagined calling the Also, instead of tweaking My plan is to first align to Micropython v1.20.0 without an external C module. |
Sounds great @amirgon ! I'm pretty sure when I first did this, I'm not sure I follow your other comments about init, but I was aiming to not change the current end user usage of lvgl with my PR, trying to ensure any init things were called automatically at an appropriate time. Having a seperate / manual init function might make sense, certainly of there's times you might want to reuse it after soft reset etc. As long as things don't segfault if it's accidentally not run beforehand. Working on that PR was the first time I used lvgl at all though so I was figuring out a lot as I went through it, probably did some things wrong! |
@andrewleech - lv_binding_micropython is now aligned to Micropython v1.20.0, see #272, lvgl/lv_micropython#65 Would you like to rebase this PR? |
Nice work! Yep I'll rebase mine when I get a chance. I did have Unix/stm tested and working... though stm was quite unstable for me. That's probably something wrong with the driver I wrote for my board. |
@andrewleech @amirgon progress on this? need help to complete some tasks? |
No I haven't rebased / reworked it for the updated micropython yet; too many projects / too little time. I never got it working with esp either. I'm definitely keen to still see this updated and working! |
@andrewleech Here are the changes https://github.com/Carglglz/lv_binding_micropython/tree/userCmod |
@Carglglz I tried your code (on esp32) and have some issues with it:
|
@MathyV thanks for testing this!
That makes sense, my knowledge in Cmake / esp-idf is limited, so I'm not 100 % sure that everything in
Yes I tried to implement those drivers in the build too, but then I realised that they were written with IDF-v4.x and now MicroPython is at IDF-v5.x. So they need to be updated first, which right now it is out of my scope. In the meantime I've been looking at the drivers at https://github.com/kdschlosser/lvgl_micropython and https://github.com/bdbarnett/mpdisplay, which seem promising. Let me know if you get it working. I'm mostly developing/testing on unix port, on a esp32 I've only tested this with a "dummy" display, i.e. just writing the buffers and it seems to work... see https://docs.lvgl.io/master/porting/display.html# |
I confirm this is working on esp32 with the drivers at https://github.com/bdbarnett/mpdisplay, in any case I think the drivers shouId be independent from the bindings so people can choose/implement its own... |
Allow using `MICROPY_MALLOC_USES_ALLOCATED_SIZE` option required to build `lv_bindings_micropython` with upstream MicroPython. Required for lvgl/lv_binding_micropython#242
OK so the only thing you are wanting to do is provide LVGL as a user C module. The user would be responsible for writing and implementing their own drivers for the bus and for the display IC and proper handling of flushing the display buffer. I was expecting the functionality to be the same as it is right now. |
Yes exactly, and that's the logic behind the specific test split in The functionality doesn't change at all if using In the future example board definitions could be added to showcase how to add the |
f4df5db
to
fe60d69
Compare
Fix to allow using lv_utils with asyncio when Timer not available.
Properly handle root pointers on lvgl init/deinit which fixes init error after a soft reset (see lvgl#343).
d4a6552
to
50a99c3
Compare
c01d7e0
to
755d385
Compare
Hi @andrewleech, Thank you very much for this PR! It has allowed me to use LVGL9 on MicroPython 1.23.0 and run it successfully on the ESP32 development board. However, when I use Squareline to generate UI files (ui_images.py.txt, ui.py.txt) compatible with MicroPython, it produces the following error. MicroPython v1.23.0-4.gf4ec8a07c.dirty on 2024-11-11; linux [GCC 11.4.0] version
Use Ctrl-D to exit, Ctrl-E for paste mode
# First try
>>> import ui
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/x/Desktop/work/repository/work/MicroPython/scripts/ui.py", line 10, in <module>
AttributeError: 'module' object has no attribute 'theme_simple_init'
# After comment out these code: `theme = lv.theme_simple_init(dispp)` `dispp.set_theme(theme)`
>>> import ui
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/x/Desktop/work/repository/work/MicroPython/scripts/ui.py", line 651, in <module>
SyntaxError: Cannot convert 'function' to pointer! I found that some APIs are indeed missing in the generated // This PR
static mp_obj_t mp_lv_obj_add_event_cb(size_t mp_n_args, const mp_obj_t *mp_args, void *lv_func_ptr)
{
...
lv_event_cb_t event_cb = mp_to_ptr(mp_args[1]);
...
}
// Official
STATIC mp_obj_t mp_lv_obj_add_event_cb(size_t mp_n_args, const mp_obj_t *mp_args, void *lv_func_ptr)
{
...
void *event_cb = mp_lv_callback(mp_args[1], &lv_obj_add_event_cb_event_cb_callback, MP_QSTR_lv_obj_add_event_cb_event_cb, &user_data, NULL, (mp_lv_get_user_data)NULL, (mp_lv_set_user_data)NULL);
...
} Could you help further improve it? Thank you very much! |
Hi @Lzw655 that's interesting, how did you build it? I haven't managed to successfully compile for esp32. This PR is very much still in progress, I've been integrating the excellent additions done by @Carglglz and trying to simplify the build and integration processes. Update: Ah, I see, the failures I'm getting are like this:
I've figured out this is a problem when using IDF 5.2.2 (the current default version I use). However this failure doesn't occur on IDF 5.0.4 or 5.1.1 |
@andrewleech I encountered the same issue. You can add this code snippet after here to resolve it. (example) idf_build_get_property(component_targets __COMPONENT_TARGETS)
string(REPLACE "___idf_lvgl" "" component_targets "${component_targets}")
idf_build_set_property(__COMPONENT_TARGETS "${component_targets}") |
@Lzw655 Oh strange, how did you come up with that snippet? I'm not yet sure of the IDF change that's triggering this issue (5.1.1 works, 5.1.5 does not). |
I located the issue through the error message, identifying that, for some reason, the IDF recognized LVGL as a component. This code snippet detaches LVGL from the components to resolve it. And I compiled it directly on IDF v5.2.2 without trying other versions. So I'm not sure how it would perform on other versions. |
No apology necessary, that information really helps. |
Great! And I found that the following error was caused by updating LVGL to v9.2.2. When I reverted to the original version, the error no longer occurred. Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/x/Desktop/work/repository/work/MicroPython/scripts/ui.py", line 651, in <module>
SyntaxError: Cannot convert 'function' to pointer! |
@Lzw655 I've just updated my PR with your fix 🚀 (Thanks!) It seems the fix also works here Carglglz@4ff1ea9, i.e. no need to modify micropython esp32 cmake file. 👍🏼 |
…nit/deinit." This reverts commit 451faee.
This PR provides changes that allow
lv_binding_micropython
to be used as an External C Module with un-modified / upstream micropython.This takes advantage of the relativly new macro
MP_REGISTER_ROOT_POINTER
to remove the need to manually include the LV roots in the mpconfigport.h files.Other port-specific settings can be added to
micropython.mk
andmicropython.cmake
An example of usage to build a project can be found here: https://github.com/andrewleech/lvgl_mpy_example
Note: I've currently only tested on stm32 and unix - I have not yet built for esp32 or any other cmake based port.
It also includes an update to the binding generator script to support the new types syntax in current upstream micropython, for details see: https://github.com/micropython/micropython/wiki/Build-Troubleshooting#define_const_obj_type