From 620fa10adf747f0a9a23ca3b6b04ccfdb74e29b8 Mon Sep 17 00:00:00 2001 From: sunbeam Date: Mon, 2 Dec 2024 13:28:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=98=B2=E8=AF=AF=E8=A7=A6?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- firmware/src/RTE/RTE.c | 60 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/firmware/src/RTE/RTE.c b/firmware/src/RTE/RTE.c index 45e47e0..7de3ea7 100644 --- a/firmware/src/RTE/RTE.c +++ b/firmware/src/RTE/RTE.c @@ -604,6 +604,53 @@ uint8_t RTE_Get_ACT_LD_OUT_SNS(void) { return 0; } +//统计所有触发的通道数量 +uint8_t GetActiveChNum (uint16_t chdata[],uint16_t thdata[],uint8_t num) +{ + uint8_t i,count; + count = 0; + for (i = 0; i < num; i++) + { + if (chdata[i] > thdata[i]) + { + count++; + } + } + return count; +} + +//统计连续触发的通道数量 +uint8_t GetContinuousChNum(uint16_t chdata[],uint16_t thdata[],uint8_t num) +{ + uint8_t i,count,index; + count = 0; + index = 0; + for (i = 0; i < num; i++) + { + if (chdata[i] > thdata[i]) + { + //找到第一个触发的通道 + index = i; + break; + } + } + if (i == num) + { + //没有触发的通道 + return count; + } + + for (i = index; i < num; i++) + { + if (chdata[i] <= thdata[i]) + { + //找到第一个触发的通道之后第一个不触发的通道 + break; + } + } + count = i - index; + return count; +} uint8_t RTE_Get_TouchBoard_XY_Touch_And_Below_1N(void) // 0 false 1 true { @@ -643,6 +690,9 @@ uint8_t RTE_Get_TouchBoard_XY_Touch_And_Below_1N(void) // 0 false 1 true th_y[3] = qtlib_key_configs_set1[11].channel_threshold; th_y[4] = qtlib_key_configs_set1[12].channel_threshold; + + Two_Finger_Y_count = GetActiveChNum(Two_Finger_Y_data,th_y,5U); + /* Two_Finger_Y_count = 0; for (i = 0; i < 5; i++) { @@ -651,7 +701,9 @@ uint8_t RTE_Get_TouchBoard_XY_Touch_And_Below_1N(void) // 0 false 1 true Two_Finger_Y_count++; } } - + */ + Y_count = GetContinuousChNum(Two_Finger_Y_data,th_y,5U); + /* i = 0; Y_count = 0; while (Two_Finger_Y_data[i] <= th_y[i++] && i < 5) @@ -664,7 +716,11 @@ uint8_t RTE_Get_TouchBoard_XY_Touch_And_Below_1N(void) // 0 false 1 true else Y_count++; } + */ + Two_Finger_X_count = GetActiveChNum(Two_Finger_X_data,th_x,5U); + X_count = GetActiveChNum(Two_Finger_X_data,th_x,5U); + /* Two_Finger_X_count = 0; for (m = 0; m < 5; m++) { @@ -685,7 +741,7 @@ uint8_t RTE_Get_TouchBoard_XY_Touch_And_Below_1N(void) // 0 false 1 true else X_count++; } - + */ // 触发的通道数量 //连续触发的通道数量 if ((Two_Finger_Y_count > 4 && Two_Finger_X_data[0]>th_x[0]) || Y_count != Two_Finger_Y_count || Two_Finger_X_count > 4 || X_count != Two_Finger_X_count)