Lvgl init and driver register

HI:
can i use lvgl like this?
lvgl initialization and driver registration in C

lv_init();
lv_port_disp_init();
lv_port_indev_init();

and used a hardware timer, in timer irq call

void TIM3_IRQHandler(void) {

  HAL_TIM_IRQHandler(&TimHandle);

  lv_tick_inc(1);

  lv_timer_handler();

}

Drawing the screen with micropython

Screen1 = lv.obj()

SetFlag(Screen1, lv.obj.FLAG.SCROLLABLE, False)

Screen1.set_scrollbar_mode(lv.SCROLLBAR_MODE.AUTO)

Screen1.set_scroll_dir(lv.DIR.ALL)

Hi @dahuanzi !

lv_port_disp_init and lv_port_indev_init are not part of core LVGL.
They are part of specific LVGL ports for specific drivers and architectures.

lv_micropython is a Micropython fork with core LVGL and does not include specific LVGL ports.
Therefore lv_port_disp_init and lv_port_indev_init are not available in lv_micropython.
Instead, it provides Python (or hybrid C/Python) drivers for different devices and architectures (such as ili9341 and ili9488 for esp32, ft5336 for STM32F7DISC, SDL and FB for linux etc.)

The main advantage of Python drivers over C drivers is the way they are configured. To change the configuration of C drivers you have to rebuild the firmware upon every configuration change (such as changing IO pins, changing display parameters etc.). On the other hand, on Micropython drivers you set all parameters on runtime from your Python script and there is no need to rebuild the firmware when you change anything.

So the idea is to have a single Micropython firmware image that could be used with different hardware devices and different configurations, and that’s the main reason Python drivers is the preferred approach.

But if you still want to use your own C drivers in lv_micropython, you can still do it.
You would need to:

  • Build lv_micropython with your C driver. This requires changing the build script to compile and link your C driver into the Micropython firmware image.
  • Create a Micropython binding to your C driver API.
    This is usually very easy because the Micropython bindings are automatically generated. All you really need to do is to include your driver API C header from lvgl.h (or from any other header included from lvgl.h). The binding script would consider your driver API to be part of LVGL and automatically generate the code to allow you to call it from Micropython