refactor(protocol): CoP 帧字段从 float 改为整型,单位 mm→cm / kg
cop_x/cop_y 改为 int16_t (cm),force 改为 uint16_t (kg), 帧长 17→11 字节,降低带宽占用;1 cm 精度满足平衡板场景需求。
This commit is contained in:
+10
-10
@@ -42,19 +42,19 @@
|
||||
/* 总重低于此值时 CoP 无意义(除零保护),单位 kg */
|
||||
#define COP_MIN_FORCE_THRESHOLD 0.5f
|
||||
|
||||
/* ─── 上行: CoP 帧 (17 bytes, 50 Hz) ───
|
||||
/* ─── 上行: CoP 帧 (11 bytes, 50 Hz) ───
|
||||
*
|
||||
* [AA 55 01 flags cop_x(4) cop_y(4) force(4) crc]
|
||||
* [AA 55 01 flags cop_x(2) cop_y(2) force(2) crc]
|
||||
*/
|
||||
struct cop_frame_t {
|
||||
uint8_t sync0; /* = PROTO_SYNC0 */
|
||||
uint8_t sync1; /* = PROTO_SYNC1 */
|
||||
uint8_t type; /* = PROTO_TYPE_COP */
|
||||
uint8_t flags; /* bit0: force_valid */
|
||||
float cop_x; /* 压力中心 X (mm),板面坐标系 */
|
||||
float cop_y; /* 压力中心 Y (mm),板面坐标系 */
|
||||
float force; /* 总重量 (kg) */
|
||||
uint8_t crc; /* CRC-8/MAXIM, 校验 type~force */
|
||||
uint8_t sync0; /* = PROTO_SYNC0 */
|
||||
uint8_t sync1; /* = PROTO_SYNC1 */
|
||||
uint8_t type; /* = PROTO_TYPE_COP */
|
||||
uint8_t flags; /* bit0: force_valid */
|
||||
int16_t cop_x; /* 压力中心 X (cm),板面坐标系 */
|
||||
int16_t cop_y; /* 压力中心 Y (cm),板面坐标系 */
|
||||
uint16_t force; /* 总重量 (kg) */
|
||||
uint8_t crc; /* CRC-8/MAXIM, 校验 type~force */
|
||||
} __attribute__((packed));
|
||||
|
||||
union cop_pkt_t {
|
||||
|
||||
Reference in New Issue
Block a user