说明
-
RT-Thread : 5.2.0
-
LVGL 9.5
-
BSP : qemu-vexpress-a9
-
更新 LVGL 9.5 版本后, 原来的 LVGL8.3 版本的 Mouse 鼠标输入设备驱动
lv_port_indev.c需要重新适配。 -
qemu qemu-vexpress-a9 Mouse 输入设备,鼠标的坐标默认被动读取。也就是鼠标移动或者点击后,产生坐标数据与输入事件(按下、弹起),等待 LVGL 周期性输入读取回调函数读取。
LVGL9.5 lv_port_indev.c 适配
- 适配如下
c
#include <lvgl.h>
#include <stdbool.h>
#include <rtdevice.h>
#include <drv_clcd.h>
lv_indev_t * touch_indev;
static lv_indev_state_t last_state = LV_INDEV_STATE_REL;
static rt_int16_t last_x = 0;
static rt_int16_t last_y = 0;
static void input_read(lv_indev_t * indev, lv_indev_data_t *data)
{
data->point.x = last_x;
data->point.y = last_y;
data->state = last_state;
}
void lv_port_indev_input(rt_int16_t x, rt_int16_t y, lv_indev_state_t state)
{
last_state = state;
last_x = x;
last_y = y;
}
void lv_port_indev_init(void)
{
touch_indev = lv_indev_create();
lv_indev_set_type(touch_indev, LV_INDEV_TYPE_POINTER);
lv_indev_set_read_cb(touch_indev, input_read);
}
效果
-
新版本如 LVGL 9.5 工程编译通过
-
点击鼠标后,产生事件。比如更按钮的颜色

点击按钮,触发按钮的背景颜色切换。

- 默认 LVGL 的 LOG,比如
LV_LOG_USER("Clicked");没有输出, RT-Thread 上需要适配 LOG 打印