LVGL v9.1 on Nintendo switch

  • Thread starter Thread starter fiszu123
  • Start date Start date
  • Views Views 2,662
  • Replies Replies 12
  • Likes Likes 4

fiszu123

Member
Newcomer
Joined
Aug 2, 2024
Messages
8
Reaction score
14
Trophies
0
Age
36
XP
71
Country
Poland
For people who want to create applications for Nintendo Switch. I present the ported LVGL in the latest version for Nintendo Switch.
Anyone who knows LVGL knows how easy and pleasant it is to create UI at squareline

https://github.com/JakubRybakowski/DEVKITPRO-NX-LVGL-EXAMPLE


Anyone who has tried to create applications for a switch knows how difficult it is to create a GUI. That's why many great apps still use text-based versions or simple ugly UIs.

LVGL allows you to use SquareLine or similar programs to create UI via drag & drop.


Currently, SDL acceleration is not supported in the main LVGL repository, but I saw that there is a PR on github that fixes this bug. So soon we will be able to create beautiful UIs even at 60FPS.

Plus LVGL have a lot of great libraries to support BMP JPEG PNG GIF FreeFont QRCode FFmpeg and filesystems.



Zrzut ekranu 2024-08-2 o 14.51.54.png



example.png
Zrzut ekranu 2024-08-2 o 15.11.54.png
Zrzut ekranu 2024-08-2 o 15.16.24.png
20240802_152057.jpg

Without acceleration 14 FPS, but when I tested with acceleration it was 60 FPS without any problems.
 
Last edited by fiszu123,
Well done!

"Find" errors are a misconfigured makefile. Nothing important. Then maybe I'll fix it.

Unused variable, nothing important either. You can hide them or ignore them. This must be improved by the lvgl team.

The last error is the missing "drive" folder. Squarline can export compressed png images to "drive" folder as romfs. Github removed this folder because it is empty. You can add it or disable romfs from the makefile.

minimum requirements are this libs: SDL2_image SDL2_mixer turbojpeg webp png16. I don't know what they are called in the devkit. But you can check if you want.
 
Last edited by fiszu123,
Another minor issue, the generated NSO do not uses icon.jpg nor .NACP file, so the resultan NRO, do not have name nor icon:

1722619982332.png


I built manually a NRO with correct parameters and:

1722620092667.png
 
This is just an example how to use LVGL. The icon and name are not important, but they should work.
Yes the no use of icon and NACP was because the drive folder, created before build and everything goes right!
Post automatically merged:

Perfect I just create a Blank DevProKit environment using MSYS and the minimum packages needed are:
  • git
  • make
  • devkitA64
  • switch-tools
  • libnx
  • switch-sdl2_image
  • switch-sdl2_mixer
  • switch-libjpeg-turbo
  • switch-libwebp
  • switch-libpng


On MSYS you can install them using the command:
Bash:
pacman -Syuu --needed --noconfirm git make devkitA64 switch-tools libnx switch-sdl2_image switch-sdl2_mixer switch-libjpeg-turbo switch-libwebp switch-libpng

With the next commands you can build the package on the environment.
Bash:
cd ~
rm -rf DEVKITPRO-NX-LVGL-EXAMPLE
git clone --recursive https://github.com/JakubRybakowski/DEVKITPRO-NX-LVGL-EXAMPLE
cd ~/DEVKITPRO-NX-LVGL-EXAMPLE
mkdir drive
make -j



For Linux you need git, make and DevKitPro setup, then you can run the commands:

Bash:
sudo dkp-pacman -Syuu --needed --noconfirm git make devkitA64 switch-tools libnx switch-sdl2_image switch-sdl2_mixer switch-libjpeg-turbo switch-libwebp switch-libpng

cd ~
rm -rf DEVKITPRO-NX-LVGL-EXAMPLE
git clone --recursive https://github.com/JakubRybakowski/DEVKITPRO-NX-LVGL-EXAMPLE
cd ~/DEVKITPRO-NX-LVGL-EXAMPLE
mkdir drive
make -j
Post automatically merged:

About the «empty» folder on github you can create a folder with only a file called «.gitignore» which may contain:

Code:
# Ignore everything in this directory
*
# Except this file
!.gitignore

https://stackoverflow.com/questions/115983/how-do-i-add-an-empty-directory-to-a-git-repository
 
Last edited by impeeza,
Well done!
As for the empty folder, I disabled romfs in the makefile. It is not needed for anything, so this folder is not needed anymore.

I can also confirm that the build runs correctly on macOS ARM.
Post automatically merged:

Also, the library -lturbojpeg in the makefile is not needed. You can safely remove it from the makefile if you want. It's not LVGL compatible anyway. I'm using the PNG library.
 
Last edited by fiszu123,
  • Love
Reactions: impeeza
Temporary fix for SDL acceleration:
Works well on 60FPS.


Enable in lv_conf.h
/* Draw using cached SDL textures*/
#define LV_USE_DRAW_SDL 1


lvgl/src/draw/sdl/lv_draw_sdl.c in draw_to_texture() change to this code:

case LV_DRAW_TASK_TYPE_IMAGE: {
lv_draw_image_dsc_t image_dsc;
lv_draw_image_dsc_init(&image_dsc);
lv_memcpy(&image_dsc, task->draw_dsc, sizeof(image_dsc));
image_dsc.base.user_data = lv_sdl_window_get_renderer(disp);
lv_draw_image(&dest_layer, &image_dsc, &task->area);
break;
}
 
Ok so I found a way to fully accelerate SDL:


lv_conf.h:
/* Draw using cached SDL textures*/
#define LV_USE_DRAW_SDL 0


lv_sdl_window.c line 323:
dsc->renderer = SDL_CreateRenderer(dsc->window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC);


this is fixed in lvgl 9.2 with flag LV_SDL_ACCELERATED but now squareline studio don't support 9.2 for now.


And i added benchmark for 9.2 at lvgl9.2 branch
 
Last edited by fiszu123,

Site & Scene News

Popular threads in this forum