Chapter 211. Configuration

This chapter shows how to incorporate the LVGL support into an eCos configuration, and how to configure it once included.

211.1. Configuration Overview

The LVGL support is contained in a single eCos package CYGPKG_LVGL. Currently the eCos LVGL world consists of unmodified source files from the lvgl-9.3.0.tar.gz release tar-ball, along with some additional eCos specific sources to provide a standard eCos configurable and buildable package.

The eCos package does not contain all of the files from the release tar-ball, but only the core library requirements and some additional (useful) demo/example sources. All of the LVGL functionality is included though. Due to the constraints of the eCos package system some files are held in different sub-directories to their original location, but as mentioned currently no LVGL sources are modified, this is to allow for easier future imports of updated LVGL releases with minimal effort.

[Note]Note

An eCos specific lv_conf.h implementation is provided to interface with the standard eCos CDL configuration world.

211.1.1. Quick Start

Incorporating the LVGL support into your application is straightforward. The essential starting point is to incorporate the LVGL eCos package (CYGPKG_LVGL) into your configuration.

This may be achieved directly using ecosconfig add on the command line, or the Build->Packages… menu item within the eCos Configuration Tool.

211.1.2. Configuring Options

For the majority of situations the default LVGL configuration as defined in the package include/cyg/gfx/lv_conf.h header will suffice. Especially since only referenced code will be linked into the final application.

The package does provide some CDL configuration options that will affect the LVGL library construction.

CYGOPT_LVGL_OS
When this option is configured as “None” then the application is responsible for managing the LVGL initialisation and lv_task_handler() calling. When configured as “eCos” then a helper thread is created to process LVGL operations in the background.
CYGNUM_LVGL_OS_ECOS_DRAW_THREAD_COUNT
When CYGOPT_LVGL_OS is configured for “eCos” then this option specifies the number of drawing threads to be created (minimum of 1).
CYGNUM_LVGL_OS_ECOS_DRAW_THREAD_STACK_SIZE
When CYGOPT_LVGL_OS is configured for “eCos” then this option specifies the size (in bytes) for each drawing thread stack.
CYGPKG_LVGL_DRAW_DMA2D
This is a ST STM32 specific feature to enable DMA2D acceleration, which may improve the performance of some graphic operations (e.g. blends, fills, etc.).
CYGPKG_LVGL_RENDER_MODE
This option configures the LVGL rendering mode. PARTIAL uses smaller, LVGL managed, buffers to render the screen in smaller chunks. Using DIRECT expects screen sized buffers to be supplied where LVGL will render directly into the correct location in the supplied framebuffer (which normally would be the actual display memory). The FULL setting will redraw the complete screen regardless of the level of redraw changes made.
CYGNUM_LVGL_RENDER_MODE_PARTIAL_BUF_SIZE
When PARTIAL rendering is configured this option specifies the size of the two buffers created for the LVGL rendering operations. These buffers will subsequently be copied into the relevant framebuffer location as required.
CYGDAT_LVGL_RENDER_MODE_PARTIAL_BUF_SECTION
If PARTIAL rendering is configured then this option allows for an optional named section to be used to hold the partial buffers. This may be required if specific memory, e.g. SRAM, should be used for the temporary buffers.
CYGPKG_LVGL_LOG
his option controls the LV_LOG support. The setting NONE disables the logging functionality. Use USER to only log custom log messages added by the user. The ERROR setting logs only critical, system failure imminent, issues. The WARN setting logs indications of unexpected, but recoverable, behaviour. The INFO setting logs important events, whilst the TRACE setting provides detailed execution information.
CYGPKG_LVGL_LOG_TIMESTAMP
This option controls whether the log entries contain a LVGL timestamp.
CYGPKG_LVGL_LOG_FILELINE
This option controls whether the log entries indicate the source file and line-number for the relevant log output call.
CYGPKG_LVGL_LOG_TRACE_MODULES
This component contains a set of modules where individual log message generation can be controlled for the specific module. These options can be used to reduced the amount of logging generated to make it easier to track specific information/events.
CYGFUN_LVGL_SYSMON
When enabled this option provides the system monitoring features.
CYGFUN_LVGL_SYSMON_MONITOR_PERF
When system monitoring is configured this option enables the system performance monitoring feature.
CYGFUN_LVGL_SYSMON_MONITOR_PERF_DEST
The system performance information can be displayed as an overlay using the SCREEN setting, or can be directed to the logging system by selecting LOG.
CYGFUN_LVGL_SYSMON_MONITOR_PERF_POS
When the performance monitor is configured for the SCREEN display, then this option specifies the screen position where the overlay is rendered.
CYGFUN_LVGL_SYSMON_MONITOR_MEM

When enabled this option provides support for the memory usage monitor feature.

[Note]Note

This is currently limited to configurations where LV_USE_STDLIB_MALLOC = LV_STDLIB_BUILTIN, and so if the LV_STDLIB_CLIB is configured (used when the CYGPKG_MEMALLOC is configured) then memory usage will not be reported.

CYGFUN_LVGL_SYSMON_MONITOR_MEM_POS
When the performance monitor is configured then this option specifies the screen position where the overlay is rendered.
CYGNUM_LVGL_COLOUR_DEPTH
The user should not normally need to configure this option, since it is normally a requirement of the underlying display driver hardware.
CYGPKG_LVGL_FONT
This component provides a set of options to individually control which of the LVGL supplied fonts are built into the library.
CYGPKG_LVGL_FONT_DEFAULT
Since the LVGL library requires a default font to be specified, this option allows the selection of a LVGL supplied font as the default to be used by the configured library.
CYGBLD_LVGL_TESTS_DEMOLIB
Due to the way that the original LVGL library structures the available demonstrations, and to allow the standard eCos TESTS build support some of the demonstration code is provided as a distinct library that can be referenced from the build world. This allows multi-file demonstration builds to co-exist with the single-file based eCos test application build infrastructure.

If, however, greater control over the configuration of the LVGL library build is required then the developer can supply header files to #define or #undef options as desired to override the default settings. This is achieved by enabling the relevant configuration option, specifying a header file location, so that the build will include the referenced header.

The header file injection configuration option is:

CYGBLD_LVGL_USER_CONFIG_HEADER
If defined, the supplied header file will be included at the end of the automatically included <cyg/gfx/lv_conf.h> header.

If the requirement for a specific LVGL configuration update is part of another package (for example the platform (PLF) or variant (VAR). or some application library package) then this can easily be achieved in the package specific CDL by a simple requires statement. e.g.

    requires      { CYGBLD_LVGL_USER_CONFIG_HEADER == "<my_package/my_lvgl_config.h>" }
        

If using the ecosconfig tool to construct a build configuration, then a CDL fragmant can be imported to set the desired header file reference. e.g.

cat > my_lvgl.ecm <<EOF
cdl_option CYGBLD_LVGL_USER_CONFIG_HEADER {
    inferred_value 1 “my_lvgl_options.h”
}
EOF
ecosconfig import my_lvgl.ecm
        

Alternatively, for a specific build configuration .ecc file, the option can be manually set using the configtool GUI application with a suitable local or global path filename used to reference the required header for the build.

211.2. Usage

For applications to make use of the LVGL functionality it is simply a case of including the main LVGL header and subsequently calling the initialisation routine, followed by any UI setup required and then finally entering the LVGL event loop processing. At the simplest this would be something like:

#include <cyg/gfx/lvgl/lvgl.h>

void lv_example(void)
{
    cyg_lvgl_init();

    // lv calls as required to setup the UI

    cyg_lvgl_timer_loop(); // does not return
    return;
}

The package contains some unmodified, other than being wrapped for eCos, LVGL demonstration applications in the tests and src/demos sub-directories. These can be used as starting points if needed when creating the LVGL application support required by the user.