How to use simulator with latest LVGL version?

For future reference:

platformio.ini:

; PlatformIO Project Configuration File
;
;   Build options: build flags, source filter
;   Upload options: custom upload port, speed and extra flags
;   Library options: dependencies, extra library storages
;   Advanced options: extra scripting
;
; Please visit documentation for the other options and examples
; http://docs.platformio.org/page/projectconf.html

[platformio]
default_envs = emulator_64bits

; Shared options
[env]
build_flags =
  -D LV_CONF_INCLUDE_SIMPLE
  ; Add more defines below to overide lvgl:/src/lv_conf_simple.h
lib_deps =
    git+https://github.com/lvgl/lvgl.git
lib_archive = false


[env:emulator_64bits]
platform = native@^1.1.3
extra_scripts = support/sdl2_build_extra.py
build_flags =
  ${env.build_flags}
  -D LV_LOG_LEVEL=LV_LOG_LEVEL_INFO
  -D LV_LOG_PRINTF=1
  ; Add recursive dirs for hal headers search
  !python -c "import os; print(' '.join(['-I {}'.format(i[0].replace('\x5C','/')) for i in os.walk('hal/sdl2')]))"
  -lSDL2
  ; SDL drivers options
  -D LV_LVGL_H_INCLUDE_SIMPLE
  -D LV_CONF_INCLUDE_SIMPLE
  -D USE_SDL
  -I src
lib_deps =
  ${env.lib_deps}
  git+https://github.com/lvgl/lv_drivers.git
src_filter =
  +<*>
  +<../hal/sdl2>


[env:emulator_32bits]
extends = env:emulator_64bits
build_flags =
  ${env:emulator_64bits.build_flags}
  -m32


[env:stm32f429_disco]
platform = ststm32@^8.0.0
board = disco_f429zi
framework = stm32cube
build_flags =
  ${env.build_flags}
  -D LV_LOG_LEVEL=LV_LOG_LEVEL_NONE
  ; header's default is 25MHz, but board uses 8MHz crystal
  -D HSE_VALUE=8000000
  ; Add recursive dirs for hal headers search
  !python -c "import os; print(' '.join(['-I {}'.format(i[0].replace('\x5C','/')) for i in os.walk('hal/stm32f429_disco')]))"
lib_deps =
  ${env.lib_deps}
  BSP-ili9341
  BSP-stmpe811
src_filter =
  +<*>
  +<../hal/stm32f429_disco>

I also had to copy the lv_conf_template.h and lv_drv_conf_template.h header files as lv_conf.h and lv_drv_conf.h.

In app_hal.c I had to remove all the old monitor/mouse/keyboard header files, and added #include "sdl/sdl.h" and #include "lvgl.h".

I had to replace the monitor/mouse functions by SDL functions:

  • sdl_init() instead of monitor_init()
  • sdl_display_flush() instead of monitor_flush()
  • sdl_mouse_read() instead of mouse_read()

I had to fix some types that were renamed in v8 I guess:

  • lv_disp_draw_buf_t instead of lv_disp_buf_t
  • disp_drv.draw_buf instead of disp_drv.buffer

Made some variables static:

  • disp_drv
  • indev_drv

Initialized the following variables:

    disp_drv.hor_res = SCREEN_WIDTH;
    disp_drv.ver_res = SCREEN_HEIGHT;

Also added those definitions to have a 480x320 screen resolution.

I don’t remember if I had to change anything else. Unfortunately I downloaded the simulator as a zip from Github instead of cloning the repo, so I don’t have the diffs.

I hope this is of help to somebody else :slight_smile:

1 Like