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

LVGL embedded GUI library #603

Merged
merged 5 commits into from
Apr 6, 2021
Merged

LVGL embedded GUI library #603

merged 5 commits into from
Apr 6, 2021

Conversation

rleh
Copy link
Member

@rleh rleh commented Apr 1, 2021

  • Add LVGL as submodule
  • LVGL debug-log integration into modm logging
  • Example for STM32F469-Disco board
    • Cleanup
    • Use touchscreen in this example
  • Example for Ili9341 and/or SSD1306 displays

@rleh rleh force-pushed the lvgl branch 3 times, most recently from ef0504a to cd84b7f Compare April 3, 2021 14:09
@rleh rleh marked this pull request as ready for review April 3, 2021 14:10
@rleh
Copy link
Member Author

rleh commented Apr 3, 2021

CI: Error generating documentation for device hosted-linux: 'NoneType' object is not subscriptable

Copy link
Member

@salkinium salkinium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll test in hardware and check why the docs generator is broken (yet again).

examples/nucleo_l452re/lvgl/main.cpp Outdated Show resolved Hide resolved
ext/lvgl/lvgl.lb Outdated Show resolved Hide resolved
ext/lvgl/lvgl.lb Outdated Show resolved Hide resolved
ext/lvgl/lv_conf.h.in Show resolved Hide resolved
@salkinium
Copy link
Member

I enabled DMA2D for the STM32 devices that have it. I don't see any visual difference in performance, but maybe it helps elsewhere.

Copy link
Member

@chris-durand chris-durand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

src/modm/driver/display/ili9341_impl.hpp Outdated Show resolved Hide resolved
ext/lvgl/lvgl.lb Outdated Show resolved Hide resolved
@rleh
Copy link
Member Author

rleh commented Apr 4, 2021

I enabled DMA2D for the STM32 devices that have it. I don't see any visual difference in performance, but maybe it helps elsewhere.

I have not enabled this on purpose and will disable it again because the user has to take care of configuring DMA2D/PXP manually and implementing gpu_fill_cb/gpu_blend_cb. If someone does that he can also enable DMA2D/PXP manually using lv_conf_user.h.

DMA2D would have to become a configurable option in any case, since it could possibly be used by a display driver as well.

@rleh rleh force-pushed the lvgl branch 2 times, most recently from 7c31019 to 1f7845b Compare April 4, 2021 18:40
ext/lvgl/lv_modm_logging.cpp Show resolved Hide resolved
ext/lvgl/lvgl.lb Show resolved Hide resolved
ext/lvgl/lvgl.lb Show resolved Hide resolved
ext/lvgl/lvgl.lb Show resolved Hide resolved
examples/stm32f469_discovery/lvgl/main.cpp Outdated Show resolved Hide resolved
Copy link
Member

@salkinium salkinium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!

@salkinium salkinium added the ci:hal Triggers the exhaustive HAL compile CI jobs label Apr 5, 2021
ext/lvgl/lvgl.lb Outdated

- https://lvgl.io/
- https://github.com/lvgl/lvgl
"""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, we should mention the lv_conf_local.h mechanism, I'll add a fixup commit in a second.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, there's a file called lv_conf_internal.h that contains a lot of defaults.

We should also implement LV_TICK_CUSTOM_SYS_TIME_EXPR to use modm::Clock::now to remove the need for a manual call to lv_tick_inc().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I've implemented and tested LV_TICK_CUSTOM_SYS_TIME_EXPR.

Copy link
Member

@salkinium salkinium Apr 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only other thing I found interesting in terms of a modm port was LV_ATTRIBUTE_FAST_MEM which we could set to __attribute__((sections(".fastcode"))). However, 15-20kB of RAM seems like a lot and would probably cause issues if set by default. So I didn't.

/* Prefix performance critical functions to place them into a faster memory (e.g RAM)
 * Uses 15-20 kB extra memory */
#define  LV_ATTRIBUTE_FAST_MEM

@salkinium
Copy link
Member

Ok, I've played around with the lv_conf.h. The lv_conf_internal.h defines default values for the entire config, so I've removed all definitions (and typedefs) from lv_conf.h that we did not change and moved the lv_conf_local.h before our config. There are two reasons for this:

  1. It removes the need for #undef since we're not double declaring the config. This is a very nice UX improvement.
  2. It makes it easier for us to upgrade LVGL in the future, since we only need to worry about the configs that we've changed, not all configs.

Is this config approach ok for you?

@salkinium
Copy link
Member

(Sorry about the fixup! mess, I'll happily squash this all together if you want).

@rleh rleh mentioned this pull request Apr 5, 2021
5 tasks
@rleh
Copy link
Member Author

rleh commented Apr 5, 2021

Ok, I've played around with the lv_conf.h. The lv_conf_internal.h defines default values for the entire config, so I've removed all definitions (and typedefs) from lv_conf.h that we did not change and moved the lv_conf_local.h before our config. There are two reasons for this:

1. It removes the need for `#undef` since we're not double declaring the config. This is a very nice UX improvement.

2. It makes it easier for us to upgrade LVGL in the future, since we only need to worry about the configs that we've changed, not _all_ configs.

Is this config approach ok for you?

Very nice, I like this approach. Thanks!

I built this PR on my attempts from >1 year ago with LittlevGL v5/v6, back then lv_conf_internal.h didn't exist as far as I remember; instead lv_conf.h was checked for completeness using lv_conf_checker.h.

Comment on lines 17 to 30
/*====================
Graphical settings
*====================*/

/* Maximal horizontal and vertical resolution to support by the library.*/
#define LV_HOR_RES_MAX ({{ options.resolution_horizontal_max }})
#define LV_VER_RES_MAX ({{ options.resolution_vertical_max }})

/* Color depth:
* - 1: 1 byte per pixel
* - 8: RGB332
* - 16: RGB565
* - 32: ARGB8888
*/
#define LV_COLOR_DEPTH {{ options.color_depth }}

/* Enable anti-aliasing (lines, and radiuses will be smoothed) */
#ifndef LV_ANTIALIAS
#define LV_ANTIALIAS 0
#endif

/* Dot Per Inch: used to initialize default sizes.
* E.g. a button with width = LV_DPI / 2 -> half inch wide
* (Not so important, you can adjust it to modify default sizes and spaces)*/
#define LV_DPI {{ options.dpi }} /*[px]*/

/* Type of coordinates. Should be `int16_t` (or `int32_t` for extreme cases) */
typedef int16_t lv_coord_t;

/*=========================
Memory manager settings
*=========================*/

/* 1: use custom malloc/free, 0: use the built-in `lv_mem_alloc` and `lv_mem_free` */
#define LV_MEM_CUSTOM 1

/*==================
* Feature usage
*==================*/

/* 1: Enable GPU interface*/
#ifndef LV_USE_GPU
#define LV_USE_GPU 0 /*Only enables `gpu_fill_cb` and `gpu_blend_cb` in the disp. drv- */
#endif

/* 1: Enable file system (might be required for images */
#ifndef LV_USE_FILESYSTEM
#define LV_USE_FILESYSTEM 0
#endif

Copy link
Member Author

@rleh rleh Apr 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also remove all this lbuild options and instead let the user configure them through <lv_conf_local.h>. What do you think?

Edit: Except for LV_MEM_CUSTOM, and below LV_TICK_CUSTOM* and LV_USE_LOG/LV_LOG_LEVEL.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I would prefer that since the lbuild options don't add any additional benefits (ie. like other modules being able to query display size). I'll add a few more fixups.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've moved all config options out of lbuild into lv_conf_local.h incl. logging, since it's weird to have to regenerate modm again just for that one option. I like this solution very much, it's very clean and minimal.

@rleh rleh added ci:hal Triggers the exhaustive HAL compile CI jobs and removed ci:hal Triggers the exhaustive HAL compile CI jobs labels Apr 6, 2021
@rleh
Copy link
Member Author

rleh commented Apr 6, 2021

Merge?

@salkinium salkinium merged commit e0d1327 into modm-io:develop Apr 6, 2021
@rleh rleh deleted the lvgl branch April 6, 2021 21:04
@TomSaw
Copy link
Contributor

TomSaw commented Apr 14, 2021

Got my ili9341 on monday.
I'm happy to test LVLG - Thanks @rleh 🌻🌻🌻

@salkinium salkinium added this to the 2021q2 milestone Jun 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
advanced 🤯 ci:hal Triggers the exhaustive HAL compile CI jobs feature 🚧
Development

Successfully merging this pull request may close these issues.

4 participants