下半区传感器接线方式修改,屏幕安装点过低或过高,按压上半区或下半区屏幕会造成误触发,未能得到解决

This commit is contained in:
2026-07-09 18:52:49 +08:00
parent 7f68ef4677
commit 59d5c62b12
11 changed files with 910 additions and 353 deletions
@@ -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;
}
/**
* 加强特定区域的平滑处理(使用更小的权重衰减,更平滑的效果)
*