Skip to content
This repository was archived by the owner on Jan 7, 2023. It is now read-only.

Commit 85f42ee

Browse files
committed
Initial working app
1 parent b73cd2f commit 85f42ee

9 files changed

Lines changed: 212 additions & 4 deletions

File tree

Abm.dsc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@
7979
StrLib|AbmPkg/Library/StrLib/StrLib.inf
8080
MallocLib|AbmPkg/Library/MallocLib/MallocLib.inf
8181
MicroLibC|AbmPkg/Library/MicroLibC/MicroLibC.inf
82+
83+
AbmLib|AbmPkg/Library/AbmLib/AbmLib.inf
8284

8385
[LibraryClasses.AARCH64]
8486
CompilerIntrinsicsLib|ArmPkg/Library/CompilerIntrinsicsLib/CompilerIntrinsicsLib.inf

Include/Library/abm_base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
void test_lvgl(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable);

Include/Library/main.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <Uefi.h>
2+
#include <Protocol/GraphicsOutput.h>
3+
#include <Library/UefiLib.h>
4+
//TODO: fix this include
5+
#include <../Include/lvgl.h>
6+
#include <../Include/lv_misc/lv_log.h>
7+
#include <string.h>
8+
9+
static void event_handler(lv_obj_t * obj, lv_event_t event);
10+
static void EfiGopBltFlush(
11+
lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p);
12+
13+
bool key_read(lv_indev_drv_t * drv, lv_indev_data_t*data);
14+
15+
//
16+
// main entry point
17+
//
18+
EFI_STATUS
19+
EFIAPI
20+
efi_main_init (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable);

Library/AbmLib/AbmLib.inf

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
[Defines]
2+
INF_VERSION = 0x00010005
3+
BASE_NAME = AbmLib
4+
FILE_GUID = 5e600feb-6d54-4f87-8199-8d614576bf22
5+
MODULE_TYPE = BASE
6+
VERSION_STRING = 1.0
7+
LIBRARY_CLASS = ABM
8+
9+
[Packages]
10+
ArmPkg/ArmPkg.dec
11+
MdePkg/MdePkg.dec
12+
AbmPkg/Abm.dec
13+
14+
[LibraryClasses]
15+
BaseLib
16+
IoLib
17+
PrintLib
18+
DebugLib
19+
TimerLib
20+
CacheMaintenanceLib
21+
MicroLibC
22+
LittleVglLib
23+
DxeServicesTableLib
24+
UefiLib
25+
UefiApplicationEntryPoint
26+
Zlib
27+
ArmLib
28+
HobLib
29+
PerformanceLib
30+
DebugPrintErrorLevelLib
31+
TimerLib
32+
BootLib
33+
EfiFileLib
34+
35+
[Sources.common]
36+
abm_base.h
37+
abm_base.c

abm/main.c renamed to Library/AbmLib/abm_base.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ EFI_GRAPHICS_OUTPUT_PROTOCOL *mGop;
1212
lv_disp_drv_t mDispDrv;
1313
lv_indev_drv_t mFakeInputDrv;
1414
lv_disp_t * disp;
15-
15+
bool abm_running=true;
16+
static void event_handler(lv_obj_t * obj, lv_event_t event)
17+
{
18+
if(event == LV_EVENT_CLICKED) {
19+
abm_running=false;
20+
}
21+
}
1622
static void EfiGopBltFlush(
1723
lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
1824
{
@@ -59,7 +65,7 @@ bool key_read(lv_indev_drv_t * drv, lv_indev_data_t*data)
5965
//
6066
EFI_STATUS
6167
EFIAPI
62-
efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
68+
test_lvgl (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
6369
{
6470
gST1 = SystemTable;
6571
gBS1 = gST1->BootServices;
@@ -99,11 +105,13 @@ efi_main (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
99105
lv_obj_t * list_btn;
100106
lv_obj_set_state(list1, LV_STATE_DEFAULT);
101107
list_btn = lv_list_add_btn(list1, LV_SYMBOL_FILE, "Example 1");
108+
lv_obj_set_event_cb(list_btn, event_handler);
102109
list_btn = lv_list_add_btn(list1, LV_SYMBOL_FILE, "Example 2");
110+
lv_obj_set_event_cb(list_btn, event_handler);
103111
list_btn = lv_list_add_btn(list1, LV_SYMBOL_FILE, "Extras");
104112
lv_list_set_anim_time(list1, 500);
105113

106-
while (TRUE) {
114+
while (abm_running) {
107115
lv_tick_inc(1);
108116
lv_task_handler();
109117
gBS1->Stall(EFI_TIMER_PERIOD_MILLISECONDS(1));

Library/AbmLib/abm_base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
void test_lvgl(IN EFI_SYSTEM_TABLE *SystemTable);

abm.inf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#
2323

2424
[Sources]
25-
abm/main.c
25+
abm/abm.c
2626

2727
[Packages]
2828
MdePkg/MdePkg.dec

abm/abm.c

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
#include <Uefi.h>
2+
#include <Protocol/GraphicsOutput.h>
3+
#include <Library/UefiLib.h>
4+
//TODO: fix this include
5+
#include <../Include/lvgl.h>
6+
#include <../Include/lv_misc/lv_log.h>
7+
#include <string.h>
8+
9+
EFI_SYSTEM_TABLE *gST1;
10+
EFI_BOOT_SERVICES *gBS1;
11+
EFI_GRAPHICS_OUTPUT_PROTOCOL *mGop;
12+
lv_disp_drv_t mDispDrv;
13+
lv_indev_drv_t mFakeInputDrv;
14+
lv_disp_t * disp;
15+
bool abm_running=true;
16+
static void event_handler(lv_obj_t * obj, lv_event_t event)
17+
{
18+
if(event == LV_EVENT_CLICKED) {
19+
abm_running=false;
20+
}
21+
}
22+
static void EfiGopBltFlush(
23+
lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p)
24+
{
25+
mGop->Blt(
26+
mGop, (EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)color_p, EfiBltBufferToVideo, 0, 0,
27+
area->x1, area->y1, area->x2 - area->x1 + 1, area->y2 - area->y1 + 1, 0);
28+
29+
lv_disp_flush_ready(disp_drv);
30+
}
31+
32+
33+
//Read keys state
34+
bool key_read(lv_indev_drv_t * drv, lv_indev_data_t*data)
35+
{
36+
EFI_INPUT_KEY Key;
37+
38+
//Read keys
39+
gST1->ConIn->ReadKeyStroke (gST1->ConIn, &Key);
40+
41+
//Vol up
42+
data->key = LV_KEY_UP;
43+
if (Key.ScanCode==SCAN_UP){
44+
data->state = LV_INDEV_STATE_PR;
45+
return false;
46+
}
47+
48+
//Vol down
49+
data->key = LV_KEY_DOWN;
50+
if (Key.ScanCode==SCAN_DOWN){
51+
data->state = LV_INDEV_STATE_PR;
52+
return false;
53+
}
54+
55+
//Pwr key
56+
data->key = LV_KEY_ENTER;
57+
if (Key.ScanCode==SCAN_SUSPEND){
58+
data->state = LV_INDEV_STATE_PR;
59+
return false;
60+
}
61+
}
62+
63+
//
64+
// main entry point
65+
//
66+
EFI_STATUS
67+
EFIAPI
68+
efi_main_init (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable)
69+
{
70+
gST1 = SystemTable;
71+
gBS1 = gST1->BootServices;
72+
gBS1->LocateProtocol(
73+
&gEfiGraphicsOutputProtocolGuid, NULL, (VOID **)&mGop);
74+
75+
76+
// Prepare LittleVGL
77+
lv_init();
78+
static lv_disp_buf_t disp_buf;
79+
static lv_color_t buf[LV_HOR_RES_MAX * 10]; /*Declare a buffer for 10 lines*/
80+
lv_disp_buf_init( & disp_buf, buf, NULL, LV_HOR_RES_MAX * 10); /*Initialize the display buffer*/
81+
lv_disp_drv_t disp_drv; /*Descriptor of a display driver*/
82+
lv_disp_drv_init( & disp_drv); /*Basic initialization*/
83+
disp_drv.flush_cb = EfiGopBltFlush; /*Set your driver function*/
84+
disp_drv.buffer = & disp_buf; /*Assign the buffer to the display*/
85+
lv_disp_drv_register( & disp_drv); /*Finally register the driver*/
86+
87+
lv_obj_t * win = lv_win_create(lv_scr_act(), NULL);
88+
lv_win_set_title(win, "Boot Menu");
89+
lv_obj_t * list1 = lv_list_create(win, NULL);
90+
lv_obj_set_size(list1, 1000, 1050);
91+
92+
lv_group_t * g1 = lv_group_create();
93+
lv_group_add_obj(g1, list1);
94+
lv_group_focus_obj(list1);
95+
96+
97+
lv_indev_drv_t indev_drv;
98+
lv_indev_drv_init(&indev_drv); /*Basic initialization*/
99+
indev_drv.type = LV_INDEV_TYPE_KEYPAD;
100+
indev_drv.read_cb = key_read;
101+
/*Register the driver in LVGL and save the created input device object*/
102+
lv_indev_t * my_indev = lv_indev_drv_register(&indev_drv);
103+
lv_indev_set_group(my_indev, g1);
104+
105+
lv_obj_t * list_btn;
106+
lv_obj_set_state(list1, LV_STATE_DEFAULT);
107+
list_btn = lv_list_add_btn(list1, LV_SYMBOL_FILE, "Example 1");
108+
lv_obj_set_event_cb(list_btn, event_handler);
109+
list_btn = lv_list_add_btn(list1, LV_SYMBOL_FILE, "Example 2");
110+
lv_obj_set_event_cb(list_btn, event_handler);
111+
list_btn = lv_list_add_btn(list1, LV_SYMBOL_FILE, "Extras");
112+
lv_list_set_anim_time(list1, 500);
113+
114+
while (abm_running) {
115+
lv_tick_inc(1);
116+
lv_task_handler();
117+
gBS1->Stall(EFI_TIMER_PERIOD_MILLISECONDS(1));
118+
}
119+
}

abm/abm.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <Uefi.h>
2+
#include <Protocol/GraphicsOutput.h>
3+
#include <Library/UefiLib.h>
4+
//TODO: fix this include
5+
#include <../Include/lvgl.h>
6+
#include <../Include/lv_misc/lv_log.h>
7+
#include <string.h>
8+
9+
static void event_handler(lv_obj_t * obj, lv_event_t event);
10+
static void EfiGopBltFlush(
11+
lv_disp_drv_t * disp_drv, const lv_area_t * area, lv_color_t * color_p);
12+
13+
bool key_read(lv_indev_drv_t * drv, lv_indev_data_t*data);
14+
15+
//
16+
// main entry point
17+
//
18+
EFI_STATUS
19+
EFIAPI
20+
efi_main_init (EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE *SystemTable);

0 commit comments

Comments
 (0)