Win32 Code::Block LVGL
Create Win32 Project
Frame based
GNU GCC Compiler
Run
Remove Console: Right Click Project → Properties…
Build targets → Debug → Type: GUI application
Build → Rebuild (Ctrl+F11)
Run
Add LGVL
cd Win32CodeBlockLVGL
git submodule init
git submodule add https://github.com/lvgl/lvgl.git lvgl
cp lvgl/lv_conf_template.h lv_conf.h
Edit lv_conf
diff --git a/lv_conf.h b/lv_conf.h
old mode 100644
new mode 100755
index 914189f..410786c
--- a/lv_conf.h
+++ b/lv_conf.h
@@ -12,7 +12,7 @@
*/
/* clang-format off */
-#if 0 /* Set this to "1" to enable content */
+#if 1 /* Set this to "1" to enable content */
#ifndef LV_CONF_H
#define LV_CONF_H
@@ -106,7 +106,7 @@
* - LV_OS_WINDOWS
* - LV_OS_MQX
* - LV_OS_CUSTOM */
-#define LV_USE_OS LV_OS_NONE
+#define LV_USE_OS LV_OS_WINDOWS
#if LV_USE_OS == LV_OS_CUSTOM
#define LV_OS_CUSTOM_INCLUDE <stdint.h>
@@ -1173,7 +1173,7 @@
#endif
/** LVGL Windows backend */
-#define LV_USE_WINDOWS 0
+#define LV_USE_WINDOWS 1
/** Use OpenGL to open window on PC and handle mouse and keyboard */
#define LV_USE_OPENGLES 0
Add files recursively…
Choose lvgl
directory
Add files
Choose lv_conf.h
Rebuild (Ctrl+F11)
lvgl\demos\benchmark\assets\img_benchmark_avatar.c
|12|fatal error:
lvgl/lvgl.h: No such file or directory|
Project → Build options…
Win32CodeBlockLVGL(or choose Debug/Release)
Compiler settings → Compiler Flags → Check -std=c17
CodeBlock_LVGL → Compiler settings → #defines
WINVER=0x0601
WIN32
_WIN32
CodeBlock_LVGL → Search directories . lvgl
Hello LVGL
main.c
#include <stdlib.h>
#include <unistd.h>
#include "lvgl/lvgl.h"
static const wchar_t * title = L"LVGL port Windows CodeBlocks. https://lvgl.io | https://docs.lvgl.io";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nCmdShow)
{
/*Initialize LVGL*/
lv_init();
/*Initialize the HAL for LVGL*/
lv_display_t * display = lv_windows_create_display(title, 800, 480, 100, FALSE, FALSE);
lv_windows_acquire_pointer_indev(display);
/*Output prompt information to the console, you can also use printf() to print directly*/
LV_LOG_USER("LVGL initialization completed!");
lv_obj_t * label = lv_label_create(lv_screen_active());
// Set the label text
lv_label_set_text(label, "Hello, LVGL!");
// Align the label in the center
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
while (1) {
/* Periodically call the lv_task handler.
* It could be done in a timer interrupt or an OS task too.*/
lv_task_handler();
usleep(5000); /*Just to let the system breath*/
}
return 0;
}