{"id":426,"date":"2025-03-20T09:05:02","date_gmt":"2025-03-20T01:05:02","guid":{"rendered":"https:\/\/www.armfun.cn\/?p=426"},"modified":"2025-03-20T09:05:02","modified_gmt":"2025-03-20T01:05:02","slug":"lvgl-8-4-%e5%85%a5%e9%97%a8%e6%8c%87%e5%8d%97","status":"publish","type":"post","link":"https:\/\/www.armfun.cn\/?p=426","title":{"rendered":"#LVGL 8.4 \u5165\u95e8\u6307\u5357"},"content":{"rendered":"<h2>1. LVGL \u7b80\u4ecb<\/h2>\n<p>LVGL\uff08Light and Versatile Graphics Library\uff09\u662f\u4e00\u4e2a\u8f7b\u91cf\u7ea7\u7684\u56fe\u5f62\u5e93\uff0c\u4e13\u4e3a\u5d4c\u5165\u5f0f\u7cfb\u7edf\u8bbe\u8ba1\u3002\u5b83\u652f\u6301\u591a\u79cd\u663e\u793a\u9a71\u52a8\uff0c\u80fd\u591f\u63d0\u4f9b\u5e73\u6ed1\u7684 GUI \u4f53\u9a8c\uff0c\u5e76\u4e14\u5177\u5907\u4e30\u5bcc\u7684\u7ec4\u4ef6\uff0c\u5982\u6309\u94ae\u3001\u6ed1\u5757\u3001\u56fe\u8868\u7b49\u3002<\/p>\n<p>LVGL 8.4 \u7248\u672c\u5728\u6027\u80fd\u3001\u6e32\u67d3\u4f18\u5316\u548c API \u65b9\u9762\u8fdb\u884c\u4e86\u6539\u8fdb\uff0c\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u66f4\u8f7b\u677e\u5730\u521b\u5efa\u6d41\u7545\u7684\u7528\u6237\u754c\u9762\u3002<\/p>\n<h2>2. LVGL 8.4 \u7684\u4e3b\u8981\u7279\u6027<\/h2>\n<ul>\n<li><strong>\u66f4\u9ad8\u6548\u7684\u6e32\u67d3\u5f15\u64ce<\/strong>\uff1a\u51cf\u5c11 CPU \u548c RAM \u5360\u7528\uff0c\u63d0\u9ad8\u52a8\u753b\u548c\u754c\u9762\u7684\u6d41\u7545\u5ea6\u3002<\/li>\n<li><strong>\u66f4\u7075\u6d3b\u7684\u6837\u5f0f\u7cfb\u7edf<\/strong>\uff1a\u652f\u6301\u52a8\u6001\u66f4\u6539\u63a7\u4ef6\u7684\u5916\u89c2\u3002<\/li>\n<li><strong>\u4f18\u5316\u7684\u4e8b\u4ef6\u5904\u7406<\/strong>\uff1a\u63d0\u9ad8\u54cd\u5e94\u901f\u5ea6\uff0c\u652f\u6301\u66f4\u590d\u6742\u7684\u4ea4\u4e92\u903b\u8f91\u3002<\/li>\n<li><strong>\u66f4\u597d\u7684\u591a\u663e\u793a\u652f\u6301<\/strong>\uff1a\u53ef\u4ee5\u5728\u591a\u4e2a\u5c4f\u5e55\u4e0a\u663e\u793a\u4e0d\u540c\u7684\u5185\u5bb9\u3002<\/li>\n<li><strong>\u6539\u8fdb\u7684\u6587\u672c\u6e32\u67d3<\/strong>\uff1a\u652f\u6301\u591a\u8bed\u8a00\u663e\u793a\u548c\u66f4\u6e05\u6670\u7684\u5b57\u4f53\u6e32\u67d3\u3002<\/li>\n<\/ul>\n<h2>3. LVGL 8.4 \u73af\u5883\u642d\u5efa<\/h2>\n<p>\u5728\u4f7f\u7528 LVGL \u4e4b\u524d\uff0c\u9700\u8981\u642d\u5efa\u5f00\u53d1\u73af\u5883\u3002\u4ee5\u4e0b\u662f\u57fa\u672c\u6b65\u9aa4\uff1a<\/p>\n<h3>3.1 \u4e0b\u8f7d LVGL<\/h3>\n<pre><code class=\"language-bash\"># \u514b\u9686 LVGL \u6e90\u7801\ngit clone https:\/\/github.com\/lvgl\/lvgl.git\ncd lvgl\ngit checkout v8.4.0<\/code><\/pre>\n<h3>3.2 \u914d\u7f6e CMake<\/h3>\n<p>\u5982\u679c\u4f7f\u7528 CMake \u8fdb\u884c\u7f16\u8bd1\uff0c\u53ef\u4ee5\u521b\u5efa <code>CMakeLists.txt<\/code> \u6587\u4ef6\uff1a<\/p>\n<pre><code class=\"language-cmake\">cmake_minimum_required(VERSION 3.10)\nproject(lvgl_example)\n\nadd_subdirectory(lvgl)\nadd_executable(main main.c)\ntarget_link_libraries(main lvgl)<\/code><\/pre>\n<h3>3.3 \u8fd0\u884c\u793a\u4f8b\u4ee3\u7801<\/h3>\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u7b80\u5355\u7684 LVGL 8.4 \u793a\u4f8b\uff0c\u521b\u5efa\u4e00\u4e2a\u57fa\u672c\u7684 GUI \u754c\u9762\uff0c\u5305\u62ec\u6309\u94ae\u548c\u6807\u7b7e\u3002<\/p>\n<pre><code class=\"language-c\">#include &quot;lvgl.h&quot;\n#include &quot;lv_drivers\/display\/monitor.h&quot;\n\nstatic void btn_event_cb(lv_event_t * e) {\n    lv_obj_t * label = lv_event_get_user_data(e);\n    lv_label_set_text(label, &quot;Button Clicked!&quot;);\n}\n\nint main(void) {\n    lv_init();\n\n    lv_disp_draw_buf_t draw_buf;\n    static lv_color_t buf1[LV_HOR_RES_MAX * 10];\n    lv_disp_draw_buf_init(&amp;draw_buf, buf1, NULL, LV_HOR_RES_MAX * 10);\n\n    lv_disp_drv_t disp_drv;\n    lv_disp_drv_init(&amp;disp_drv);\n    disp_drv.draw_buf = &amp;draw_buf;\n    disp_drv.flush_cb = monitor_flush;\n    disp_drv.hor_res = 480;\n    disp_drv.ver_res = 320;\n    lv_disp_t * disp = lv_disp_drv_register(&amp;disp_drv);\n\n    lv_obj_t * scr = lv_scr_act();\n    lv_obj_t * label = lv_label_create(scr);\n    lv_label_set_text(label, &quot;Hello LVGL!&quot;);\n    lv_obj_align(label, LV_ALIGN_CENTER, 0, -20);\n\n    lv_obj_t * btn = lv_btn_create(scr);\n    lv_obj_align(btn, LV_ALIGN_CENTER, 0, 20);\n    lv_obj_add_event_cb(btn, btn_event_cb, LV_EVENT_CLICKED, label);\n\n    lv_obj_t * btn_label = lv_label_create(btn);\n    lv_label_set_text(btn_label, &quot;Click Me&quot;);\n    lv_obj_center(btn_label);\n\n    while(1) {\n        lv_timer_handler();\n        usleep(5000);\n    }\n\n    return 0;\n}<\/code><\/pre>\n<h2>4. \u8fd0\u884c\u793a\u4f8b<\/h2>\n<p>\u7f16\u8bd1\u5e76\u8fd0\u884c\u7a0b\u5e8f\u540e\uff0c\u5c4f\u5e55\u4e0a\u4f1a\u663e\u793a &quot;Hello LVGL!&quot;\uff0c\u5e76\u6709\u4e00\u4e2a\u6309\u94ae &quot;Click Me&quot;\uff0c\u70b9\u51fb\u540e\u6587\u672c\u4f1a\u66f4\u65b0\u4e3a &quot;Button Clicked!&quot;\u3002<\/p>\n<h2>5. \u7ed3\u8bba<\/h2>\n<p>LVGL 8.4 \u662f\u4e00\u4e2a\u5f3a\u5927\u4e14\u8f7b\u91cf\u7ea7\u7684 GUI \u5e93\uff0c\u9002\u7528\u4e8e\u5d4c\u5165\u5f0f\u7cfb\u7edf\u3002\u5b83\u7684\u4f18\u5316\u4f7f\u5f97\u5f00\u53d1\u8005\u53ef\u4ee5\u66f4\u5bb9\u6613\u5730\u521b\u5efa\u9ad8\u6548\u7684\u7528\u6237\u754c\u9762\u3002\u5982\u679c\u4f60\u6b63\u5728\u5bfb\u627e\u4e00\u4e2a\u7075\u6d3b\u7684\u5d4c\u5165\u5f0f GUI \u89e3\u51b3\u65b9\u6848\uff0cLVGL 8.4 \u503c\u5f97\u4e00\u8bd5\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. LVGL \u7b80\u4ecb LVGL\uff08Light and Versatile &#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-426","post","type-post","status-publish","format-standard","hentry","category-arm"],"views":1424,"_links":{"self":[{"href":"https:\/\/www.armfun.cn\/index.php?rest_route=\/wp\/v2\/posts\/426","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.armfun.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.armfun.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.armfun.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.armfun.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=426"}],"version-history":[{"count":1,"href":"https:\/\/www.armfun.cn\/index.php?rest_route=\/wp\/v2\/posts\/426\/revisions"}],"predecessor-version":[{"id":427,"href":"https:\/\/www.armfun.cn\/index.php?rest_route=\/wp\/v2\/posts\/426\/revisions\/427"}],"wp:attachment":[{"href":"https:\/\/www.armfun.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=426"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.armfun.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=426"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.armfun.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=426"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}