下半区传感器接线方式修改,屏幕安装点过低或过高,按压上半区或下半区屏幕会造成误触发,未能得到解决
This commit is contained in:
@@ -4,6 +4,50 @@
|
||||
#include "Algorithm.h"
|
||||
#include "Debug.h"
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h> // 用于 abs() 函数
|
||||
|
||||
/**
|
||||
* @brief 比较两个数组对应位置的绝对值差值,统计满足条件的个数
|
||||
*
|
||||
* 判断条件:|arr1[i] - zero1| + offset > |arr2[i] - zero2|
|
||||
*
|
||||
* @param arr1 数组1指针
|
||||
* @param arr2 数组2指针
|
||||
* @param length 要比较的数组长度(截取值)
|
||||
* @param zero1 数组1的零点值
|
||||
* @param zero2 数组2的零点值
|
||||
* @param offset 补偿值
|
||||
* @return int 满足条件的个数
|
||||
*
|
||||
* @note 如果 length 为0,返回0
|
||||
* @note 如果 arr1 或 arr2 为 NULL,返回0
|
||||
*/
|
||||
int CompareAndCountAbs(const int32_t *arr1, const int32_t *arr2, uint16_t length,
|
||||
int32_t zero1, int32_t zero2, int32_t offset)
|
||||
{
|
||||
// 参数校验
|
||||
if (arr1 == NULL || arr2 == NULL || length == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
|
||||
for (uint16_t i = 0; i < length; i++) {
|
||||
// 计算绝对值
|
||||
int32_t abs1 = abs(arr1[i] - zero1);
|
||||
int32_t abs2 = abs(arr2[i] - zero2);
|
||||
|
||||
// 判断:|arr1[i] - zero1| + offset > |arr2[i] - zero2|
|
||||
if (abs1 + offset > abs2) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
/**
|
||||
* 加强特定区域的平滑处理(使用更小的权重衰减,更平滑的效果)
|
||||
*
|
||||
|
||||
@@ -517,13 +517,43 @@ static void GPIO_Config(void)
|
||||
PORT_Init(LEFTLOW_CS1237_SCLK_PORTx, LEFTLOW_CS1237_SCLK_PINx, &stcPortInit);
|
||||
PORT_Init(RIGHTUP_CS1237_SCLK_PORTx, RIGHTUP_CS1237_SCLK_PINx, &stcPortInit);
|
||||
PORT_Init(RIGHTLOW_CS1237_SCLK_PORTx, RIGHTLOW_CS1237_SCLK_PINx, &stcPortInit);
|
||||
PORT_Init(BUZZER_PORTx, BUZZER_PINx, &stcPortInit);
|
||||
PORT_Init(LED_GREEN_PORTx, LED_GREEN_PINx, &stcPortInit);
|
||||
PORT_Init(LED_RED_PORTx, LED_RED_PINx, &stcPortInit);
|
||||
LED_GREEN_OFF();
|
||||
LED_RED_OFF();
|
||||
|
||||
stcPortInit.enPullUp = Enable;//上拉
|
||||
}
|
||||
void Bit0AndBit1_OUT(void)
|
||||
{
|
||||
stc_port_init_t stcPortInit;
|
||||
MEM_ZERO_STRUCT(stcPortInit);
|
||||
|
||||
/********************************** GPIO输出 ****************************************/
|
||||
stcPortInit.enPinMode = Pin_Mode_Out;
|
||||
stcPortInit.enPinOType = Pin_OType_Cmos;
|
||||
stcPortInit.enPinDrv = Pin_Drv_H;
|
||||
stcPortInit.enPullUp = Disable;//无上拉
|
||||
|
||||
stcPortInit.enPullUp = Enable;//上拉
|
||||
PORT_Init(TWIN_BIT0_PORTx, TWIN_BIT0_PINx, &stcPortInit);
|
||||
PORT_Init(TWIN_BIT1_PORTx, TWIN_BIT1_PINx, &stcPortInit);
|
||||
SET_TWIN_BIT0();
|
||||
SET_TWIN_BIT1();
|
||||
}
|
||||
void Bit0AndBit1_IN(void)
|
||||
{
|
||||
stc_port_init_t stcPortInit;
|
||||
MEM_ZERO_STRUCT(stcPortInit);
|
||||
|
||||
/********************************** GPIO输入 ****************************************/
|
||||
stcPortInit.enPinMode = Pin_Mode_In;
|
||||
stcPortInit.enPullUp = Disable;//无上拉
|
||||
|
||||
PORT_Init(TWIN_BIT0_PORTx, TWIN_BIT0_PINx, &stcPortInit);
|
||||
PORT_Init(TWIN_BIT1_PORTx, TWIN_BIT1_PINx, &stcPortInit);
|
||||
}
|
||||
/*********************************左上传感器
|
||||
*******************************************************************************
|
||||
** \brief ExtInt00 callback function
|
||||
@@ -1429,6 +1459,7 @@ void BSP_Init(void)
|
||||
ExtiCh01_Init();
|
||||
ExtiCh06_Init();
|
||||
ExtiCh04_Init();
|
||||
Bit0AndBit1_OUT();
|
||||
|
||||
DbgUart_Config(700000);
|
||||
#if(USE_USART3 == 1)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user