lv_binding_micropython icon indicating copy to clipboard operation
lv_binding_micropython copied to clipboard

About a basic guide to my own C code for LVGL binding compatibility

Open bhcuong2008 opened this issue 8 months ago • 2 comments

Hi,

This is not a bug/issue report. I dont know where to post my issue. I want to write an C/C++ code application for interacting with sensors, collecting its data. Its data is already at C/C++ side. I need binding it to MicroPython side, so that uPy code can use its data natively, or attach uPy function callback to C/C++ sensor app side. When getting a new sensor data at C/C++ side, uPy callback will be called for further processing. Actually it would be the same LVGL, but it's too large for me to follow.

I've already read these 2 guides, but still can't master it. Section of ESPIDF is useful for me to learn. But I need a guideline to code my C/C++ app like LVGL so that MicroPython binding process is smooth during development and maintenance in future. If having a small C/C++ example with steps to run gen_mpy.py for generating mp module is really graceful.

https://blog.lvgl.io/2019-02-20/micropython-bindings https://blog.lvgl.io/2019-08-05/micropython-pure-display-driver

Thank you so much.

bhcuong2008 avatar Apr 25 '25 09:04 bhcuong2008

The script gen_mpy.py generates a class C_Pointer. What is its usage? The script also generates a lot.

>>> help(lv.C_Pointer)
object <class 'C_Pointer'> is of type type
  __SIZE__ -- 4
>>> 

bhcuong2008 avatar Apr 25 '25 13:04 bhcuong2008

In this file, https://github.com/lvgl/lv_binding_micropython/blob/master/README.md, section Callback, it says that There's a struct that contains a field called void * user_data

It means that in my C code struct must have a field void * user_data for supporting callback? I could not catch this idea.

bhcuong2008 avatar Apr 25 '25 14:04 bhcuong2008