docs(libs): proofread docs batch 19 (#7709)

Co-authored-by: Liam Howatt <30486941+liamHowatt@users.noreply.github.com>
This commit is contained in:
Victor Wheeler
2025-02-21 10:49:14 -07:00
committed by GitHub
parent 5856e46079
commit 2bf2ab46ce
8 changed files with 206 additions and 176 deletions

View File

@@ -4,10 +4,8 @@
File System Interfaces File System Interfaces
====================== ======================
LVGL has a :ref:`overview_file_system` module LVGL's :ref:`file_system` module provides an abstraction that enables you to attach
to provide an abstraction layer for various file system drivers. any type of file system for LVGL's use. File systems already supported are:
LVG has built in support for:
- `FATFS <http://elm-chan.org/fsw/ff/00index_e.html>`__ - `FATFS <http://elm-chan.org/fsw/ff/00index_e.html>`__
- STDIO (Linux and Windows using C standard function .e.g ``fopen``, ``fread``) - STDIO (Linux and Windows using C standard function .e.g ``fopen``, ``fread``)
@@ -19,59 +17,33 @@ LVG has built in support for:
- Arduino SD (allows for reading from and writing to SD cards) - Arduino SD (allows for reading from and writing to SD cards)
You still need to provide the drivers and libraries, this extension You still need to provide the drivers and libraries, this extension
provides only the bridge between FATFS, STDIO, POSIX, WIN32 and LVGL. provides only the bridge between LVGL and these file systems.
.. _libs_filesystem_usage: .. _libs_filesystem_usage:
Usage Usage
***** *****
In ``lv_conf.h`` enable ``LV_USE_FS_...`` and assign an upper cased In ``lv_conf.h`` enable ``LV_USE_FS_...`` (by setting its value to ``1``) and assign
letter to ``LV_FS_..._LETTER`` (e.g. ``'S'``). After that you can access an upper cased letter to ``LV_FS_..._DRIVER_LETTER`` (e.g. ``'S'``). If more than
files using that driver letter. E.g. ``"S:path/to/file.txt"``. one file system is enabled, each driver will need to have a unique driver-identifier
letter. After that you can access files using that driver letter. Example with
driver identifier letter ``'S'``:
Working with common prefixes :Linux-like relative path: ``"S:path/to/file.txt"``
"""""""""""""""""""""""""""" :Linux-like absolute path: ``"S:/path/to/file.txt"``
:Windows-like relative path: ``"S:C:path/to/file.txt"``
:Windows-like absolute path: ``"S:C:/path/to/file.txt"``
A **default driver letter** can be set by ``LV_FS_DEFAULT_DRIVER_LETTER``, Do not confuse the driver-identifier letter with the Windows/DOS/FAT "drive letter",
which allows skipping the drive prefix in file paths. which is part of the path passed to the OS-level functions. For more details, see
:ref:`lv_fs_identifier_letters`.
For example if ``LV_FS_DEFAULT_DRIVER_LETTER`` is set the ``'S'`` *"path/to/file.txt"* will mean *"S:path/to/file.txt"*. :ref:`Cached reading <file_system_cache>` is also supported if ``LV_FS_..._CACHE_SIZE`` is set to
a non-zero value.
This feature is useful if you have only a single driver and don't want to bother with LVGL's driver layer in the file paths. For further details, including how to create support for your own file system, see
It also helps to use a unified path with LVGL's file system and normal file systems. :ref:`file_system`.
The original mechanism is not affected, so a path starting with drive letter will still work.
The **working directory** can be set with ``LV_FS_..._PATH``. E.g.
``"/home/joe/projects/"`` The actual file/directory paths will be
appended to it, allowing to skip the common part.
Caching
"""""""
:ref:`Cached reading <overview_file_system_cache>` is also supported if ``LV_FS_..._CACHE_SIZE`` is set to
not ``0`` value. :cpp:func:`lv_fs_read` caches this size of data to lower the
number of actual reads from the storage.
To use the memory-mapped file emulation an ``lv_fs_path_ex_t`` object must be
created and initialized. This object can be passed to :cpp:func:`lv_fs_open` as
the file name:
.. code-block:: c
lv_fs_path_ex_t mempath;
lv_fs_file_t file;
uint8_t *buffer;
uint32_t size;
/* Initialize buffer */
...
lv_fs_make_path_from_buffer(&mempath, LV_FS_MEMFS_LETTER, (void*)buffer, size);
lv_fs_res_t res = lv_fs_open(&file, (const char *)&mempath, LV_FS_MODE_RD);
.. _libs_filesystem_api:
API
***

View File

@@ -1,45 +1,56 @@
.. _qrcode: .. _qrcode:
======= =======
QR code QR Code
======= =======
QR code generation with LVGL. Uses The `QR-Code-generator library <https://github.com/nayuki/QR-Code-generator>`__ by
`QR-Code-generator <https://github.com/nayuki/QR-Code-generator>`__ by `nayuki <https://github.com/nayuki>`__ is a 3rd-party library that generates QR-Code
`nayuki <https://github.com/nayuki>`__. bitmaps.
The lv_qrcode LVGL extension is an interface to that library which implements a custom
Widget that generates and displays QR Codes using the library.
.. _qrcode_usage: .. _qrcode_usage:
Usage Usage
----- *****
Enable :c:macro:`LV_USE_QRCODE` in ``lv_conf.h``. Enable :c:macro:`LV_USE_QRCODE` in ``lv_conf.h`` by setting its value to ``1``.
Use :cpp:func:`lv_qrcode_create` to create a qrcode object, and use Use :cpp:func:`lv_qrcode_create` to create the QR-Code Widget. Then use
:cpp:func:`lv_qrcode_update` to generate a QR code. :cpp:func:`lv_qrcode_update` to generate the QR Code on it.
If you need to re-modify the size and color, use If you need to re-modify the size and color, use
:cpp:func:`lv_qrcode_set_size` and :cpp:func:`lv_qrcode_set_dark_color` or :cpp:func:`lv_qrcode_set_size` and :cpp:func:`lv_qrcode_set_dark_color` or
:cpp:func:`lv_qrcode_set_light_color`, and :cpp:func:`lv_qrcode_set_light_color` respectively, and then
call :cpp:func:`lv_qrcode_update` again to regenerate the QR code. call :cpp:func:`lv_qrcode_update` again to update the QR Code.
Notes Notes
----- *****
- QR Codes with less data are smaller, but they are scaled by an integer
value to best fit to the given size.
- QR codes with less data are smaller, but they scaled by an integer
number to best fit to the given size.
.. _qrcode_example: .. _qrcode_example:
Example Example
------- *******
.. include:: ../../examples/libs/qrcode/index.rst .. include:: ../../examples/libs/qrcode/index.rst
.. _qrcode_api: .. _qrcode_api:
API API
--- ***
:ref:`qrcodegen_h` :ref:`qrcodegen_h`

View File

@@ -1,23 +1,26 @@
.. _rle: .. _rle:
============ =================
RLE Compress RLE Decompression
============ =================
LVGL provides a custom RLE compression method. It can be used to reduce binary LVGL provides a custom RLE (Run-Length Encoding) decompression method. It can be
image size. The RLE compression is a lossless compression method. used to reduce binary image size. The RLE compression is a lossless compression
method.
The LVGL's built-in binary image decoder supports RLE compressed images. The LVGL's built-in binary image decoder supports RLE-compressed images.
The decoder supports both variable and file as image sources. The original The decoder supports both variable and file as image sources. The original
binary data is directly decoded to RAM binary data is directly decoded to RAM.
Benefits Benefits
-------- ********
Based on test result from a watch project. Most of the images can be compressed Most screenshot and UI images (where there are a limited number of colors) can be
to save more than 70% space as show in below statistic. It shows the file count compressed to save more than 70% space. The below statistics are from a watch
of every compress level. For rare conditions, RLE compress may increase the file project. It shows the file count of every compress level. For rare conditions, RLE
size if there's no large repetition in data. compress may increase the file size if there's no large repetition in data.
.. image:: rle-compress-statistics.png .. image:: rle-compress-statistics.png
:alt: RLE compress statistics from a watch project :alt: RLE compress statistics from a watch project
@@ -25,14 +28,14 @@ size if there's no large repetition in data.
Theory Theory
------ ******
The RLE algorithm is a simple compression algorithm that is based on the fact that The RLE algorithm is a simple compression algorithm that is based on the fact that
the for many pixels, the color is the same. The algorithm simply counts how many for many adjacent pixels, the color is the same. The algorithm simply counts how
repeated data are there and store the count value and the color value. many repeated pixels with the same color there are, and stores the count value and
If the coming pixels are not repeated, it stores the non-repeat count value and the color value. If the up-coming pixels are not repeated, it stores the non-repeat
original color value. For more details, the script used to compress the image count value and original color values. For more details, the script used to compress
can be found from ``lvgl/script/LVGLImage.py``. the image can be found from ``lvgl/script/LVGLImage.py``.
.. code-block:: python .. code-block:: python
@@ -63,24 +66,39 @@ can be found from ``lvgl/script/LVGLImage.py``.
return b"".join(compressed_data) return b"".join(compressed_data)
.. _rle_usage: .. _rle_usage:
Usage Usage
----- *****
To use the RLE Decoder, enable it in ``lv_conf.h`` configuration file by setting :c:macro:`LV_USE_RLE` to `1`. To use the RLE Decoder, enable it in ``lv_conf.h`` configuration file by setting
The RLE image can be used same as other images. :c:macro:`LV_USE_RLE` to ``1``. The RLE image can then be used in the same way as
other images.
.. code-block:: c .. code-block:: c
lv_image_set_src(img, "path/to/image.rle"); lv_image_set_src(img, "path/to/image.rle");
Generate RLE compressed binary images
-------------------------------------
The image can be directly generated using script ``lvgl/script/LVGLImage.py``
Generating RLE Compressed Binary Images
***************************************
An RLE image binary can be directly generated from another image using script
``lvgl/script/LVGLImage.py``.
.. code-block:: bash .. code-block:: bash
./script/LVGLImage.py --ofmt BIN --cf I8 --compress RLE cogwheel.png ./scripts/LVGLImage.py --ofmt BIN --cf I8 --compress RLE cogwheel.png
This will decompress ``cogwheel.png``, and then re-compress it using RLE and write
the output to ``./output/cogwheel.bin``.
API
***
:ref:`lv_rle_h`

View File

@@ -1,25 +1,27 @@
.. _rlottie: .. _rlottie:
============== ==============
Rlottie player Rlottie Player
============== ==============
.. warning:: .. warning::
Rlottie is deprecated. Consider using :ref:`lv_lottie` instead. Rlottie is deprecated. Consider using the :ref:`lv_lottie` Widget instead.
Allows playing Lottie animations in LVGL. Taken from `lv_rlottie <https://github.com/ValentiWorkLearning/lv_rlottie>`__. The `Rlottie animation player for LVGL <https://github.com/ValentiWorkLearning/lv_rlottie>`__
is a 3rd-party extension for LVGL that allows playing Lottie animations in LVGL.
It provides an interface to `Samsung/rlottie <https://github.com/Samsung/rlottie>`__
library's C API. This Lottie player is not part of LVGL; it needs to be built
separately.
LVGL provides the interface to `Samsung/rlottie <https://github.com/Samsung/rlottie>`__ library's C
API. That is the actual Lottie player is not part of LVGL, it needs to
be built separately.
Build Rlottie
-------------
To build Samsung's Rlottie C++14 compatible compiler and optionally Building Rlottie
CMake 3.14 or higher is required. ****************
To build on desktop you can follow the instructions from Rlottie's To build Samsung's Rlottie, you will need a C++14-compatible compiler and optionally
CMake 3.14 or higher.
To build on a desktop you can follow the instructions from Rlottie's
`README <https://github.com/Samsung/rlottie/blob/master/README.md>`__. `README <https://github.com/Samsung/rlottie/blob/master/README.md>`__.
In the most basic case it looks like this: In the most basic case it looks like this:
@@ -40,24 +42,26 @@ And finally add the ``-lrlottie`` flag to your linker.
On embedded systems you need to take care of integrating Rlottie to the On embedded systems you need to take care of integrating Rlottie to the
given build system. given build system.
ESP-IDF example at bottom See the ESP-IDF example below.
~~~~~~~~~~~~~~~~~~~~~~~~~
.. _rlottie_usage: .. _rlottie_usage:
Usage Usage
----- *****
You can use animation from files or raw data (text). In either case You can use animation from files or raw data (text). In either case
first you need to enable :c:macro:`LV_USE_RLOTTIE` in ``lv_conf.h``. first you need to enable :c:macro:`LV_USE_RLOTTIE` in ``lv_conf.h`` by setting its
value to ``1``.
The ``width`` and ``height`` of the Widget be set in the *create* The ``width`` and ``height`` of the Widget is set in the ``lv_rlottie_create_from_...()``
function and the animation will be scaled accordingly. function, and the animation will be scaled accordingly.
Use Rlottie from file Use Rlottie from File
~~~~~~~~~~~~~~~~~~~~~ ---------------------
To create a Lottie animation from file use: To create a Lottie animation from a file use:
.. code-block:: c .. code-block:: c
@@ -66,11 +70,11 @@ To create a Lottie animation from file use:
Note that, Rlottie uses the standard STDIO C file API, so you can use Note that, Rlottie uses the standard STDIO C file API, so you can use
the path "normally" and no LVGL specific driver letter is required. the path "normally" and no LVGL specific driver letter is required.
Use Rlottie from raw string data Use Rlottie from Raw String Data
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --------------------------------
``lv_example_rlottie_approve.c`` contains an example animation in raw ``lv_example_rlottie_approve.c`` contains an example animation in raw
format. Instead storing the JSON string, a hex array is stored for the format. Instead of storing the JSON string, a hex array is stored for the
following reasons: following reasons:
- avoid escaping ``"`` character in the JSON file - avoid escaping ``"`` character in the JSON file
@@ -83,7 +87,8 @@ array. E.g.:
./filetohex.py path/to/lottie.json --filter-character --null-terminate > out.txt ./filetohex.py path/to/lottie.json --filter-character --null-terminate > out.txt
``--filter-character`` filters out non-ASCII characters and ``--null-terminate`` makes sure that a trailing zero is appended to properly close the string. ``--filter-character`` filters out non-ASCII characters and ``--null-terminate``
makes sure that a trailing zero is appended to properly terminate the string.
To create an animation from raw data: To create an animation from raw data:
@@ -92,17 +97,21 @@ To create an animation from raw data:
extern const uint8_t lottie_data[]; extern const uint8_t lottie_data[];
lv_obj_t* lottie = lv_rlottie_create_from_raw(parent, width, height, (const char *)lottie_data); lv_obj_t* lottie = lv_rlottie_create_from_raw(parent, width, height, (const char *)lottie_data);
Getting animations
------------------
Getting Animations
******************
Lottie is standard and popular format so you can find many animation Lottie is standard and popular format so you can find many animation
files on the web. For example: https://lottiefiles.com/ files on the web. For example: https://lottiefiles.com/ .
You can also create your own animations with Adobe After Effects or You can also create your own animations with Adobe After Effects or
similar software. similar software.
Controlling animations
----------------------
Controlling Animations
**********************
LVGL provides two functions to control the animation mode: LVGL provides two functions to control the animation mode:
:cpp:func:`lv_rlottie_set_play_mode` and :cpp:func:`lv_rlottie_set_current_frame`. :cpp:func:`lv_rlottie_set_play_mode` and :cpp:func:`lv_rlottie_set_current_frame`.
@@ -132,11 +141,13 @@ To get the number of frames in an animation or the current frame index,
you can cast the :c:struct:`lv_obj_t` instance to a :c:struct:`lv_rlottie_t` instance you can cast the :c:struct:`lv_obj_t` instance to a :c:struct:`lv_rlottie_t` instance
and inspect the ``current_frame`` and ``total_frames`` members. and inspect the ``current_frame`` and ``total_frames`` members.
ESP-IDF Example ESP-IDF Example
--------------- ***************
Background Background
~~~~~~~~~~ ----------
Rlottie can be expensive to render on embedded hardware. Lottie Rlottie can be expensive to render on embedded hardware. Lottie
animations tend to use a large amount of CPU time and can use large animations tend to use a large amount of CPU time and can use large
@@ -155,13 +166,13 @@ lottie animation.
In order to pass initialization of the lv_rlottie_t object, you need In order to pass initialization of the lv_rlottie_t object, you need
240x320x32/8 (307k) available memory. The latest ESP32-S3 has 256kb RAM 240x320x32/8 (307k) available memory. The latest ESP32-S3 has 256kb RAM
available for this (before freeRtos and any other initialization starts available for this (before FreeRTOS and any other initialization starts
taking chunks out). So while you can probably start to render a 50x50 taking chunks out). So while you can probably start to render a 50x50
animation without SPIRAM, PSRAM is highly recommended. animation without SPIRAM, PSRAM is highly recommended.
Additionally, while you might be able to pass initialization of the Additionally, while you might be able to pass initialization of the
lv_rlottie_t object, as rlottie renders frame to frame, this consumes ``lv_rlottie_t`` object, as rlottie renders frame to frame, this consumes
additional memory. A 30 frame animation that plays over 1 second additional memory. A 30-frame animation that plays over 1 second
probably has minimal issues, but a 300 frame animation playing over 10 probably has minimal issues, but a 300 frame animation playing over 10
seconds could very easily crash due to lack of memory as rlottie seconds could very easily crash due to lack of memory as rlottie
renders, depending on the complexity of the animation. renders, depending on the complexity of the animation.
@@ -169,7 +180,7 @@ renders, depending on the complexity of the animation.
Rlottie will not compile for the IDF using the ``-02`` compiler option at Rlottie will not compile for the IDF using the ``-02`` compiler option at
this time. this time.
For stability in lottie animations, I found that they run best in the For stability in lottie animations, this author has found that they run best in the
IDF when enabling :c:macro:`LV_MEM_CUSTOM` (using ``stdlib.h``) IDF when enabling :c:macro:`LV_MEM_CUSTOM` (using ``stdlib.h``)
For all its faults, when running right-sized animations, they provide a For all its faults, when running right-sized animations, they provide a
@@ -179,15 +190,15 @@ done properly.
When picking/designing a lottie animation consider the following When picking/designing a lottie animation consider the following
limitations: limitations:
- Build the lottie animation to be sized for the intended size - Build the lottie animation to be sized for the intended size.
- it can scale/resize, but performance will be best when the base lottie size is as intended - It can scale/resize, but performance will be best when the base lottie size is as intended.
- Limit total number of frames, the longer the lottie animation is, - Limit total number of frames, the longer the lottie animation is,
the more memory it will consume for rendering (rlottie consumes IRAM for rendering) the more memory it will consume for rendering (rlottie consumes IRAM for rendering).
- Build the lottie animation for the intended frame rate - Build the lottie animation for the intended frame rate.
- default lottie is 60fps, embedded LCDs likely won't go above 30fps - Default lottie is 60fps, embedded LCDs likely won't go above 30fps.
IDF Setup IDF Setup
~~~~~~~~~ ---------
Where the LVGL simulator uses the installed rlottie lib, the IDF works Where the LVGL simulator uses the installed rlottie lib, the IDF works
best when using rlottie as a submodule under the components directory. best when using rlottie as a submodule under the components directory.
@@ -203,19 +214,19 @@ Now, Rlottie is available as a component in the IDF, but it requires
some additional changes and a CMakeLists file to tell the IDF how to some additional changes and a CMakeLists file to tell the IDF how to
compile. compile.
Rlottie patch file Rlottie Patch File
~~~~~~~~~~~~~~~~~~ ------------------
Rlottie relies on a dynamic linking for an image loader lib. This needs Rlottie relies on dynamic linking for an image loader lib. This needs
to be disabled as the IDF doesn't play nice with dynamic linking. to be disabled as the IDF doesn't play nice with dynamic linking.
A patch file is available in lvgl under: A patch file is available in LVGL under:
``/env_support/esp/rlottie/0001-changes-to-compile-with-esp-idf.patch`` ``/env_support/esp/rlottie/0001-changes-to-compile-with-esp-idf.patch``
Apply the patch file to your rlottie submodule. Apply the patch file to your rlottie submodule.
CMakeLists for IDF CMakeLists for IDF
~~~~~~~~~~~~~~~~~~ ------------------
An example CMakeLists file has been provided at An example CMakeLists file has been provided at
``/env_support/esp/rlottie/CMakeLists.txt`` ``/env_support/esp/rlottie/CMakeLists.txt``
@@ -235,13 +246,13 @@ project as any other widget in LVGL ESP examples. Please remember that
these animations can be highly resource constrained and this does not these animations can be highly resource constrained and this does not
guarantee that every animation will work. guarantee that every animation will work.
Additional Rlottie considerations in ESP-IDF Additional Rlottie Considerations in ESP-IDF
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ --------------------------------------------
While unnecessary, removing the ``rlottie/rlottie/example`` folder can remove While unnecessary, removing the ``rlottie/rlottie/example`` folder can remove
many un-needed files for this embedded LVGL application many un-needed files for this embedded LVGL application.
From here, you can use the relevant LVGL lv_rlottie functions to create From here, you can use the relevant LVGL ``lv_rlottie...()`` functions to create
lottie animations in LVGL on embedded hardware! lottie animations in LVGL on embedded hardware!
Please note, that while lottie animations are capable of running on many Please note, that while lottie animations are capable of running on many
@@ -261,33 +272,37 @@ lottie animations.
You will need to enable :c:macro:`LV_USE_RLOTTIE` through **idf.py** menuconfig under You will need to enable :c:macro:`LV_USE_RLOTTIE` through **idf.py** menuconfig under
LVGL component settings. LVGL component settings.
Additional changes to make use of SPIRAM Additional Changes to Make Use of SPIRAM
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ----------------------------------------
:cpp:expr:`lv_alloc/realloc` do not make use of SPIRAM. Given the high memory usage :cpp:expr:`lv_alloc/realloc` does not make use of SPIRAM. Given the high memory usage
of lottie animations, it is recommended to shift as much out of internal of lottie animations, it is recommended to shift as much out of internal
DRAM into SPIRAM as possible. In order to do so, SPIRAM will need to be DRAM into SPIRAM as possible. In order to do so, SPIRAM will need to be
enabled in the menuconfig options for your given espressif chip. enabled in the menuconfig options for your given espressif chip.
There may be a better solution for this, but for the moment the There may be a better solution for this, but for the moment the
recommendation is to make local modifications to the lvgl component in recommendation is to make local modifications to the LVGL component in
your espressif project. This is as simple as swapping your espressif project. This is as simple as swapping
:cpp:expr:`lv_alloc/lv_realloc` calls in `lv_rlottie.c`` with :cpp:expr:`heap_caps_malloc` (for :cpp:expr:`lv_alloc/lv_realloc` calls in `lv_rlottie.c`` with :cpp:expr:`heap_caps_malloc` (for
IDF) with the appropriate :cpp:expr:`MALLOC_CAP` call - for SPIRAM usage this is IDF) with the appropriate :cpp:expr:`MALLOC_CAP` call --- for SPIRAM usage this is
:cpp:expr:`MALLOC_CAP_SPIRAM`. :cpp:expr:`MALLOC_CAP_SPIRAM`.
.. code-block:: c .. code-block:: c
rlottie->allocated_buf = heap_caps_malloc(allocated_buf_size+1, MALLOC_CAP_SPIRAM); rlottie->allocated_buf = heap_caps_malloc(allocated_buf_size+1, MALLOC_CAP_SPIRAM);
.. _rlottie_example: .. _rlottie_example:
Example Example
------- *******
.. include:: ../../examples/libs/rlottie/index.rst .. include:: ../../examples/libs/rlottie/index.rst
.. _rlottie_api: .. _rlottie_api:
API API
--- ***

View File

@@ -1,22 +1,27 @@
.. _svg: .. _svg:
============== ===========
SVG support SVG Support
============== ===========
The lv_svg extension provides makes it possible to use SVG images in your LVGL UI using the
`Scalable Vector Graphics (SVG) Tiny 1.2 Specification <https://www.w3.org/TR/SVGTiny12/>`__.
For a detailed introduction, see: https://www.w3.org/TR/SVGTiny12/
Scalable Vector Graphics (SVG) Tiny 1.2 support in LVGL.
Detailed introduction: https://www.w3.org/TR/SVGTiny12/
Usage Usage
***** *****
Enable :c:macro:`LV_USE_SVG` in ``lv_conf.h``. Enable :c:macro:`LV_USE_SVG` in ``lv_conf.h`` by setting its value to ``1``.
See the examples below. See the examples below.
If you need support SVG animation attribute parsing, If you need support for SVG animation attribute parsing,
you can enable :c:macro:`LV_USE_SVG_ANIMATION` in ``lv_conf.h``. you can set :c:macro:`LV_USE_SVG_ANIMATION` in ``lv_conf.h`` to ``1``.
.. _svg_example: .. _svg_example:
@@ -28,23 +33,25 @@ Example
lv_svg_node_t * svg_doc; lv_svg_node_t * svg_doc;
const char* svg_data = "<svg><rect x=\"0\" y=\"0\" width=\"100\" height=\"100\"/></svg>"; const char* svg_data = "<svg><rect x=\"0\" y=\"0\" width=\"100\" height=\"100\"/></svg>";
/* Create an SVG DOM tree*/ /* Create an SVG DOM tree */
svg_doc = lv_svg_load_data(svg_data, svg_len); svg_doc = lv_svg_load_data(svg_data, svg_len);
... ...
/* Draw SVG image*/ /* Draw SVG image */
lv_draw_svg(layer, svg_doc); lv_draw_svg(layer, svg_doc);
... ...
/* Release the DOM tree*/ /* Release the DOM tree */
lv_svg_node_delete(svg_doc); lv_svg_node_delete(svg_doc);
`lv_image` also supports svg image, For example: `lv_image` also supports SVG images, For example:
.. code-block:: c .. code-block:: c
lv_image_set_src(widget, "S:path/to/example.svg"); lv_image_set_src(widget, "S:path/to/example.svg");
.. _svg_api: .. _svg_api:
API API

View File

@@ -4,24 +4,27 @@
Tiny TTF font engine Tiny TTF font engine
==================== ====================
The lv_tiny_ttf extension allows using TrueType fonts in LVGL using the
`stb_truetype 3rd-Party Library <https://github.com/nothings/stb>`__.
For a detailed introduction, see: https://github.com/nothings/stb.
.. _tiny_ttf_usage: .. _tiny_ttf_usage:
Usage Usage
----- *****
Allow using TrueType fonts in LVGL. When enabled in ``lv_conf.h`` by setting :c:macro:`LV_USE_TINY_TTF` to ``1``,
Detailed introduction: https://github.com/nothings/stb
When enabled in ``lv_conf.h`` with :c:macro:`LV_USE_TINY_TTF`
:cpp:expr:`lv_tiny_ttf_create_data(data, data_size, font_size)` can be used to :cpp:expr:`lv_tiny_ttf_create_data(data, data_size, font_size)` can be used to
create a TTF font instance at the specified line height. You can then create a TTF font instance with the specified line height. You can then
use that font anywhere :c:struct:`lv_font_t` is accepted. use that font anywhere :c:struct:`lv_font_t` is accepted.
By default, the TTF or OTF file must be embedded as an array, either in By default, the TTF or OTF file must be embedded as an array, either in
a header, or loaded into RAM in order to function. a header, or loaded into RAM in order to function.
However, if :c:macro:`LV_TINY_TTF_FILE_SUPPORT` is enabled, However, if :c:macro:`LV_TINY_TTF_FILE_SUPPORT` is enabled (i.e. ``1``),
:cpp:expr:`lv_tiny_ttf_create_file(path, font_size)` will also be available, :cpp:expr:`lv_tiny_ttf_create_file(path, font_size)` will also be available,
allowing tiny_ttf to stream from a file. The file must remain open the allowing tiny_ttf to stream from a file. The file must remain open the
entire time the font is being used. entire time the font is being used.
@@ -29,27 +32,31 @@ entire time the font is being used.
After a font is created, you can change the font size in pixels by using After a font is created, you can change the font size in pixels by using
:cpp:expr:`lv_tiny_ttf_set_size(font, font_size)`. :cpp:expr:`lv_tiny_ttf_set_size(font, font_size)`.
By default, a font will cache data for upto 256 glyphs elements to speed up rendering. By default, a font will cache data for up to 256 glyph elements to speed up rendering.
This maximum can be changed by using This maximum can be changed by using
:cpp:expr:`lv_tiny_ttf_create_data_ex(data, data_size, font_size, kerning, cache_size)` :cpp:expr:`lv_tiny_ttf_create_data_ex(data, data_size, font_size, kerning, cache_size)`
or :cpp:expr:`lv_tiny_ttf_create_file_ex(path, font_size, kerning, cache_size)` (when or :cpp:expr:`lv_tiny_ttf_create_file_ex(path, font_size, kerning, cache_size)` (when
available). The cache size is indicated in number of entries. Kerning is whether to allow available). The cache size is indicated in number of entries. The ``kerning``
if supported, or disable. argument will be one of the ``LV_FONT_KERNING_...`` values, indicating whether to
allow kerning, if supported, or disable.
.. _tiny_ttf_example: .. _tiny_ttf_example:
Example Example
------- *******
.. include:: ../../examples/libs/tiny_ttf/index.rst .. include:: ../../examples/libs/tiny_ttf/index.rst
.. _tiny_ttf_api: .. _tiny_ttf_api:
API API
--- ***
:ref:`stb_rect_pack_h` :ref:`stb_rect_pack_h`
:ref:`stb_truetype_htcw_h` :ref:`stb_truetype_htcw_h`

View File

@@ -367,7 +367,7 @@ Loading a Font from a Memory Buffer at Run-Time
This function may be useful to load a font from an external file system, which is not This function may be useful to load a font from an external file system, which is not
supported by LVGL. The font needs to be in the same format as if it were loaded from a file. supported by LVGL. The font needs to be in the same format as if it were loaded from a file.
:note: To load a font from a buffer :ref:`LVGL's filesystem <overview_file_system>` :note: To load a font from a buffer :ref:`LVGL's filesystem <file_system>`
needs to be enabled and the MEMFS driver must be added. needs to be enabled and the MEMFS driver must be added.
Example Example

View File

@@ -17,7 +17,7 @@ under :ref:`lv_fs_identifier_letters`.
Ready-to-use drivers Ready-to-Use Drivers
******************** ********************
LVGL contains prepared drivers for the API of POSIX, standard C, LVGL contains prepared drivers for the API of POSIX, standard C,
@@ -29,7 +29,7 @@ Learn more :ref:`here <libs_filesystem>`.
.. _lv_fs_identifier_letters: .. _lv_fs_identifier_letters:
Identifier Letters Identifier Letters
********************* ******************
As mentioned above, a file system is identified by an assigned identifier letter. As mentioned above, a file system is identified by an assigned identifier letter.
This identifier is merely a way for the LVGL File System abtraction logic to look up This identifier is merely a way for the LVGL File System abtraction logic to look up
@@ -295,7 +295,7 @@ To use files in Image Widgets the following callbacks are required:
.. _overview_file_system_cache: .. _file_system_cache:
Optional File Buffering/Caching Optional File Buffering/Caching
******************************* *******************************
@@ -386,7 +386,7 @@ The driver's ``tell`` will not actually be called.
.. _overview_file_system_api: .. _file_system_api:
API API
*** ***