1============================= 2UEFI Display/Inputs driver 3============================= 4 5Overview 6-------- 7 8The **UEFI** display/input `driver <https://github.com/lvgl/lvgl/src/drivers/uefi>`__ offers support for using LVGL with UEFI. 9 10Prerequisites 11------------- 12 13You need the following protocols available: 14 15* *EFI_LOADED_IMAGE_PROTOCOL_GUID*, for file system support (used to determine the file system that was used to load the application) 16* *EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID*, for file system support 17* *EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID*, for keyboard support 18* *EFI_SIMPLE_POINTER_PROTOCOL_GUID*, for mouse support 19* *EFI_ABSOLUTE_POINTER_PROTOCOL_GUID*, for touch support 20* *EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID*, for drawing 21* *EFI_EDID_ACTIVE_PROTOCOL_GUID*, for drawing (optional) 22 23Configure UEFI driver 24------------------------ 25 26- Enable the UEFI driver support in lv_conf.h 27 28.. code-block:: c 29 30 #define LV_USE_UEFI 1 31 32- Enable the the memory core functions, which are wrappers around AllocatePool and FreePool (using memory of type *EfiBootServicesData*) if you do not wan't to use your own implementations 33 34.. code-block:: c 35 36 #define LV_UEFI_USE_MEMORY_SERVICES 1 37 38- You can enable file system support for the file system from which the appliation got loaded (default letter 'E') 39 40.. code-block:: c 41 42 #define LV_USE_FS_UEFI 1 43 44- You need to define an include file which contains the basic UEFI definitions (protocols and types), there are 2 predefined files which can be used for EDK2 and gnu-efi 45 46.. code-block:: c 47 48 #define LV_USE_UEFI_INCLUDE <lvgl/src/drivers/uefi/lv_uefi_edk2.h> 49 // or 50 #define LV_USE_UEFI_INCLUDE <lvgl/src/drivers/uefi/lv_uefi_gnu_efi.h> 51 52Usage 53----- 54 55.. code-block:: c 56 57 #include "lvgl/lvgl.h" 58 #include "lvgl/examples/lv_examples.h" 59 #include "lvgl/demos/lv_demos.h" 60 61 EFI_STATUS EFIAPI EfiMain(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE * SystemTable) 62 { 63 lv_uefi_init(ImageHandle, SystemTable); 64 lv_init(); 65 66 if(!lv_is_initialized()) return EFI_NOT_READY; 67 68 EFI_HANDLE handle = NULL; 69 lv_display_t* display = NULL; 70 lv_indev_t* indev = NULL; 71 lv_group_t* group = NULL; 72 lv_obj_t* cursor = NULL; 73 // used to get out of the main loop 74 size_t counter; 75 76 // Init the display 77 handle = lv_uefi_display_get_active(); 78 if(handle == NULL) { 79 handle = lv_uefi_display_get_any(); 80 } 81 if(handle == NULL) { 82 lv_deinit(); 83 return EFI_UNSUPPORTED; 84 } 85 86 display = lv_uefi_display_create(handle); 87 lv_display_set_default(display); 88 89 // Create the group 90 group = lv_group_create(); 91 lv_group_set_default(group); 92 93 // Create an image that can be used as cursor 94 cursor = lv_image_create(lv_layer_top()); 95 lv_image_set_src(cursor, "E:cursor.png"); 96 97 // Create the input devices 98 indev = lv_uefi_simple_text_input_indev_create(); 99 lv_indev_set_group(indev, lv_group_get_default()); 100 lv_uefi_simple_text_input_indev_add_all(indev); 101 102 indev = lv_uefi_simple_pointer_indev_create(NULL); 103 lv_uefi_simple_pointer_indev_add_all(indev); 104 lv_indev_set_cursor(indev, cursor); 105 106 indev = lv_uefi_absolute_pointer_indev_create(NULL); 107 lv_uefi_absolute_pointer_indev_add_all(indev); 108 109 lv_demo_widgets(); 110 111 // Run main loop for ~ 10 seconds 112 counter = 0; 113 while(counter < 10000) { 114 counter ++; 115 gBS->Stall(1000); 116 lv_tick_inc(1); 117 lv_timer_handler(); 118 } 119 120 return EFI_SUCCESS; 121 } 122