编程开源技术交流,分享技术与知识

网站首页 > 开源技术 正文

在Linux桌面环境下试用LVGL linux桌面应用用什么编写最好

wxchong 2024-12-28 16:08:56 开源技术 39 ℃ 0 评论

LVGL (Light and Versatile Graphics Library) is a free and open-source graphics library providing everything you need to create an embedded GUI with easy-to-use graphical elements, beautiful visual effects and a low memory footprint.

We are delighted to announce that Xiaomi has chosen LVGL for their latest S1 Pro Smart Watch. We received a sample from them and it looks phenomenal. We couldn’t be more thrilled to work with such an innovative company.

有时候从github下载.zip比用git clone快,反正我下载到了lvgl-master.zip。建立一个目录try,从lvgl下复制几个文件和目录过来,ls -F try/lvgl:

lv_conf.h  lvgl.h  lvgl.mk  lv_version.h  src/

src是个目录,用cp -a复制。a代表archive(归档),same as -dR --preserve=all,d代表目录,R代表递归(recursive)。

lv_conf.h是lv_conf_template.h改名来的。第一个#if 0要改成1,LV_USE_X11也要改成1:

#if 1 /*Set it to "1" to enable content*/
...
#define LV_COLOR_DEPTH 24
...
/*Use X11 to open window on Linux desktop and handle mouse and keyboard*/
#define LV_USE_X11              1

没有试其它COLOR DEPTH。我的Linux桌面的是24,用xwininfo -root | grep Depth看到的。

lvgl.mk:

LVGL_PATH ?= ${shell pwd}/lvgl

ASRCS += $(shell find $(LVGL_PATH)/src -type f -name '*.S')
CSRCS += $(shell find $(LVGL_PATH)/src -type f -name '*.c')
CSRCS += $(shell find $(LVGL_PATH)/demos -type f -name '*.c')
CSRCS += $(shell find $(LVGL_PATH)/examples -type f -name '*.c')
CXXEXT := .cpp
CXXSRCS += $(shell find $(LVGL_PATH)/src -type f -name '*${CXXEXT}')

AFLAGS += "-I$(LVGL_PATH)"
CFLAGS += "-I$(LVGL_PATH)"
CXXFLAGS += "-I$(LVGL_PATH)"

在try目录下编辑个Makefile:

include lvgl/lvgl.mk

# 替换扩展名
Os = $(CXXSRCS:.cpp=.o) \
  $(CSRCS:.c=.o)

a.out: t.o liblvgl.a
# 下一行的首字符应为TAB
  $(CC) -o $@ $^ -lX11

liblvgl.a: $(Os)
# 下一行的首字符应为TAB
  ar r $@ $(Os)

Linux下的库叫libxxx.a,ar - create, modify, and extract from archives。r Insert the files member... into archive (with replacement).

然后make。LVGL里有汇编代码,如neon相关的。编译lvgl/src/draw/sw/blend/neon/lv_blend_neon.S时找不到../../lv_conf.h。因为没有用到所以没去管它,没编译进liblvgl.a。

运行a.out出来个名为LVGL X11 Simulation的空白窗口,分辨率为800x600。

t.cpp:

#include <lvgl.h>
int main() {
  lv_init();
  /* initialize X11 display driver */
  lv_display_t * disp = lv_x11_window_create("LVGL X11 Simulation", 800, 600);
  /* initialize X11 input drivers (for keyboard, mouse & mousewheel) */
  lv_x11_inputs_create(disp, NULL);
  while (1) {
    /* Periodically call the lv_timer handler */
    lv_timer_handler();
  }
  return 0;
}

吐槽:

  • 示例X11的代码没调lv_init;没调的后果是core dump。
  • 风扇狂转。lv_timer_handler()的循环里该sleep吧?time.h里有nanosleep。
  • Proteus叫仿真(比如x64 Windows下仿真8051),把一个窗口当屏幕用也敢叫仿真?
  • 像在下这样写文档,Linux取代Windows才更有希望。[微笑]

Tags:

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表