From a66f787aa054e09f82fcea8f1b184e8414ea6f54 Mon Sep 17 00:00:00 2001 From: Lizongdi <1210855344@qq.com> Date: Wed, 19 Aug 2026 11:15:23 +0800 Subject: [PATCH] =?UTF-8?q?paint=5Frobot=5Fnew=20v1.0=E3=80=90MK32?= =?UTF-8?q?=E4=B8=B2=E5=8F=A3=E6=8E=A5=E6=94=B6=E8=B0=83=E9=80=9A=E3=80=91?= =?UTF-8?q?=E7=A8=8D=E5=BE=AE=E4=BC=98=E5=8C=96=E4=B8=80=E4=B8=8BMK32?= =?UTF-8?q?=E8=A7=A3=E7=A0=81=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- project/paint_robot_new/include/paint_robot_new.h | 2 +- project/paint_robot_new/paint_robot_new.c | 14 ++++---------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/project/paint_robot_new/include/paint_robot_new.h b/project/paint_robot_new/include/paint_robot_new.h index f22fd92..ece89d5 100644 --- a/project/paint_robot_new/include/paint_robot_new.h +++ b/project/paint_robot_new/include/paint_robot_new.h @@ -68,7 +68,6 @@ extern "C"{ *----------------------------------------------*/ typedef struct _MSP_MK32_Button { - int32_t RxIndex; int32_t CH0_RY_H; int32_t CH1_RY_V; int32_t CH2_LY_V; @@ -86,6 +85,7 @@ typedef struct _MSP_MK32_Button int32_t CH14_LT; int32_t CH15_RT; int32_t IsOnline; + int32_t RxIndex; } MSP_MK32_Button; /*==============================================* diff --git a/project/paint_robot_new/paint_robot_new.c b/project/paint_robot_new/paint_robot_new.c index e3c0f13..12e43a5 100644 --- a/project/paint_robot_new/paint_robot_new.c +++ b/project/paint_robot_new/paint_robot_new.c @@ -58,7 +58,7 @@ int check_MK32(char *_pBuffer, uint32_t _iSize) void decode_MK32(const char *buf, uint32_t _iSize) { - int16_t CH[16]; + int32_t CH[16]; int Start_byte = 0; CH[0] = ((buf[Start_byte + 1] | buf[Start_byte + 2] << 8) & 0x07FF); @@ -82,21 +82,15 @@ void decode_MK32(const char *buf, uint32_t _iSize) CH[14] = ((buf[Start_byte + 20] >> 2 | buf[Start_byte + 21] << 6) & 0x07FF); CH[15] = ((buf[Start_byte + 21] >> 5 | buf[Start_byte + 22] << 3) & 0x07FF); - int32_t* channel_ptrs[16] = - { - &RB_MK32.CH0_RY_H, &RB_MK32.CH1_RY_V, &RB_MK32.CH2_LY_V, &RB_MK32.CH3_LY_H, - &RB_MK32.CH4_SA, &RB_MK32.CH5_SB, &RB_MK32.CH6_SC, &RB_MK32.CH7_SD, - &RB_MK32.CH8_SE, &RB_MK32.CH9_SF, &RB_MK32.CH10_LD1, &RB_MK32.CH11_RD1, - &RB_MK32.CH12_S1, &RB_MK32.CH13_S2, &RB_MK32.CH14_LT, &RB_MK32.CH15_RT - }; - // 按键数值转换:1050为中间值,272-1712 for (int i = 0; i < 16; i++) { // 通过指针解引用赋值,完美替代原来的 RB_MK32[i + 1] - *channel_ptrs[i] = (int32_t)((CH[i] - 992) * 1.388889); + CH[i] = (int32_t)((CH[i] - 992) * 1.388889); } + RD_MEMCPY(&RB_MK32, CH, sizeof(CH)); + // buf[23] 才是在线标志字节,对应老工程 Sbus_Data_Count(&buffer[1]) 中的 buf[22]==buffer[23] if (buf[23] == 0) {