Skip to content
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

Add back CONFIG_LV_COLOR_16_SWAP #6104

Closed
XuNeo opened this issue Apr 22, 2024 · 10 comments · Fixed by #6225
Closed

Add back CONFIG_LV_COLOR_16_SWAP #6104

XuNeo opened this issue Apr 22, 2024 · 10 comments · Fixed by #6225
Labels

Comments

@XuNeo
Copy link
Collaborator

XuNeo commented Apr 22, 2024

Introduce the problem

While migrating all existing project using lvgl on Nuttx, apache/nuttx#11780, many configurations have enabled CONFIG_LV_COLOR_16_SWAP. It may be a common issue others will face too.

nuttx/boards/risc-v/esp32c3-legacy/esp32c3-devkit/configs/lvgl/defconfig:38:CONFIG_LV_COLOR_16_SWAP=y
nuttx/boards/xtensa/esp32/esp32-2432S028/configs/lvgl/defconfig:39:CONFIG_LV_COLOR_16_SWAP=y
nuttx/boards/xtensa/esp32/esp32-wrover-kit/configs/lvgl/defconfig:44:CONFIG_LV_COLOR_16_SWAP=y
nuttx/boards/xtensa/esp32s2/esp32s2-kaluga-1/configs/lvgl_ili9341/defconfig:42:CONFIG_LV_COLOR_16_SWAP=y
nuttx/boards/xtensa/esp32s2/esp32s2-kaluga-1/configs/lvgl_st7789/defconfig:44:CONFIG_LV_COLOR_16_SWAP=y
nuttx/boards/xtensa/esp32s3/esp32s3-box/configs/lvgl-3/defconfig:56:CONFIG_LV_COLOR_16_SWAP=y
nuttx/boards/xtensa/esp32s3/esp32s3-box/configs/lvgl/defconfig:59:CONFIG_LV_COLOR_16_SWAP=y
nuttx/boards/xtensa/esp32/ttgo_t_display_esp32/configs/lvgl_lcd/defconfig:45:CONFIG_LV_COLOR_16_SWAP=y
nuttx/defconfig:39:CONFIG_LV_COLOR_16_SWAP=y

Proposal

Add equivalent configuration option CONFIG_LV_COLOR_16_SW_SWAP that does the swap by software just before flush_cb by calling lv_draw_sw_rgb565_swap.

Update existing configuration to use CONFIG_LV_COLOR_16_SW_SWAP instead.

@kisvegabor
Copy link
Member

The main purpose of this would be backward compatibility or ease of use?

@XuNeo
Copy link
Collaborator Author

XuNeo commented Apr 24, 2024

Mainly for backward compatibility. Without CONFIG_LV_COLOR_16_SW_SWAP , those listed configurations will be break in lvgl v9 and it's tough for me to upgrade all LCD drivers to support hardware swap.

@kisvegabor
Copy link
Member

Makes sense, can you prepare a PR?

@FASTSHIFT
Copy link
Collaborator

If the LCD driver does not support the endian setting, the SPI can be switched to Bit Order set to MSB FIRST+16bit mode when sending the image buffer with DMA, and then switched to 8bit mode after sending, so that the code is simple and efficient.
I believe most MCUs can support this mode.

See:
65794137df908305e3d853e35e97324

MVIMG_20240429_000014

@XuNeo
Copy link
Collaborator Author

XuNeo commented Apr 29, 2024

Nice work.

Calling lv_draw_sw_rgb565_swap also has limitation. It performs byte order swap in place, thus needs to swap back before drawing next frame.

@kisvegabor
Copy link
Member

It performs byte order swap in place, thus needs to swap back before drawing next frame.

Why? The buffer into which the UI drawn is dropped after sending the image. Or do you use LVGL in direct mode?

@XuNeo
Copy link
Collaborator Author

XuNeo commented Apr 29, 2024

Yes, we have to consider direct mode too.

@kisvegabor
Copy link
Member

In this case we should swap the bytes only on a given area. Adding lv_draw_sw_rgb565_swap_area can be useful.

@lvgl-bot
Copy link

We need some feedback on this issue.

Now we mark this as "stale" because there was no activity here for 14 days.

Remove the "stale" label or comment else this will be closed in 7 days.

@kisvegabor
Copy link
Member

I've opened #6225

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants