RT-Thread qemu LVGL9.5 鼠标 indev 驱动更新 lv_port_indev.c

说明

  • 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 打印
相关推荐
张世争2 天前
RT-Thread bsp qemu-vexpress-a9 编译环境
qemu·rt-thread·编译
daqinzl20 天前
银河麒麟V10下使用QEMU安装Windows虚拟机
qemu·windows 10·银河麒麟v10
SXSBJS_XYT25 天前
在资源有限的M0单片机上运行RTOS
单片机·rt-thread·rtos
ejinxian1 个月前
Linux 虚拟化技术 KVM/ESXI/Docker
linux·运维·docker·qemu·openvz
明早你自己说1 个月前
RT-Thread 在SD卡实现ulog+时间戳保存不同日志方法
stm32·rt-thread·ulog
skywalk81631 个月前
windows装wsl ubuntu24.04 ,里面装qemu ,然后装mac os (windows也可以直接qemu安装macos)(未实践)
windows·ubuntu·macos·qemu
学生董格2 个月前
[嵌入式embed]Keil5-STM32F103C8T6(江协科技)+移植RT-Thread v3.15模版
stm32·嵌入式硬件·rt-thread·keil5·江协科技
漫谈网络2 个月前
KVM创建的虚拟机,虚拟机的网卡是如何生成的
运维·服务器·网络·qemu·虚拟化·kvm
Zenexus4 个月前
VSCODE+GDB+QEMU调试内核
linux·vscode·qemu·gdb