LVGL v8 Baseimg
lvsf_baseimg is a basic image widget that SiFli wraps around LVGL lv_img, and it is the base class for image-type widgets such as lvsf_imgarray. It supports multiple image display modes: image-group index/value/Q24.8 fixed-point, pointer (stepless/snap), and sequence frames (forward/backward/forward-backward looping). It also supports angle, zoom, rotation pivot, loop count, and value-table mapping.
Main header: middleware/lvgl/lvsf/gui_widgets/lvsf_baseimg.h
Dependent widget: LVGL img (
LV_USE_IMG)
Note
This widget does not yet have a corresponding lvgl_v8_baseimg example. For detailed usage, refer to the header comments and the SDK configuration.
Features
Supports multiple image types: image-group index (the value is the index), image-group value (a value range maps to one image), image-group Q24.8 fixed-point, stepless pointer, snap pointer, and sequence-frame forward/backward/forward-backward looping.
Supports three source types: memory descriptor, file, and sequence frame.
Supports angle, zoom, and rotation pivot X/Y settings.
Supports sequence-frame start/end index, current index, and empty index settings, plus loop-count control (-1 means infinite loop).
Supports state callbacks (play start/stop/resume/pause/done, and so on) and index callbacks.
Supports a value table (
value_table) for mapping numeric values to images/positions.
Use Cases
Sequence-frame animation playback (forward/backward/oscillating loop).
Pointer-style instrument dials (stepless or snap).
Image-group index switching and value-to-image-mapping indicators.
Used as the base class for widgets such as
lvsf_imgarray.
Supported Boards
See the corresponding lvgl_v8 example or the SDK configuration.
Configuration and Initialization
lvsf_baseimg depends on the LVGL img component. In menuconfig, confirm it is enabled:
CONFIG_LV_USE_IMG=y
In the BSP, the LVSF_USE_BASEIMG macro controls whether this widget is compiled.
Minimum flow to create an object:
#include "lvsf_baseimg.h"
lv_obj_t *img = lv_baseimg_create(lv_scr_act());
API Reference
Enumerations
Image type lv_baseimg_type_t:
Value |
Meaning |
|---|---|
|
Image group, sequence mode; the numeric value is the image index |
|
Image group, value mode; a range of values maps to one image |
|
Image group, numeric mode; the data is in Q24.8 format |
|
Pointer, stepless change |
|
Snap pointer |
|
Sequence frames, continuous forward loop (0x0f) |
|
Sequence frames, continuous backward loop (0x1f) |
|
Sequence frames, continuous forward-backward loop (0x10f) |
Playback state lv_baseimg_state_t:
Value |
Meaning |
|---|---|
|
Empty state |
|
Sequence-frame playback started (triggered from stopped state or at the very start) |
|
Sequence-frame playback stopped; index reset to zero |
|
Sequence-frame playback resumed (triggered after being paused) |
|
Sequence-frame playback paused; index unchanged |
|
Sequence-frame forward playback finished |
|
Sequence-frame backward playback finished |
Source type lv_baseimg_src_type_t:
Value |
Meaning |
|---|---|
|
Memory descriptor |
|
File |
|
Sequence frame |
Callback types
Type definition |
Description |
|---|---|
|
Called when the base image is set to a specific index |
|
Called when the base image state changes; |
Creation and refresh
Function |
Description |
Parameters / Returns |
|---|---|---|
|
Creates a base image object |
|
|
Refresh timer callback |
|
State and source settings
Function |
Description |
Parameters / Returns |
|---|---|---|
|
Sets the state |
|
|
Sets the source array (memory descriptors) |
|
|
Sets the source array by file path |
|
|
Sets the sequence-frame image source and index range |
|
|
Sets the state callback |
|
|
Sets the value table |
|
Angle, zoom, and index
Function |
Description |
Parameters / Returns |
|---|---|---|
|
Sets the image angle |
|
|
Sets the image zoom |
|
|
Sets the start index |
|
|
Sets the end index |
|
|
Sets the current index |
|
|
Sets the image type |
|
|
Sets the empty index |
|
|
Sets the rotation pivot X coordinate |
|
|
Sets the rotation pivot Y coordinate |
|
|
Sets the loop count |
|
Query interfaces
Function |
Description |
Parameters / Returns |
|---|---|---|
|
Gets the current angle |
Returns the angle value |
|
Gets the current zoom |
Returns the zoom value |
|
Gets the start index |
Returns the start index |
|
Gets the end index |
Returns the end index |
|
Gets the current index |
Returns the current index |
|
Gets the image type |
Returns the image type ( |
|
Gets the empty index |
Returns the empty image index |
|
Gets the rotation pivot X coordinate |
Returns the rotation pivot X |
|
Gets the rotation pivot Y coordinate |
Returns the rotation pivot Y |
Typical Usage
Based on the header interfaces, the typical flow for continuous forward sequence-frame playback is: create the object → set the image type to sequence frame → set the source array → set the loop count → start playback:
#include "lvsf_baseimg.h"
lv_obj_t *img = lv_baseimg_create(parent);
/* Sequence frames: continuous forward loop */
lv_baseimg_set_img_type(img, BASEIMG_TYPE_SEQUENCE);
lv_baseimg_set_src_array(img, frame_dsc_arr, 0, FRAME_CNT - 1);
lv_baseimg_set_loop(img, -1); /* Infinite loop */
lv_baseimg_set_state(img, BASEIMG_STATE_PLAY_START); /* Start playback */
The typical flow for a pointer dial (stepless change) is:
lv_baseimg_set_img_type(img, BASEIMG_TYPE_POINTER);
lv_baseimg_set_pivot_X(img, 60);
lv_baseimg_set_pivot_y(img, 60);
lv_baseimg_set_angle(img, angle); /* Angle drives the pointer */
For detailed usage, refer to the header comments.
Demo
This widget does not yet have a corresponding example. Run examples based on baseimg such as lvgl_v8_imgarray to see its derived widgets in action.
See Also
Source path:
middleware/lvgl/lvsf/gui_widgets/lvsf_baseimg.h