修改gt911驱动测试触摸乱触发现象

This commit is contained in:
wen
2025-11-12 10:04:29 +08:00
parent 43c799919d
commit d24873566d
13 changed files with 125 additions and 114 deletions

View File

@@ -21,25 +21,25 @@
static struct rt_i2c_client gt911_client; static struct rt_i2c_client gt911_client;
/* hardware section */ // /* hardware section */
static rt_uint8_t GT911_CFG_TBL[] = { // static rt_uint8_t GT911_CFG_TBL[] = {
0x6C,0xE0,0x01,0xE0,0x01,0x05,0xF5,0x00,0x22,0x0F,0x28,0x0F, // 0x6D,0xE0,0x01,0xE0,0x01,0x05,0xF5,0x00,0x22,0x0F,0x28,0x0F,
0x5A,0x3C,0x03,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x18, // 0x5A,0x3C,0x03,0x05,0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x18,
0x1A,0x1E,0x14,0x85,0x25,0x0A,0xC8,0xCA,0xB5,0x06,0x00,0x00, // 0x1A,0x1E,0x14,0x85,0x25,0x0A,0x78,0x7A,0x0C,0x08,0x00,0x00,
0x01,0x22,0x00,0x10,0x00,0x01,0x00,0x00,0x00,0x03,0x64,0x32, // 0x00,0x21,0x01,0x10,0x00,0x01,0x00,0x00,0x00,0x03,0x64,0x32,
0x00,0x00,0x00,0xAA,0xE6,0xDE,0xC5,0x02,0x07,0x00,0x00,0x04, // 0x00,0x00,0x00,0x64,0x96,0xDE,0xD5,0x02,0x07,0x00,0x00,0x04,
0x8D,0xAF,0x00,0x86,0xBA,0x00,0x81,0xC5,0x00,0x7B,0xD2,0x00, // 0x8E,0x68,0x00,0x85,0x71,0x00,0x7E,0x7A,0x00,0x77,0x84,0x00,
0x76,0xDF,0x00,0x77,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 0x70,0x90,0x00,0x71,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x02,0x04,0x06,0x08,0x0A,0x0C,0x0E,0x10, // 0x00,0x00,0x00,0x00,0x02,0x04,0x06,0x08,0x0A,0x0C,0x0E,0x10,
0x12,0x14,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, // 0x12,0x14,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x08,0x06, // 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x08,0x06,
0x04,0x02,0x00,0x1D,0x1E,0x1F,0x20,0x21,0xFF,0xFF,0xFF,0xFF, // 0x04,0x02,0x00,0x1D,0x1E,0x1F,0x20,0x21,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, // 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF, // 0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0x96,0x01, // 0xFF,0xFF,0xFF,0xFF,0xEE,0x01,
}; // };
static rt_err_t gt911_write_reg(struct rt_i2c_client *dev, rt_uint8_t *data, static rt_err_t gt911_write_reg(struct rt_i2c_client *dev, rt_uint8_t *data,
rt_uint8_t len) rt_uint8_t len)
@@ -362,109 +362,109 @@ static rt_err_t gt911_control(struct rt_touch_device *touch, int cmd, void *arg)
gt911_get_config_version(&gt911_client, &regver, 1); gt911_get_config_version(&gt911_client, &regver, 1);
LOG_I("Config version:%d",regver); LOG_I("Config version:%d",regver);
if(regver!=0x6C) // if(regver!=0x6D)
{ // {
LOG_I("update touch config"); // LOG_I("update touch config");
rt_uint8_t buf[4]; // rt_uint8_t buf[4];
rt_uint8_t i = 0; // rt_uint8_t i = 0;
rt_uint8_t *config; // rt_uint8_t *config;
config = (rt_uint8_t *)rt_calloc(1, sizeof(GT911_CFG_TBL) + GT911_REGITER_LEN); // config = (rt_uint8_t *)rt_calloc(1, sizeof(GT911_CFG_TBL) + GT911_REGITER_LEN);
if (config == RT_NULL) { // if (config == RT_NULL) {
LOG_D("malloc config memory failed\n"); // LOG_D("malloc config memory failed\n");
return -RT_ERROR; // return -RT_ERROR;
} // }
//conmmand // //conmmand
config[0] =(rt_uint8_t)((GT911_CONFIG_REG >> 8) & 0xFF); // config[0] =(rt_uint8_t)((GT911_CONFIG_REG >> 8) & 0xFF);
config[1] =(rt_uint8_t)(GT911_CONFIG_REG & 0xFF); // config[1] =(rt_uint8_t)(GT911_CONFIG_REG & 0xFF);
//data // //data
memcpy(&config[2], GT911_CFG_TBL, sizeof(GT911_CFG_TBL)); // memcpy(&config[2], GT911_CFG_TBL, sizeof(GT911_CFG_TBL));
// switch (cmd) { // // switch (cmd) {
// case RT_TOUCH_CTRL_SET_X_RANGE: { // // case RT_TOUCH_CTRL_SET_X_RANGE: {
// rt_uint16_t x_range; // // rt_uint16_t x_range;
// x_range = *(rt_uint16_t *)arg; // // x_range = *(rt_uint16_t *)arg;
// config[4] = (rt_uint8_t)(x_range >> 8); // // config[4] = (rt_uint8_t)(x_range >> 8);
// config[3] = (rt_uint8_t)(x_range & 0xff); // // config[3] = (rt_uint8_t)(x_range & 0xff);
// GT911_CFG_TBL[2] = config[4]; // // GT911_CFG_TBL[2] = config[4];
// GT911_CFG_TBL[1] = config[3]; // // GT911_CFG_TBL[1] = config[3];
// break; // // break;
// } // // }
// case RT_TOUCH_CTRL_SET_Y_RANGE: { // // case RT_TOUCH_CTRL_SET_Y_RANGE: {
// rt_uint16_t y_range; // // rt_uint16_t y_range;
// y_range = *(rt_uint16_t *)arg; // // y_range = *(rt_uint16_t *)arg;
// config[6] = (rt_uint8_t)(y_range >> 8); // // config[6] = (rt_uint8_t)(y_range >> 8);
// config[5] = (rt_uint8_t)(y_range & 0xff); // // config[5] = (rt_uint8_t)(y_range & 0xff);
// GT911_CFG_TBL[4] = config[6]; // // GT911_CFG_TBL[4] = config[6];
// GT911_CFG_TBL[3] = config[5]; // // GT911_CFG_TBL[3] = config[5];
// break; // // break;
// } // // }
// case RT_TOUCH_CTRL_SET_X_TO_Y: { // // case RT_TOUCH_CTRL_SET_X_TO_Y: {
// config[8] ^= (1 << 3); // // config[8] ^= (1 << 3);
// break; // // break;
// } // // }
// case RT_TOUCH_CTRL_SET_MODE: { // // case RT_TOUCH_CTRL_SET_MODE: {
// rt_uint16_t trig_type; // // rt_uint16_t trig_type;
// trig_type = *(rt_uint16_t *)arg; // // trig_type = *(rt_uint16_t *)arg;
// switch (trig_type) { // // switch (trig_type) {
// case RT_DEVICE_FLAG_INT_RX: // // case RT_DEVICE_FLAG_INT_RX:
// config[8] &= 0xFC; // // config[8] &= 0xFC;
// break; // // break;
// case RT_DEVICE_FLAG_RDONLY: // // case RT_DEVICE_FLAG_RDONLY:
// config[8] &= 0xFC; // // config[8] &= 0xFC;
// config[8] |= 0x02; // // config[8] |= 0x02;
// break; // // break;
// default: // // default:
// break; // // break;
// } // // }
// break; // // break;
// } // // }
// default: { // // default: {
// break; // // break;
// } // // }
// } // // }
//写入配置 // //写入配置
if (gt911_write_reg(&gt911_client, config,sizeof(GT911_CFG_TBL) + GT911_ADDR_LEN) != RT_EOK) //lenght=cmd+data--->sizeof(GT911_CFG_TBL) + GT911_ADDR_LEN) // if (gt911_write_reg(&gt911_client, config,sizeof(GT911_CFG_TBL) + GT911_ADDR_LEN) != RT_EOK) //lenght=cmd+data--->sizeof(GT911_CFG_TBL) + GT911_ADDR_LEN)
{ // {
LOG_D("send config failed"); // LOG_D("send config failed");
return -1; // return -1;
} // }
//checksum // //checksum
buf[0] = (rt_uint8_t)((GT911_CHECK_SUM >> 8) & 0xFF); // buf[0] = (rt_uint8_t)((GT911_CHECK_SUM >> 8) & 0xFF);
buf[1] = (rt_uint8_t)(GT911_CHECK_SUM & 0xFF); // buf[1] = (rt_uint8_t)(GT911_CHECK_SUM & 0xFF);
buf[2] = 0; // buf[2] = 0;
buf[3] = 1; // buf[3] = 1;
//计算校验和 // //计算校验和
// for (i = GT911_ADDR_LEN; i < sizeof(GT911_CFG_TBL) + GT911_ADDR_LEN; i++) // // for (i = GT911_ADDR_LEN; i < sizeof(GT911_CFG_TBL) + GT911_ADDR_LEN; i++)
// { // // {
// buf[GT911_ADDR_LEN] += config[i]; // // buf[GT911_ADDR_LEN] += config[i];
// } // // }
for (i = 0; i < sizeof(GT911_CFG_TBL) ; i++) // for (i = 0; i < sizeof(GT911_CFG_TBL) ; i++)
{ // {
buf[2] += GT911_CFG_TBL[i]; // buf[2] += GT911_CFG_TBL[i];
} // }
LOG_I("checksum:%x",buf[2]); // LOG_I("checksum:%x",buf[2]);
LOG_I("checksum~:%x",~buf[2]); // LOG_I("checksum~:%x",~buf[2]);
buf[2] = (~buf[2]) + 1; // buf[2] = (~buf[2]) + 1;
LOG_I("checksum~+1:%x",buf[2]); // LOG_I("checksum~+1:%x",buf[2]);
buf[3] = 1;//是否写入到GT9147 FLASH? 即是否掉电保存 // buf[3] = 1;//是否写入到GT9147 FLASH? 即是否掉电保存
gt911_write_reg(&gt911_client, buf, 4); // gt911_write_reg(&gt911_client, buf, 4);
rt_free(config); // rt_free(config);
LOG_I("update config suss"); // LOG_I("update config suss");
} // }
if (cmd == RT_TOUCH_CTRL_GET_ID) { if (cmd == RT_TOUCH_CTRL_GET_ID) {
return gt911_get_product_id(&gt911_client, arg, 6); return gt911_get_product_id(&gt911_client, arg, 6);

Binary file not shown.

Binary file not shown.

BIN
t3e_pro标准版_v1.0.5.zip Normal file

Binary file not shown.

View File

@@ -793,8 +793,8 @@ CONFIG_CONFIG_LANAGUAGE_CHS=y
# CONFIG_CONFIG_LANAGUAGE_CHT is not set # CONFIG_CONFIG_LANAGUAGE_CHT is not set
# CONFIG_CONFIG_USER_RELAY_1 is not set # CONFIG_CONFIG_USER_RELAY_1 is not set
# CONFIG_CONFIG_USER_RELAY_2 is not set # CONFIG_CONFIG_USER_RELAY_2 is not set
CONFIG_CONFIG_USER_RELAY_3=y # CONFIG_CONFIG_USER_RELAY_3 is not set
# CONFIG_CONFIG_USER_RELAY_4 is not set CONFIG_CONFIG_USER_RELAY_4=y
CONFIG_CONFIG_DEVICE_SCR_ACT_JUMP=y CONFIG_CONFIG_DEVICE_SCR_ACT_JUMP=y
CONFIG_CONFIG_OBJICT_IMAGE=y CONFIG_CONFIG_OBJICT_IMAGE=y
CONFIG_CONFIG_USER_MENU_TABLEVEW=y CONFIG_CONFIG_USER_MENU_TABLEVEW=y

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<key name="Software"> <key name="Software">
<key name="ConEmu"> <key name="ConEmu">
<key name=".Vanilla" modified="2025-10-29 18:25:06" build="180206"> <key name=".Vanilla" modified="2025-11-11 18:32:22" build="180206">
<value name="StartType" type="hex" data="02"/> <value name="StartType" type="hex" data="02"/>
<value name="CmdLine" type="string" data=""/> <value name="CmdLine" type="string" data=""/>
<value name="StartTasksFile" type="string" data=""/> <value name="StartTasksFile" type="string" data=""/>
@@ -259,11 +259,11 @@
<value name="Cascaded" type="hex" data="01"/> <value name="Cascaded" type="hex" data="01"/>
<value name="IntegralSize" type="hex" data="00"/> <value name="IntegralSize" type="hex" data="00"/>
<value name="WindowMode" type="dword" data="0000051f"/> <value name="WindowMode" type="dword" data="0000051f"/>
<value name="ConWnd X" type="long" data="592"/> <value name="ConWnd X" type="long" data="494"/>
<value name="ConWnd Y" type="long" data="337"/> <value name="ConWnd Y" type="long" data="173"/>
<value name="LastMonitor" type="string" data="0,0,1920,1040"/> <value name="LastMonitor" type="string" data="0,0,1920,1040"/>
<value name="ConWnd Width" type="dword" data="00000071"/> <value name="ConWnd Width" type="dword" data="0000006f"/>
<value name="ConWnd Height" type="dword" data="00000027"/> <value name="ConWnd Height" type="dword" data="00000026"/>
<value name="16bit Height" type="ulong" data="0"/> <value name="16bit Height" type="ulong" data="0"/>
<value name="StartCreateDelay" type="ulong" data="100"/> <value name="StartCreateDelay" type="ulong" data="100"/>
<value name="ExtendFonts" type="hex" data="00"/> <value name="ExtendFonts" type="hex" data="00"/>

View File

@@ -182,3 +182,14 @@ me
me me
me me
me me
me
me
me
me
me
me
me
me
me
me
me