2021-12-09 11:23:50 +08:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2006-2021, RT-Thread Development Team
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2021-10-18 Meco Man The first version
|
|
|
|
*/
|
|
|
|
#include <lvgl.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <rtdevice.h>
|
|
|
|
|
|
|
|
#include <drv_clcd.h>
|
|
|
|
|
2022-05-11 11:42:12 +08:00
|
|
|
lv_indev_t * touch_indev;
|
|
|
|
|
2021-12-09 11:23:50 +08:00
|
|
|
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_drv_t *indev_drv, 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)
|
|
|
|
{
|
|
|
|
static lv_indev_drv_t indev_drv;
|
|
|
|
|
|
|
|
lv_indev_drv_init(&indev_drv); /*Basic initialization*/
|
|
|
|
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
|
|
|
indev_drv.read_cb = input_read;
|
|
|
|
|
|
|
|
/*Register the driver in LVGL and save the created input device object*/
|
2022-05-11 11:42:12 +08:00
|
|
|
touch_indev = lv_indev_drv_register(&indev_drv);
|
2021-12-09 11:23:50 +08:00
|
|
|
}
|