This commit is contained in:
刘可亮
2024-10-30 16:50:31 +08:00
parent 0ef85b55da
commit 661e71562d
458 changed files with 46555 additions and 12133 deletions

View File

@@ -53,22 +53,32 @@ config AIC_TOUCH_PANEL_INT_PIN
depends on AIC_USING_CTP
config AIC_TOUCH_X_COORDINATE_RANGE
int "Touch x coordinate range"
int "Touch real x coordinate range"
default 1024
depends on AIC_USING_CTP
config AIC_TOUCH_Y_COORDINATE_RANGE
int "Touch y coordinate range"
int "Touch real y coordinate range"
default 600
depends on AIC_USING_CTP
config AIC_TOUCH_X_FILP
bool "Touch filp x coordinate"
config AIC_SCREEN_REAL_X_RESOLUTION
int "Screen real x coordinate range"
default 1024
depends on AIC_USING_CTP
config AIC_SCREEN_REAL_Y_RESOLUTION
int "Screen real y coordinate range"
default 600
depends on AIC_USING_CTP
config AIC_TOUCH_X_FLIP
bool "Touch flip x coordinate"
default n
depends on AIC_USING_CTP
config AIC_TOUCH_Y_FILP
bool "Touch filp y coordinate"
config AIC_TOUCH_Y_FLIP
bool "Touch flip y coordinate"
default n
depends on AIC_USING_CTP
@@ -82,17 +92,49 @@ config AIC_TOUCH_270_DEGREE_ROTATION
default n
depends on AIC_USING_CTP
config AIC_TOUCH_CROP
bool "Enable touch crop"
default n
help
Some Touch need to be cropped, the effective area displayed is less
than the timing signal.
If unsure select "N".
if AIC_TOUCH_CROP
config AIC_TOUCH_CROP_POS_X
int "Touch crop x position of pixels"
default 0
config AIC_TOUCH_CROP_POS_Y
int "Touch crop y position of pixels"
default 0
config AIC_TOUCH_CROP_WIDTH
int "Touch crop width"
default 1024
config AIC_TOUCH_CROP_HEIGHT
int "Touch crop height"
default 600
endif
config AIC_TOUCH_REPORT_X_COORDINATE
int
default AIC_TOUCH_CROP_HEIGHT if AIC_TOUCH_90_DEGREE_ROTATION && AIC_TOUCH_CROP
default AIC_TOUCH_CROP_HEIGHT if AIC_TOUCH_270_DEGREE_ROTATION && AIC_TOUCH_CROP
default AIC_TOUCH_Y_COORDINATE_RANGE if AIC_TOUCH_90_DEGREE_ROTATION
default AIC_TOUCH_Y_COORDINATE_RANGE if AIC_TOUCH_270_DEGREE_ROTATION
default AIC_TOUCH_CROP_WIDTH if AIC_TOUCH_CROP
default AIC_TOUCH_X_COORDINATE_RANGE
depends on AIC_USING_CTP
config AIC_TOUCH_REPORT_Y_COORDINATE
int
default AIC_TOUCH_CROP_WIDTH if AIC_TOUCH_90_DEGREE_ROTATION && AIC_TOUCH_CROP
default AIC_TOUCH_CROP_WIDTH if AIC_TOUCH_270_DEGREE_ROTATION && AIC_TOUCH_CROP
default AIC_TOUCH_X_COORDINATE_RANGE if AIC_TOUCH_90_DEGREE_ROTATION
default AIC_TOUCH_X_COORDINATE_RANGE if AIC_TOUCH_270_DEGREE_ROTATION
default AIC_TOUCH_CROP_HEIGHT if AIC_TOUCH_CROP
default AIC_TOUCH_Y_COORDINATE_RANGE
depends on AIC_USING_CTP

View File

@@ -6,6 +6,11 @@ cwd = GetCurrentDir()
src = Glob('*.c')
CPPPATH = []
if GetDepend('AIC_USING_CTP'):
CPPPATH.append(cwd)
CPPPATH.append(cwd + '/common')
src += Glob('common/*.c')
if GetDepend('AIC_TOUCH_PANEL_GT911'):
CPPPATH.append(cwd + '/gt911/inc')
src += Glob('gt911/src/*.c')

View File

@@ -0,0 +1,67 @@
/*
* Copyright (c) 2024, ArtInChip Technology Co., Ltd
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Notes
* 2024-10-18 the first version
*/
#include "touch_common.h"
void aic_touch_flip(int16_t *x_coordinate, int16_t *y_coordinate)
{
#ifdef AIC_TOUCH_X_FLIP
*x_coordinate = (rt_int16_t)AIC_TOUCH_X_COORDINATE_RANGE - *x_coordinate;
#endif
#ifdef AIC_TOUCH_Y_FLIP
*y_coordinate = (rt_int16_t)AIC_TOUCH_Y_COORDINATE_RANGE - *y_coordinate;
#endif
}
void aic_touch_rotate(int16_t *x_coordinate, int16_t *y_coordinate)
{
rt_uint16_t temp = 0;
temp = temp;
#ifdef AIC_TOUCH_90_DEGREE_ROTATION
temp = *x_coordinate;
*x_coordinate = *y_coordinate;
*y_coordinate = (rt_int16_t)AIC_TOUCH_X_COORDINATE_RANGE - temp;
#endif
#ifdef AIC_TOUCH_270_DEGREE_ROTATION
temp = *x_coordinate;
*x_coordinate = (rt_int16_t)AIC_TOUCH_Y_COORDINATE_RANGE - *y_coordinate;
*y_coordinate = temp;
#endif
}
void aic_touch_scale(int16_t *x_coordinate, int16_t *y_coordinate)
{
#ifdef AIC_TOUCH_CROP
rt_int32_t temp_x;
rt_int32_t temp_y;
temp_x = (*x_coordinate) * AIC_SCREEN_REAL_X_RESOLUTION * 10 / AIC_TOUCH_X_COORDINATE_RANGE / 10;
temp_y = (*y_coordinate) * AIC_SCREEN_REAL_Y_RESOLUTION * 10 / AIC_TOUCH_Y_COORDINATE_RANGE / 10;
*x_coordinate = (int16_t)temp_x;
*y_coordinate = (int16_t)temp_y;
#endif
}
rt_int8_t aic_touch_crop(int16_t *x_coordinate, int16_t *y_coordinate)
{
#ifdef AIC_TOUCH_CROP
if (*x_coordinate < AIC_TOUCH_CROP_POS_X || *y_coordinate < AIC_TOUCH_CROP_POS_Y
|| *x_coordinate > (AIC_TOUCH_CROP_POS_X + AIC_TOUCH_CROP_WIDTH)
|| *y_coordinate > (AIC_TOUCH_CROP_POS_Y + AIC_TOUCH_CROP_HEIGHT)) {
return RT_FALSE;
}
*x_coordinate -= AIC_TOUCH_CROP_POS_X;
*y_coordinate -= AIC_TOUCH_CROP_POS_Y;
#endif
return RT_TRUE;
}

View File

@@ -0,0 +1,21 @@
/*
* Copyright (c) 2024, ArtInChip Technology Co., Ltd
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Notes
* 2024-10-18 the first version
*/
#ifndef __TOUCH_COMMON_H__
#define __TOUCH_COMMON_H__
#include <rtthread.h>
#include <rtdevice.h>
void aic_touch_flip(int16_t *x_coordinate, int16_t *y_coordinate);
void aic_touch_rotate(int16_t *x_coordinate, int16_t *y_coordinate);
void aic_touch_scale(int16_t *x_coordinate, int16_t *y_coordinate);
rt_int8_t aic_touch_crop(int16_t *x_coordinate, int16_t *y_coordinate);
#endif

View File

@@ -17,7 +17,7 @@
#define DBG_TAG "gt911"
#define DBG_LVL DBG_INFO
#include <rtdbg.h>
#include "../../common/touch_common.h"
#include "gt911.h"
static struct rt_i2c_client gt911_client;
@@ -318,6 +318,11 @@ static rt_size_t gt911_read_point(struct rt_touch_device *touch, void *buf,
input_w =
read_buf[off_set + 5] | (read_buf[off_set + 6] << 8); /* size */
aic_touch_flip(&input_x, &input_y);
aic_touch_rotate(&input_x, &input_y);
aic_touch_scale(&input_x, &input_y);
if (!aic_touch_crop(&input_x, &input_y))
continue;
gt911_touch_down(buf, read_id, input_x, input_y, input_w);
}
} else if (pre_touch) {