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 打印
相关推荐
enjoy嚣士2 天前
Windows10下安装arm64架构的centos
qemu·aarch64 linux·arm64 linux·arm64 centos
fox081513 天前
RTThread-Studio中,使用5.2.0版本默认配置生成工程,进行编译报警告的部分解决方法。
mcu·rt-thread·rtthread-studio
x-cmd16 天前
[x-cmd] QEMU 10.2.0 发布:虚拟机实时更新与性能飞跃的技术深度解读
安全·qemu·虚拟机·x-cmd
yao0003716 天前
基于QEMU+OpenSBI+edk2的riscv启动流程解析
qemu·riscv·uefi·bios·固件·opensbi
三雷科技18 天前
qemu-img 使用手册(含详细案例)
qemu
混分巨兽龙某某1 个月前
基于STM32的嵌入式操作系统RT-Thread移植教学(HAL库版本)
stm32·嵌入式硬件·rt-thread·rtos
张世争1 个月前
RT-Thread 5.3 windows bsp simulator scons --target=vs 生成的工程编译失败问题
windows·rt-thread·simulator
张世争1 个月前
RT-Thread windows bsp simulator Visual Studio 2012 (v110) (未安装) 问题
rt-thread·visual studio·simulator
河码匠1 个月前
libvirt xml 配置文件说明
qemu·kvm·libvirt
lindd9119111 个月前
4G模块应用,内网穿透,前端网页的制作第七讲(智能头盔数据上传至网页端)
前端·后端·零基础·rt-thread·实时操作系统·项目复刻