### Start LVGL Subsystem with BSP Source: https://docs.lvgl.io/9.5/integration/chip_vendors/espressif/add_lvgl_to_esp32_idf_project.html Example of starting the LVGL subsystem using the BSP display start function and running a demo. This approach handles background task management for lv_timer_handler. ```c void app_main(void) { bsp_display_start(); bsp_display_backlight_on(); bsp_display_lock(0); lv_demo_benchmark(); bsp_display_unlock(); } ``` -------------------------------- ### Compile for Node Example Source: https://docs.lvgl.io/9.5/details/xml/tools/cli.html Example of compiling a project specifically for the Node.js target, including starting the service. ```bash lved-cli.js compile ./examples/my-project --target node --start-service ``` -------------------------------- ### Compare Example Source: https://docs.lvgl.io/9.5/details/xml/tools/cli.html Example of comparing a generated build directory against a reference tree. ```bash lved-cli.js compare build/generated ./ci/reference ``` -------------------------------- ### Example Setup for Subject Group Observer Source: https://docs.lvgl.io/9.5/main-modules/observer/observer.html Sets up multiple subjects, a subject group, and attaches an observer to the group. This example demonstrates how to connect individual subjects (mode, value, unit) into a group that triggers a single observer callback. ```c lv_obj_t * label = lv_label_create(lv_screen_active()); lv_subject_t subject_mode; // Voltage or Current lv_subject_t subject_value; // Measured value lv_subject_t subject_unit; // The unit lv_subject_t subject_all; // Subject group that connects the above 3 Subjects lv_subject_t * subject_list[3] = {&subject_mode, &subject_value, &subject_unit}; // The elements of the group lv_subject_init_int(&subject_mode, 0); // Let's say 0 is Voltage, 1 is Current lv_subject_init_int(&subject_value, 0); lv_subject_init_pointer(&subject_unit, "V"); lv_subject_init_group(&subject_all, subject_list, 3); lv_subject_add_observer_obj(&subject_all, all_observer_cb, label, NULL); ``` -------------------------------- ### Install Yocto SDK Source: https://docs.lvgl.io/9.5/integration/embedded_linux/os/yocto/lvgl_recipe.html Execute the generated SDK script to install the development environment on your host machine. Specify your preferred installation directory. ```bash $ ./sdk/poky-glibc-x86_64-core-image-base-cortexa53-raspberrypi3-64-toolchain-5.0.4.sh Poky (Yocto Project Reference Distro) SDK installer version 5.0.4 ================================================================= Enter target directory for SDK (default: /opt/poky/5.0.4): /opt/poky/sdk-with-lvgl You are about to install the SDK to "/opt/poky/sdk-with-lvgl". Proceed [Y/n]? y ``` -------------------------------- ### Minimal UEFI LVGL Example Source: https://docs.lvgl.io/9.5/integration/pc/uefi.html A minimal example demonstrating the initialization and basic usage of LVGL within a UEFI environment. This includes setting up display, input devices, and running a demo. ```c #include "lvgl/lvgl.h" #include "lvgl/examples/lv_examples.h" #include "lvgl/demos/lv_demos.h" EFI_STATUS EFIAPI EfiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable) { lv_uefi_init(ImageHandle, SystemTable); lv_init(); if (!lv_is_initialized()) return EFI_NOT_READY; EFI_HANDLE handle = lv_uefi_display_get_active(); if (!handle) handle = lv_uefi_display_get_any(); if (!handle) { lv_deinit(); return EFI_UNSUPPORTED; } lv_display_t *display = lv_uefi_display_create(handle); lv_display_set_default(display); lv_group_t *group = lv_group_create(); lv_group_set_default(group); lv_obj_t *cursor = lv_image_create(lv_layer_top()); lv_image_set_src(cursor, "E:cursor.png"); lv_indev_t *indev; indev = lv_uefi_simple_text_input_indev_create(); lv_indev_set_group(indev, group); lv_uefi_simple_text_input_indev_add_all(indev); indev = lv_uefi_simple_pointer_indev_create(NULL); lv_uefi_simple_pointer_indev_add_all(indev); lv_indev_set_cursor(indev, cursor); indev = lv_uefi_absolute_pointer_indev_create(NULL); lv_uefi_absolute_pointer_indev_add_all(indev); lv_demo_widgets(); size_t counter = 0; while (counter < 10000) { counter++; gBS->Stall(1000); lv_tick_inc(1); lv_timer_handler(); } return EFI_SUCCESS; } ``` -------------------------------- ### Simple LVGL Button Example in Berry Source: https://docs.lvgl.io/9.5/integration/framework/tasmota-berry.html Demonstrates creating a basic LVGL screen, a button, and a label within that button using the Berry scripting language integrated with Tasmota. This is a starting point for GUI development. ```berry lv.start() # start LVGL scr = lv.screen_active() # get default screen btn = lv.btn(scr) # create button btn.center() label = lv.label(btn) # create a label in the button label.set_text("Button") # set a label to the button ``` -------------------------------- ### Arduino Example for NV3007 Display with SPI Source: https://docs.lvgl.io/9.5/integration/external_display_controllers/nv3007.html This example demonstrates how to initialize and use the NV3007 display with LVGL on an Arduino platform via SPI. It includes platform-specific functions for SPI communication and display setup. ```c #include /* Platform-specific includes */ #include #define LCD_DC 21 #define LCD_CS 5 #define LCD_RST 4 #define LCD_SCK 18 #define LCD_MOSI 23 #define LCD_MISO -1 #define LCD_BL 15 #define SPI_CLK 40000000 #define BUFFER_SIZE 142 * 50 uint8_t buf[BUFFER_SIZE]; /* Define your platform-specific functions to send commands and data */ void my_lcd_send_cmd(lv_display_t *disp, const uint8_t *cmd, size_t cmd_size, const uint8_t *param, size_t param_size) { SPI.beginTransaction(SPISettings(SPI_CLK, MSBFIRST, SPI_MODE0)); /* Send command */ digitalWrite(LCD_DC, LOW); /* command mode */ digitalWrite(LCD_CS, LOW); /* CS low */ SPI.transferBytes(cmd, NULL, cmd_size); /* Send parameters (if any) */ if (param != NULL && param_size > 0) { digitalWrite(LCD_DC, HIGH); /* data mode */ SPI.transferBytes(param, NULL, param_size); } digitalWrite(LCD_CS, HIGH); /* CS high */ SPI.endTransaction(); } void my_lcd_send_color(lv_display_t *disp, const uint8_t *cmd, size_t cmd_size, uint8_t *param, size_t param_size) { SPI.beginTransaction(SPISettings(SPI_CLK, MSBFIRST, SPI_MODE0)); digitalWrite(LCD_CS, LOW); /* Send the command first */ digitalWrite(LCD_DC, LOW); SPI.transferBytes(cmd, NULL, cmd_size); /* Then send the pixel data */ if (param && param_size > 0) { digitalWrite(LCD_DC, HIGH); SPI.transferBytes(param, NULL, param_size); } digitalWrite(LCD_CS, HIGH); SPI.endTransaction(); /* Important: signal LVGL that we're done */ lv_display_flush_ready(disp); } void setup() { pinMode(LCD_BL, OUTPUT); digitalWrite(LCD_BL, HIGH); /* turn on backlight */ pinMode(LCD_DC, OUTPUT); pinMode(LCD_CS, OUTPUT); pinMode(LCD_RST, OUTPUT); /* reset sequence */ digitalWrite(LCD_RST, HIGH); delay(100); digitalWrite(LCD_RST, LOW); delay(120); digitalWrite(LCD_RST, HIGH); delay(120); SPI.begin(LCD_SCK, LCD_MISO, LCD_MOSI, LCD_CS); /* SCK, MISO, MOSI, SS */ digitalWrite(LCD_CS, HIGH); /* disable device */ delay(100); /* wait for device to stabilize */ lv_init(); lv_tick_set_cb(my_tick); /* Create NV3007 display */ lv_display_t *disp = lv_nv3007_create(142, 428, LV_LCD_FLAG_NONE, my_lcd_send_cmd, my_lcd_send_color); lv_nv3007_set_gap(disp, 0, 14); lv_display_set_rotation(disp, LV_DISPLAY_ROTATION_270); lv_display_set_color_format(disp, LV_COLOR_FORMAT_RGB565_SWAPPED); lv_display_set_buffers(disp, buf, NULL, BUFFER_SIZE, LV_DISP_RENDER_MODE_PARTIAL); /* Create a simple label on the display */ lv_obj_t *label = lv_label_create(lv_screen_active()); lv_label_set_text(label, "Hello NV3007!"); lv_obj_align(label, LV_ALIGN_CENTER, 0, 0); } void loop() { lv_task_handler(); delay(5); } ``` -------------------------------- ### PikaScript Compilation and Binding Process Source: https://docs.lvgl.io/9.5/integration/bindings/pikascript.html Example output from the PikaScript pre-compiler, showing package installation and the scanning/binding process for a Python interface file. ```bash $ ./rust-msc-latest-win10.exe (pikascript) packages installed: pikascript-core==v1.10.0 PikaStdLib==v1.10.0 PikaStdDevice==v1.10.0 (pikascript) pika compiler: scanning main.py... binding pika_lvgl.pyi... ``` -------------------------------- ### Install WSL (Windows) Source: https://docs.lvgl.io/9.5/xml/editor/install.html Install the Windows Subsystem for Linux if it is not already present. ```bash wsl --install ``` -------------------------------- ### Enable LVGL Examples and Demos Source: https://docs.lvgl.io/9.5/integration/building/cmake.html Enables the building of demos and examples for LVGL. This is useful for testing and learning purposes. ```cmake set(CONFIG_LV_BUILD_EXAMPLES ON) set(CONFIG_LV_BUILD_DEMOS ON) add_subdirectory(lvgl) ``` -------------------------------- ### Install LVGL Files Source: https://docs.lvgl.io/9.5/integration/embedded_linux/os/yocto/lvgl_recipe.html Installs the compiled LVGL library files, including headers and shared objects, into the destination installation directory `${D}`. ```bash bitbake lvgl -c install ``` -------------------------------- ### Example: Asynchronous Screen Cleanup Source: https://docs.lvgl.io/9.5/main-modules/timer.html Example demonstrating how to schedule a screen cleanup function to run asynchronously after the current operations are complete. Requires locking the LVGL mutex. ```c void my_screen_clean_up(void * scr) { /* Free some resources related to `scr`*/ /* Finally delete the screen */ lv_obj_delete(scr); } ... /* Do something with the Widget on the current screen */ /* Delete screen on next call of `lv_timer_handler`, not right now. */ lv_lock(); lv_async_call(my_screen_clean_up, lv_screen_active()); lv_unlock(); /* The screen is still valid so you can do other things with it */ ``` -------------------------------- ### Install Buildroot Prerequisites on Ubuntu Source: https://docs.lvgl.io/9.5/integration/embedded_linux/os/buildroot/image_generation.html Installs essential packages required by Buildroot using Ubuntu's apt package manager. ```bash sudo apt install sed make binutils gcc g++ bash patch gzip bzip2 perl tar \ cpio python3 unzip rsync wget libncurses-dev ``` -------------------------------- ### Unix-like File System Path Examples Source: https://docs.lvgl.io/9.5/overview/fs.html Examples of file paths for Unix-like systems when using the LVGL file system abstraction, prefixed with an identifier letter. ```text "Z:/etc/images/splash.png" ``` ```text "Z:/etc/images/left_button.png" ``` ```text "Z:/etc/images/right_button.png" ``` ```text "Z:/home/users/me/wip/proposal.txt" ``` -------------------------------- ### Unix-like File Path Examples Source: https://docs.lvgl.io/9.5/main-modules/fs.html Examples of file paths using a 'Z:' identifier for LVGL to select the appropriate file system driver on Unix-like systems. ```text "Z:/etc/images/splash.png" "Z:/etc/images/left_button.png" "Z:/etc/images/right_button.png" "Z:/home/users/me/wip/proposal.txt" ``` -------------------------------- ### Get Start Value Source: https://docs.lvgl.io/9.5/API/widgets/bar/lv_bar_h.html Retrieves the start value of the bar. ```APIDOC ## lv_bar_get_start_value ### Description Get the start value of a bar. ### Parameters * **obj** (const lv_obj_t *) - pointer to a bar object ### Returns * int32_t - the start value of the bar ``` -------------------------------- ### LVGL QNX 'Hello World' Application Example Source: https://docs.lvgl.io/9.5/integration/rtos/qnx.html This code demonstrates how to initialize LVGL, create a window, add input devices, and display a 'Hello world' message on QNX. ```c #include int main(int argc, char **argv) { /* Initialize the library. */ lv_init(); /* Create a 800x480 window. */ lv_display_t *disp = lv_qnx_window_create(800, 480); lv_qnx_window_set_title(disp, "LVGL Example"); /* Add keyboard and mouse devices. */ lv_qnx_add_keyboard_device(disp); lv_qnx_add_pointer_device(disp); /* Generate the UI. */ lv_obj_set_style_bg_color(lv_screen_active(), lv_color_hex(0x003a57), LV_PART_MAIN); lv_obj_t * label = lv_label_create(lv_screen_active()); lv_label_set_text(label, "Hello world"); lv_obj_set_style_text_color(lv_screen_active(), lv_color_hex(0xffffff), LV_PART_MAIN); lv_obj_align(label, LV_ALIGN_CENTER, 0, 0); /* Run the event loop until it exits. */ return lv_qnx_event_loop(disp); } ``` -------------------------------- ### Install NuttX Prerequisites on Linux Source: https://docs.lvgl.io/9.5/details/integration/os/nuttx.html Installs necessary development tools for NuttX on a Linux system, including build tools, libraries, and cross-compilation toolchains. ```bash $ sudo apt-get install automake bison build-essential flex gcc-arm-none-eabi gperf git libncurses5-dev libtool libusb-dev libusb-1.0.0-dev pkg-config kconfig-frontends openocd ``` -------------------------------- ### Build and Install SDK Source: https://docs.lvgl.io/9.5/integration/embedded_linux/os/buildroot/quick_setup.html Navigate to the output directory, build the SDK, and extract it to a specified location for application compilation. ```bash cd output make sdk mkdir -p ~/sdk tar -xzf images/aarch64-buildroot-linux-gnu_sdk-buildroot.tar.gz -C ~/sdk ``` -------------------------------- ### Basic LVGL Integration Example Source: https://docs.lvgl.io/9.5/getting_started/learn_the_basics.html This example demonstrates the fundamental steps for integrating LVGL into a project, including initialization, setting up a display buffer and flush callback, creating a simple label widget, and running the LVGL timer handler in a loop. ```c void main(void) { your_driver_init(); lv_init(); lv_tick_set_cb(my_get_millis); lv_display_t * display = lv_display_create(320, 240); /* LVGL will render to this 1/10 screen sized buffer for 2 bytes/pixel */ static uint8_t buf[320 * 240 / 10 * 2]; lv_display_set_buffers(display, buf, NULL, LV_DISPLAY_RENDER_MODE_PARTIAL); /* This callback will display the rendered image */ lv_display_set_flush_cb(display, my_flush_cb); /* Create widgets */ lv_obj_t * label = lv_label_create(lv_screen_active()); lv_label_set_text(label, "Hello LVGL!"); /* Make LVGL periodically execute its tasks */ while(1) { /* Provide updates to currently-displayed Widgets here. */ lv_timer_handler(); my_sleep(5); /*Wait 5 milliseconds before processing LVGL timer again*/ } } /* Return the elapsed milliseconds since startup. * It needs to be implemented by the user */ uint32_t my_get_millis(void) { return my_tick_ms; } /* Copy rendered image to screen. * This needs to be implemented by the user. */ void my_flush_cb(lv_display_t * disp, const lv_area_t * area, uint8_t * px_buf) { /* Show the rendered image on the display */ my_display_update(area, px_buf); /* Indicate that the buffer is available. * If DMA were used, call in the DMA complete interrupt. */ lv_display_flush_ready(); } ``` -------------------------------- ### Get Text Selection Source: https://docs.lvgl.io/9.5/API/widgets/label/lv_label_h.html Retrieves the start and end positions of the text selection in the label. ```APIDOC ## lv_label_get_text_selection_start() ### Description Gets the starting character index of the text selection. ### Parameters - **label**: `lv_obj_t*` - Pointer to the label widget. ### Returns - `uint32_t`: The starting character index of the selection. ``` ```APIDOC ## lv_label_get_text_selection_end() ### Description Gets the ending character index of the text selection. ### Parameters - **label**: `lv_obj_t*` - Pointer to the label widget. ### Returns - `uint32_t`: The ending character index of the selection. ``` -------------------------------- ### Create Project Directory and Download Sources Source: https://docs.lvgl.io/9.5/integration/embedded_linux/os/torizon/torizon_os.html Sets up the project directory structure and clones the necessary LVGL and porting repositories. Ensure Git is installed. ```bash mkdir -p ~/lvgl_torizon_os/ cd ~/lvgl_torizon_os/ touch Dockerfile git clone --depth 1 https://github.com/lvgl/lv_port_linux git -C lv_port_linux submodule update --init ``` -------------------------------- ### lv_arclabel_get_angle_start Source: https://docs.lvgl.io/9.5/API/widgets/arclabel/lv_arclabel_h.html Get the start angle of an arc label. This indicates where the arc begins in degrees. ```APIDOC ## lv_arclabel_get_angle_start ### Description Get the start angle of an arc label. ### Parameters * **obj** (lv_obj_t *) - pointer to an arc label object ### Returns lv_value_precise_t - the start angle [0..360] (if `LV_USE_FLOAT` is enabled it can be fractional too.) ``` -------------------------------- ### Complete Hardware Button Example Source: https://docs.lvgl.io/9.5/main-modules/indev/button.html Sets up an input device for buttons, assigns points, and provides a read callback to handle button presses and releases. ```c static const lv_point_t points_array[] = { {12,30}, /* First button is assigned to x=12; y=30 */ {60,90} /* Second button is assigned to x=60; y=90 */ }; lv_indev_t * indev = lv_indev_create(); lv_indev_set_type(indev, LV_INDEV_TYPE_BUTTON); lv_indev_set_button_points(indev, points_array); lv_indev_set_read_cb(indev, button_read); ... void button_read(lv_indev_t * indev, lv_indev_data_t * data) { /* Get the ID (0,1,2...) of the pressed button. * Let's say it returns -1 if no button was pressed */ int btn_pr = my_btn_read(); /* Is there a button press? */ if(btn_pr >= 0) { data->btn_id = btn_pr; /* Save the ID of the pressed button */ data->state = LV_INDEV_STATE_PRESSED; /* Set the pressed state */ } else { data->state = LV_INDEV_STATE_RELEASED; /* Set the released state */ } } ``` -------------------------------- ### Create X11 Window and Initialize Inputs Source: https://docs.lvgl.io/9.5/API/drivers/x11/lv_x11_h.html Demonstrates the minimal initialization for an X11 display driver with keyboard and mouse support. This includes creating the window and then setting up the input devices. ```c lv_display_t* disp = lv_x11_window_create("My Window Title", window_width, window_width); lv_x11_inputs_create(disp, NULL); ``` -------------------------------- ### Clone FrogFS Repository Source: https://docs.lvgl.io/9.5/libs/fs_support/frogfs.html Clone the upstream frogfs project from GitHub to get started with creating filesystem blobs. ```bash git clone https://github.com/jkent/frogfs cd frogfs ``` -------------------------------- ### Clone Buildroot Repository Source: https://docs.lvgl.io/9.5/integration/embedded_linux/os/buildroot/quick_setup.html Clone the LVGL Buildroot repository to get started. Ensure submodules are also cloned recursively. ```bash git clone --recurse-submodules https://github.com/lvgl/lv_buildroot.git ``` -------------------------------- ### Extract and Set Up SDK Environment Source: https://docs.lvgl.io/9.5/integration/embedded_linux/os/buildroot/lvgl_app.html Extract the generated SDK archive into a desired location and set up the cross-compilation environment by creating and making executable a 'setup-build-env.sh' script. ```bash mkdir -p ~/sdk tar -xzf images/aarch64-buildroot-linux-gnu_sdk-buildroot.tar.gz -C ~/sdk cd .. mkdir application && cd application touch setup-build-env.sh && chmod +x setup-build-env.sh ``` -------------------------------- ### lv_obj_get_style_length Source: https://docs.lvgl.io/9.5/API/core/lv_obj_style_gen_h.html Gets the length style property of a widget. Its meaning is widget-dependent, for example, it can represent the length of ticks in a scale widget. ```APIDOC ## lv_obj_get_style_length ### Description Its meaning depends on the type of Widget. For example in case of lv_scale it means the length of the ticks. ### Parameters * **obj** (const lv_obj_t *) - Pointer to Widget * **part** (lv_part_t) - One of the `LV_PART_...` enum values ``` -------------------------------- ### Getting Bar Values Source: https://docs.lvgl.io/9.5/API/widgets/bar/lv_bar_h.html Functions to retrieve the current value, start value, minimum value, and maximum value of the bar widget. ```APIDOC ## lv_bar_get_value() ### Description Gets the current value of the bar. ### Parameters - **bar**: `lv_obj_t*` - Pointer to the bar widget. ### Returns - `int32_t`: The current value of the bar. ``` ```APIDOC ## lv_bar_get_start_value() ### Description Gets the start value of the bar. ### Parameters - **bar**: `lv_obj_t*` - Pointer to the bar widget. ### Returns - `int32_t`: The start value of the bar. ``` ```APIDOC ## lv_bar_get_min_value() ### Description Gets the minimum value of the bar. ### Parameters - **bar**: `lv_obj_t*` - Pointer to the bar widget. ### Returns - `int32_t`: The minimum value of the bar. ``` ```APIDOC ## lv_bar_get_max_value() ### Description Gets the maximum value of the bar. ### Parameters - **bar**: `lv_obj_t*` - Pointer to the bar widget. ### Returns - `int32_t`: The maximum value of the bar. ``` -------------------------------- ### Initialize LVGL and Load UI Source: https://docs.lvgl.io/9.5/details/xml/integration/renesas-dev-tools.html Standard LVGL initialization functions followed by UI initialization and screen loading. Replace 'my_screen' with your actual main screen name. ```c /* Standard LVGL initialization */ lv_init(); lv_port_disp_init(); lv_port_indev_init(); /* Initialize the UI generated from the LVGL Editor */ ui_init(); /* (replace "my_screen" with the actual name of your main screen) */ lv_obj_t * my_screen = my_screen_create(); lv_screen_load(my_screen); ``` -------------------------------- ### Create X11 Window with Mouse Cursor Source: https://docs.lvgl.io/9.5/API/drivers/x11/lv_x11_h.html Shows how to create an X11 window and initialize input devices, including setting a custom image for the mouse cursor. ```c lv_image_dsc_t mouse_symbol = {.....}; lv_display_t* disp = lv_x11_window_create("My Window Title", window_width, window_width); lv_x11_inputs_create(disp, &mouse_symbol); ``` -------------------------------- ### Get Next Line of Text Source: https://docs.lvgl.io/9.5/API/misc/lv_text_private_h.html Calculates and returns the starting index of the next line of text, considering line length constraints and breakable characters. ```APIDOC ## lv_text_get_next_line ### Description Get the next line of text. Check line length and break chars too. ### Parameters * **txt** (const char *) - a '\0' terminated string * **len** (uint32_t) - length of 'txt' in bytes * **font** (const lv_font_t *) - pointer to a font * **used_width** (int32_t *) - When used_width != NULL, save the width of this line if flag == LV_TEXT_FLAG_NONE, otherwise save -1. * **attributes** (lv_text_attributes_t *) - text attributes, flags to control line break behaviour, spacing etc. ### Returns the index of the first char of the new line (in byte index not letter index. With UTF-8 they are different) ``` -------------------------------- ### Create LVGL Application Recipe Source: https://docs.lvgl.io/9.5/integration/embedded_linux/os/yocto/lvgl_recipe.html Set up the directory structure and create a .bb file for an LVGL application recipe. ```bash cd ../sources/meta-mylvgl mkdir -p recipes-lvglapp/lvgl-fbdev-benchmark/files touch recipes-lvglapp/lvgl-fbdev-benchmark/lvglbenchmarkfbdev_2.4.bb ``` -------------------------------- ### Initialize LVGL Source: https://docs.lvgl.io/9.5/integration/overview.html To initialize LVGL, include the main header, initialize your hardware, and then call `lv_init()`. ```c #include "lvgl/lvgl.h" // Initialize your hardware (clock, peripherals, etc.) lv_init(); ``` -------------------------------- ### Get Two Fingers Swipe Distance Source: https://docs.lvgl.io/9.5/API/indev/lv_indev_gesture_h.html Retrieves the distance in pixels from the starting center for a two-finger swipe gesture. This helps quantify the swipe movement. ```c float lv_event_get_two_fingers_swipe_distance(lv_event_t *gesture_event); ``` -------------------------------- ### Set Up Rootfs Overlay Directory Source: https://docs.lvgl.io/9.5/integration/embedded_linux/os/buildroot/lvgl_app.html Create the necessary directory structure for the rootfs overlay and copy the compiled application executable into the appropriate location within the overlay. ```bash mkdir -p resources/board/rootfs_overlay/usr/bin cp application/lv_benchmark/bin/lvgl-app resources/board/rootfs_overlay/usr/bin/ ``` -------------------------------- ### Get Two Fingers Swipe Direction Source: https://docs.lvgl.io/9.5/API/indev/lv_indev_gesture_h.html Determines the direction of a two-finger swipe gesture relative to its starting center. Returns an `lv_dir_t` value indicating the direction. ```c lv_dir_t lv_event_get_two_fingers_swipe_dir(lv_event_t *gesture_event); ``` -------------------------------- ### Basic LVGL Application with SDL Source: https://docs.lvgl.io/9.5/integration/pc/sdl.html This is a fundamental example of initializing LVGL and creating an SDL window for display and input. Ensure SDL_MAIN_HANDLED is defined to prevent issues with SDL's main function on Windows. ```c #define SDL_MAIN_HANDLED /* To fix SDL's "undefined reference to WinMain" issue */ #include "lvgl/lvgl.h" static lv_display_t *display; static lv_indev_t *mouse; static lv_indev_t *mouse_wheel; static lv_indev_t *keyboard; int main() { /* Initialize LVGL */ lv_init(); display = lv_sdl_window_create(SDL_HOR_RES, SDL_VER_RES); mouse = lv_sdl_mouse_create(); mouse_wheel = lv_sdl_mousewheel_create(); keyboard = lv_sdl_keyboard_create(); /* Create widgets on the screen */ lv_demo_widgets(); while (1) { lv_timer_handler(); lv_delay_ms(5); } return 0; } ``` -------------------------------- ### Set Rotation Source: https://docs.lvgl.io/9.5/API/widgets/scale/lv_scale_h.html Sets the angular offset for the scale's starting point. This is particularly useful for round scales to orient them correctly, for example, aligning the zero point to a specific clock position. ```APIDOC ## lv_scale_set_rotation ### Description Set angular offset from the 3-o'clock position of the low end of the Scale. (Applies only to round Scales.) ### Parameters #### Scale Object * **obj** (lv_obj_t *) - pointer to Scale Widget #### Rotation Angle * **rotation** (int32_t) - clockwise angular offset (in degrees) from the 3-o'clock position of the low end of the scale; negative and >360 values are first normalized to range [0..360]. Examples: * 0 = 3 o'clock (right side) * 30 = 4 o'clock * 60 = 5 o'clock * 90 = 6 o'clock * 135 = midway between 7 and 8 o'clock (default) * 180 = 9 o'clock * 270 = 12 o'clock * 300 = 1 o'clock * 330 = 2 o'clock * -30 = 2 o'clock * 390 = 4 o'clock ``` -------------------------------- ### Configure Button Size, Alignment, and Label Source: https://docs.lvgl.io/9.5/getting_started/learn_the_basics.html This example demonstrates setting a button's size using percentage and content height, aligning it, and setting its label text and color. It also shows how to use non-pixel units for sizing. ```c lv_obj_t * my_button1 = lv_button_create(lv_screen_active()); /* Set parent-sized width, and content-sized height */ lv_obj_set_size(my_button1, lv_pct(100), LV_SIZE_CONTENT); /* Align to the right center with 20px offset horizontally */ lv_obj_align(my_button1, LV_ALIGN_RIGHT_MID, -20, 0); lv_obj_t * my_label1 = lv_label_create(my_button1); lv_label_set_text_fmt(my_label1, "Click me!"); lv_obj_set_style_text_color(my_label1, lv_color_hex(0xff0000), 0); /* Make the text red */ ``` -------------------------------- ### Configure LVGL Encoder Input Device Group Source: https://docs.lvgl.io/9.5/details/integration/os/zephyr.html Example C code to get the LVGL encoder input device and assign an LVGL group to it. This requires the encoder input device to be available in the devicetree. ```c const struct device *lvgl_encoder = DEVICE_DT_GET(DT_COMPAT_GET_ANY_STATUS_OKAY(zephyr_lvgl_encoder_input)); lv_obj_t *arc; lv_group_t *arc_group; arc = lv_arc_create(lv_screen_active()); lv_obj_align(arc, LV_ALIGN_CENTER, 0, 0); lv_obj_set_size(arc, 150, 150); arc_group = lv_group_create(); lv_group_add_obj(arc_group, arc); lv_indev_set_group(lvgl_input_get_indev(lvgl_encoder), arc_group); ``` -------------------------------- ### Basic DRM Display Initialization and Demo Source: https://docs.lvgl.io/9.5/integration/embedded_linux/drivers/drm.html Initialize LVGL, create a DRM display, set the device, and run the widget demo. This snippet shows the fundamental steps for using the DRM driver. ```c #include "lvgl/lvgl.h" #include "lvgl/demos/lv_demos.h" int main(void) { /* Initialize LVGL */ lv_init(); /* DRM device node */ const char *device = "/dev/dri/card0"; /* Create a DRM display */ lv_display_t *disp = lv_linux_drm_create(); /* Set DRM device file and connector */ /* The 2nd argument is the DRM device path */ /* The 3rd argument is the connector_id (-1 = auto-select first available) */ lv_linux_drm_set_file(disp, device, -1); /* Create demo widgets */ lv_demo_widgets(); /* Handle LVGL tasks */ while (1) { uint32_t time_until_next = lv_timer_handler(); if(time_until_next == LV_NO_TIMER_READY) { time_until_next = LV_DEF_REFR_PERIOD; } lv_delay_ms(time_until_next); } return 0; } ``` -------------------------------- ### XML Example for Screen Load and Create Events Source: https://docs.lvgl.io/9.5/xml/ui_elements/events.html Defines two screens with buttons that trigger screen creation and loading. Use `` to dynamically create a screen and `` to load an existing one. ```xml ``` -------------------------------- ### Basic CMake Build (Method 1) Source: https://docs.lvgl.io/9.5/integration/building/cmake.html Use this method for a straightforward configuration and build process from the command line. Ensure you are in the LVGL repository root. ```bash cd mkdir build cd build cmake .. # Configure phase cmake --build . # Build phase ``` -------------------------------- ### Build with CMake Presets Source: https://docs.lvgl.io/9.5/integration/building/cmake.html Leverage CMake presets for predefined configurations and build types. This example shows how to activate a Windows base configuration and then build a debug version. ```bash cmake --preset windows-base cmake --build --preset windows-base_dbg ctest --preset windows-base_dbg ``` -------------------------------- ### Basic OpenGL Driver Usage Source: https://docs.lvgl.io/9.5/integration/embedded_linux/drivers/opengl_driver.html Demonstrates the basic setup and usage of the OpenGL driver, including creating a display that flushes to an OpenGL texture and integrating with the LVGL main loop. Ensure an OpenGL context is created before initializing LVGL. ```c #include "lvgl/lvgl.h" #define WIDTH 640 #define HEIGHT 480 /* This flush callback works with both FULL and DIRECT render modes*/ static void flush_cb(lv_display_t *disp, const lv_area_t *area, uint8_t *px_map) { if (lv_display_flush_is_last(disp)) { const int32_t disp_width = lv_display_get_horizontal_resolution(disp); const int32_t disp_height = lv_display_get_vertical_resolution(disp); /* The texture occupies the full screen even if `area` is not the full screen which happens with RENDER_MODE_DIRECT */ lv_area_t full_area; lv_area_set(&full_area, 0, 0, disp_width, disp_height); /* Get the texture id containing LVGL generated UI */ unsigned int texture_id = lv_opengles_texture_get_texture_id(disp); /* This function will render to the current context */ lv_opengles_render_texture(texture_id, &full_area, LV_OPA_COVER, disp_width, disp_height, &full_area, false, true); } lv_display_flush_ready(disp); } int main() { /* initialize lvgl */ lv_init(); /* Don't forget the tick callback */ /* NOTE: OpenGL context must be created before this point */ /* Create a display that flushes to a texture. The OpenGL texture will be created for you */ lv_display_t * texture = lv_opengles_texture_create(WIDTH, HEIGHT); /* If you already have an OpenGL texture ready, you can use it instead: * lv_display_t * texture = lv_opengles_texture_create_from_texture_id(WIDTH, HEIGHT, my_texture_id); */ /* Set the display render mode and flush callback * lv_display_set_render_mode(texture, LV_DISPLAY_RENDER_MODE_FULL); * lv_display_set_flush_cb(texture, flush_cb); */ /* get the texture ID for use in your application */ unsigned int texture_id = lv_opengles_texture_get_texture_id(texture); /* create Widgets on the screen */ lv_demo_widgets(); while (1) { uint32_t time_until_next = lv_timer_handler(); if(time_until_next == LV_NO_TIMER_READY) time_until_next = LV_DEF_REFR_PERIOD; lv_delay_ms(time_until_next); } return 0; } ``` -------------------------------- ### Install Podman on MacOS Source: https://docs.lvgl.io/9.5/xml/editor/install.html Install Podman on MacOS using the Homebrew package manager. ```bash brew install podman ``` -------------------------------- ### Build All LVGL Libraries for QNX Source: https://docs.lvgl.io/9.5/integration/rtos/qnx.html Navigate to the QNX support directory and run 'make' to build all shared and static libraries for supported architectures. ```bash # cd $(LVGL_ROOT)/env_support/qnx # make ``` -------------------------------- ### Install Podman on Fedora Source: https://docs.lvgl.io/9.5/xml/editor/install.html Install Podman on Fedora systems using the DNF package manager. ```bash sudo dnf -y install podman ``` -------------------------------- ### Install Application Binary Source: https://docs.lvgl.io/9.5/integration/embedded_linux/os/buildroot/quick_setup.html Copy the compiled application binary into the root filesystem overlay to include it in the final image. ```bash cp application/lv_benchmark/bin/lvgl-app resources/board/rootfs_overlay/usr/bin/ ``` -------------------------------- ### Install Wayland Dependencies on Fedora Source: https://docs.lvgl.io/9.5/integration/embedded_linux/drivers/wayland.html Installs necessary development libraries for Wayland integration on Fedora systems. ```bash sudo dnf install wayland-devel libxkbcommon-devel wayland-utils wayland-protocols-devel ``` -------------------------------- ### Initialize LVGL and Display Driver in main.cpp Source: https://docs.lvgl.io/9.5/integration/framework/platformio.html Initialize LVGL, set the tick callback, and create a display driver instance. This example uses `millis()` for ticks and `lv_lovyan_gfx_create` for display initialization. ```cpp #include #include #define BUF_SIZE 320 * 50 uint8_t lv_buffer[BUF_SIZE]; /* Tick source, tell LVGL how much time (milliseconds) has passed */ static uint32_t my_tick(void) { return millis(); } void setup() { /* Initialize LVGL */ lv_init(); /* Set the tick callback */ lv_tick_set_cb(my_tick); /* Initialize the display driver */ lv_lovyan_gfx_create(320, 480, lv_buffer, BUF_SIZE, true); lv_obj_t *label = lv_label_create(lv_screen_active()); lv_label_set_text(label, "Hello PlatformIO, I\'m LVGL!"); lv_obj_align(label, LV_ALIGN_CENTER, 0, 0 ); } void loop() { lv_timer_handler(); // Update the UI- delay(5); } ``` -------------------------------- ### Install Wayland Dependencies on Ubuntu Source: https://docs.lvgl.io/9.5/integration/embedded_linux/drivers/wayland.html Installs necessary development libraries for Wayland integration on Ubuntu systems. ```bash sudo apt-get install libwayland-dev libxkbcommon-dev libwayland-bin wayland-protocols ``` -------------------------------- ### Simple Grid Example Source: https://docs.lvgl.io/9.5/details/common-widget-features/layouts/grid.html Demonstrates how to create a basic grid layout with predefined column and row sizes. Child widgets are automatically arranged and stretched to fill their cells. ```c #include "../../lv_examples.h" #if LV_USE_GRID && LV_BUILD_EXAMPLES /** * A simple grid */ void lv_example_grid_1(void) { static int32_t col_dsc[] = {70, 70, 70, LV_GRID_TEMPLATE_LAST}; static int32_t row_dsc[] = {50, 50, 50, LV_GRID_TEMPLATE_LAST}; /*Create a container with grid*/ lv_obj_t * cont = lv_obj_create(lv_screen_active()); lv_obj_set_style_grid_column_dsc_array(cont, col_dsc, 0); lv_obj_set_style_grid_row_dsc_array(cont, row_dsc, 0); lv_obj_set_size(cont, 300, 220); lv_obj_center(cont); lv_obj_set_layout(cont, LV_LAYOUT_GRID); lv_obj_t * label; lv_obj_t * obj; uint8_t i; for(i = 0; i < 9; i++) { uint8_t col = i % 3; uint8_t row = i / 3; obj = lv_button_create(cont); /*Stretch the cell horizontally and vertically too *Set span to 1 to make the cell 1 column/row sized*/ lv_obj_set_grid_cell(obj, LV_GRID_ALIGN_STRETCH, col, 1, LV_GRID_ALIGN_STRETCH, row, 1); label = lv_label_create(obj); lv_label_set_text_fmt(label, "c%d, r%d", col, row); lv_obj_center(label); } } #endif ``` -------------------------------- ### Start Animation Source: https://docs.lvgl.io/9.5/API/widgets/animimage/lv_animimage_h.html Starts the playback of the animated image. The animation will begin playing according to its configured settings. ```APIDOC ## lv_animimg_start ### Description Starts the playback of the animated image. The animation will begin playing according to its configured settings. ### Function Signature ```c void lv_animimg_start(lv_obj_t *obj); ``` ### Parameters * **obj** (*lv_obj_t* *) - Pointer to the animated image object. ``` -------------------------------- ### Step-by-Step Test Execution Initialization Source: https://docs.lvgl.io/9.5/xml/features/tests.html Prepares for executing test steps one by one. It cleans the screen and sets up the view to be tested. ```c lv_xml_test_run_init() ``` -------------------------------- ### Configure and Start DMA2D Transfer Source: https://docs.lvgl.io/9.5/API/draw/dma2d/lv_draw_dma2d_private_h.html Configures the DMA2D peripheral with the provided settings and starts a transfer operation. ```APIDOC ## void lv_draw_dma2d_configure_and_start_transfer ### Description Configures the DMA2D peripheral with the provided settings and starts a transfer operation. ### Signature void lv_draw_dma2d_configure_and_start_transfer(const lv_draw_dma2d_configuration_t *conf) ### Parameters * **conf** (*const lv_draw_dma2d_configuration_t ") - Pointer to the DMA2D configuration structure. ``` -------------------------------- ### State and Volume Source: https://docs.lvgl.io/9.5/API/libs/gstreamer/lv_gstreamer_h.html Functions to get the current state of the GStreamer object and to set and get the audio volume. ```APIDOC ## lv_gstreamer_get_state ### Description Get the state of this gstreamer. ### Parameters * **gstreamer** (*lv_obj_t* *) - Pointer to a gstreamer object. ### Returns * (*lv_gstreamer_state_t*) - The current state of the gstreamer object. ## lv_gstreamer_set_volume ### Description Set the volume of this gstreamer. ### Parameters * **gstreamer** (*lv_obj_t* *) - Pointer to a gstreamer object. * **volume** (*uint8_t*) - The value to set in the range [0..100]. Higher values are clamped. ## lv_gstreamer_get_volume ### Description Get the volume of this gstreamer. ### Parameters * **gstreamer** (*lv_obj_t* *) - Pointer to a gstreamer object. ### Returns * (*uint8_t*) - The current volume for this gstreamer. ``` -------------------------------- ### Apply Rootfs Overlay and Verify Source: https://docs.lvgl.io/9.5/integration/embedded_linux/os/buildroot/lvgl_app.html After configuring the rootfs overlay, run 'make' to apply the changes. Verify that the application executable is present in the Buildroot output directory. ```bash find . -name lvgl-app ``` -------------------------------- ### Enter Buildroot Output Directory Source: https://docs.lvgl.io/9.5/integration/embedded_linux/os/buildroot/image_generation.html Navigates into the output directory where Buildroot commands will be executed. ```bash cd output ``` -------------------------------- ### Install Podman on Arch/Manjaro Linux Source: https://docs.lvgl.io/9.5/xml/editor/install.html Install Podman on Arch Linux and its derivatives using the Pacman package manager. ```bash sudo pacman -S podman ``` -------------------------------- ### Check WSL Installation (Windows) Source: https://docs.lvgl.io/9.5/xml/editor/install.html Verify if WSL is already installed on your Windows system by listing verbose details. ```bash wsl.exe --list --verbose ``` -------------------------------- ### Create NuttX Workspace Source: https://docs.lvgl.io/9.5/details/integration/os/nuttx.html Sets up a directory structure for NuttX development and navigates into it. ```bash mkdir ~/nuttxspace cd ~/nuttxspace ``` -------------------------------- ### Set Start Value Source: https://docs.lvgl.io/9.5/API/widgets/bar/lv_bar_h.html Sets a new start value for the bar. The animation parameter determines if the change should be animated. ```APIDOC ## lv_bar_set_start_value ### Description Set a new start value on the bar. ### Parameters * **obj** (lv_obj_t *) - pointer to a bar object * **start_value** (int32_t) - new start value * **anim** (lv_anim_enable_t) - LV_ANIM_ON: set the value with an animation; LV_ANIM_OFF: change the value immediately ``` -------------------------------- ### Setup Keypad Input Device and Group Source: https://docs.lvgl.io/9.5/main-modules/indev/keypad.html This snippet demonstrates how to create a group for focus management and set up a keypad input device with a custom read callback. Ensure widgets are added to a group to be selectable. ```c /*Create a group and add widgets to it so they can be selected by the keypad*/ lv_group_t * g = lv_group_create(); lv_indev_t * indev = lv_indev_create(); lv_indev_set_type(indev, LV_INDEV_TYPE_KEYPAD); lv_indev_set_read_cb(indev, keyboard_read); lv_indev_set_group(indev, g); ... void keyboard_read(lv_indev_t * indev, lv_indev_data_t * data) { if(key_pressed()) { data->key = my_last_key(); /* Get the last pressed or released key */ data->state = LV_INDEV_STATE_PRESSED; } else { data->state = LV_INDEV_STATE_RELEASED; } } ``` -------------------------------- ### Display BitBake Help Options Source: https://docs.lvgl.io/9.5/integration/embedded_linux/os/yocto/core_components.html Use these commands to view the available command-line options for BitBake. ```bash $ bitbake -h $ bitbake --help ``` -------------------------------- ### Example Commit Message: Documentation Fix Source: https://docs.lvgl.io/9.5/contributing/pull_requests.html Example commit message for a documentation fix, specifying the type and scope. ```text docs(porting): fix typo ``` -------------------------------- ### Verify libdrm Installation Source: https://docs.lvgl.io/9.5/integration/embedded_linux/os/buildroot/lvgl_app.html After building the environment, verify that the libdrm library has been installed by searching for its files within the target sysroot. ```bash find build/ -name "*libdrm*" ``` -------------------------------- ### Example Arduino Project Structure Source: https://docs.lvgl.io/9.5/xml/integration/arduino.html Illustrates the recommended folder structure for an LVGL Editor project within an Arduino sketch, ensuring all files are compiled. ```text YourSketch/ ├── YourSketch.ino └── src/ └── editor_project/ ├── editor_project.h ├── editor_project.c ├── screens/ ├── widgets/ └── components/ ``` -------------------------------- ### Configure Buildroot with Menuconfig Source: https://docs.lvgl.io/9.5/integration/embedded_linux/os/buildroot/image_generation.html Launches the menuconfig interface to customize Buildroot settings. ```bash make menuconfig ``` -------------------------------- ### Set Start Callback Source: https://docs.lvgl.io/9.5/API/widgets/animimage/lv_animimage_h.html Sets a callback function that will be called when the animation image actually starts playing (after any initial delay). ```APIDOC ## lv_animimg_set_start_cb ### Description Sets a callback function that will be called when the animation image actually starts playing (after any initial delay). ### Function Signature ```c void lv_animimg_set_start_cb(lv_obj_t *obj, lv_anim_start_cb_t start_cb); ``` ### Parameters * **obj** (*lv_obj_t* *) - Pointer to the animated image object. * **start_cb** (*lv_anim_start_cb_t*) - The callback function to be called when the animation starts. ``` -------------------------------- ### Set Start Angle Source: https://docs.lvgl.io/9.5/API/widgets/arc/lv_arc_h.html Sets the start angle of the arc. Angles are measured in degrees, with 0 degrees pointing to the right. ```APIDOC ## lv_arc_set_start_angle ### Description Sets the start angle of an arc. 0 deg: right, 90 bottom, etc. ### Function Signature ```c void lv_arc_set_start_angle(lv_obj_t *obj, lv_value_precise_t start) ``` ### Parameters * **obj** (*lv_obj_t* *) - Pointer to an arc object. * **start** (*lv_value_precise_t*) - The start angle. (if `LV_USE_FLOAT` is enabled it can be fractional too.) ``` -------------------------------- ### Run NuttX Simulator Source: https://docs.lvgl.io/9.5/details/integration/os/nuttx.html Starts the NuttX simulator on the PC. ```bash ./nuttx ``` -------------------------------- ### Install libdrm-dev on Debian/Ubuntu Source: https://docs.lvgl.io/9.5/integration/embedded_linux/drivers/drm.html Install the necessary development library for DRM on Debian or Ubuntu-based systems. This is a prerequisite for using the DRM driver. ```bash sudo apt-get install libdrm-dev ``` -------------------------------- ### Initialize Yocto Build Environment Source: https://docs.lvgl.io/9.5/integration/embedded_linux/os/yocto/lvgl_recipe.html Navigate to the project root and source the Yocto environment setup script. This prepares the build environment and sets the current directory to the build folder. ```bash cd ../ # go back to the root folder source sources/poky/oe-init-build-env ``` -------------------------------- ### Install pre-commit Hooks Source: https://docs.lvgl.io/9.5/contributing/coding_style.html Installs the git hook scripts managed by pre-commit. This ensures hooks run automatically on git commit. ```bash pre-commit install ```