是这样的,我用imx283开发板,由于还没有移植好tslib,所以就用mouse_hid.c改了一下,在获取坐标的函数里直接赋坐标值模拟按键触摸,但是屏幕没有反应?
界面是自带的demo例程
bool mouse_hid_read(lv_indev_data_t * data)
{
static lv_indev_state_t st;
static unsigned char b;
//ts_read(touch_pad,&sample,1);
data->point.x = 240;
data->point.y = 25;
if(st == LV_INDEV_STATE_PR)
{
b ++;
if(b > 20)
{
b = 0;
st = LV_INDEV_STATE_REL;
}
}
else
{
b ++;
if(b > 20)
{
b = 0;
st = LV_INDEV_STATE_PR;
}
}
data->state = st;
printf("x = %d y = %d state = %d\r\n",data->point.x,data->point.y,data->state);
return false;
}
离线
看你的调试语句,读鼠标数据应该没问题吧?
离线
调用了的,while(1) {
lv_tick_inc(5);
lv_task_handler();
usleep(5000);
}
就是自带的demo,没改这个
离线
int main(void)
{
/*LittlevGL init*/
lv_init();
/*Linux frame buffer device init*/
fbdev_init();
mouse_hid_init();
/*Add a display the LittlevGL sing the frame buffer driver*/
lv_disp_drv_t disp_drv;
lv_disp_drv_init(&disp_drv);
disp_drv.disp_flush = fbdev_flush; /*It flushes the internal graphical buffer to the frame buffer*/
lv_disp_drv_register(&disp_drv);
lv_indev_drv_t in_drv;
lv_indev_drv_init(&in_drv);
in_drv.read = mouse_hid_read;
lv_indev_drv_register(&in_drv);
/*Create a Demo*/
demo_create();
//tpcal_create();
//lv_obj_t * label = lv_label_create(lv_scr_act(), NULL);
//lv_label_set_text(label, "Hello world!");
//lv_obj_align(label, NULL, LV_ALIGN_CENTER, 0, 0);
/*Handle LitlevGL tasks (tickless mode)*/
while(1) {
lv_tick_inc(5);
lv_task_handler();
usleep(5000);
}
return 0;
}
离线
lv_tick_inc 这个函数有没有调用,这个很重要
调用了的,直接用的官方demo
离线
除了触摸之外,其他正常吗?
离线
除了触摸之外,其他正常吗?
显示没问题,就是界面没反应
离线
眼花了
最近编辑记录 kgp0213 (2018-05-05 22:19:56)
离线
lv_indev_drv_init(&pdat->indev);
pdat->indev.type = LV_INDEV_TYPE_POINTER; //1
pdat->indev.read = ex_tp_read; //2
lv_indev_drv_register(&pdat->indev);
我用的是这种输入的,用tp。
最近编辑记录 kgp0213 (2018-05-05 22:24:50)
离线
while(1) {
lv_tick_inc(5);
lv_task_handler();
usleep(5000);
}
原来还可以这样操作~
最近编辑记录 kgp0213 (2018-05-05 22:22:07)
离线
lv_indev_drv_init(&pdat->indev);
pdat->indev.type = LV_INDEV_TYPE_POINTER;
pdat->indev.read = ex_tp_read;
lv_indev_drv_register(&pdat->indev);我用的是这种输入的,用tp,没问题,没用鼠标试验过哦
非常感谢,点醒梦中人啊,加上这句可以了
in_drv.type = LV_INDEV_TYPE_POINTER;
离线
可以用鼠标拖动了吗?
离线
可以用鼠标拖动了吗?
还没弄那个,我才了解这个ui,准备弄到linux上用触摸屏
离线
是这样的,我用imx283开发板,由于还没有移植好tslib,所以就用mouse_hid.c改了一下,在获取坐标的函数里直接赋坐标值模拟按键触摸,但是屏幕没有反应?
界面是自带的demo例程
bool mouse_hid_read(lv_indev_data_t * data)
{
static lv_indev_state_t st;
static unsigned char b;
//ts_read(touch_pad,&sample,1);
data->point.x = 240;
data->point.y = 25;
if(st == LV_INDEV_STATE_PR)
{
b ++;
if(b > 20)
{
b = 0;
st = LV_INDEV_STATE_REL;
}
}
else
{
b ++;
if(b > 20)
{
b = 0;
st = LV_INDEV_STATE_PR;
}
}
data->state = st;
printf("x = %d y = %d state = %d\r\n",data->point.x,data->point.y,data->state);return false;
}
感觉这段就干了一件事:
data->point.x = 240;
data->point.y = 25;
data->state = LV_INDEV_STATE_PR;
离线
775624981 说:是这样的,我用imx283开发板,由于还没有移植好tslib,所以就用mouse_hid.c改了一下,在获取坐标的函数里直接赋坐标值模拟按键触摸,但是屏幕没有反应?
界面是自带的demo例程
bool mouse_hid_read(lv_indev_data_t * data)
{
static lv_indev_state_t st;
static unsigned char b;
//ts_read(touch_pad,&sample,1);
data->point.x = 240;
data->point.y = 25;
if(st == LV_INDEV_STATE_PR)
{
b ++;
if(b > 20)
{
b = 0;
st = LV_INDEV_STATE_REL;
}
}
else
{
b ++;
if(b > 20)
{
b = 0;
st = LV_INDEV_STATE_PR;
}
}
data->state = st;
printf("x = %d y = %d state = %d\r\n",data->point.x,data->point.y,data->state);return false;
}感觉这段就干了一件事:
data->point.x = 240;
data->point.y = 25;
data->state = LV_INDEV_STATE_PR;
littlevgl官网的范例里面已经有了一个自带滑动的宏定义(define LV_DEMO_SLIDE_SHOW)了,开了之后就可以自动左右滑动了
src/external/lvgl-v5.1/lv_ex_conf.h 查看文件 @ 5c41db8
@@ -36,6 +36,7 @@
#define USE_LV_DEMO 1
#if USE_LV_DEMO
#define LV_DEMO_WALLPAPER 1 /*Create a wallpaper too*/
+#define LV_DEMO_SLIDE_SHOW 0 /*Automatically switch between tabs*/
离线
好使了吗
离线