Browse Source

paint_robot_new v1.0【调通打标】调整MK32数组使用probuf中定义的

master
Lizongdi 11 hours ago
parent
commit
a334c2c8a2
  1. 22
      project/paint_robot_new/include/paint_robot_new.h
  2. 13
      project/paint_robot_new/paint_robot_new.c

22
project/paint_robot_new/include/paint_robot_new.h

@ -66,27 +66,7 @@ extern "C"{
/*==============================================* /*==============================================*
* constants or macros define * * constants or macros define *
*----------------------------------------------*/ *----------------------------------------------*/
typedef struct _MSP_MK32_Button
{
int32_t CH0_RY_H;
int32_t CH1_RY_V;
int32_t CH2_LY_V;
int32_t CH3_LY_H;
int32_t CH4_SA;
int32_t CH5_SB;
int32_t CH6_SC;
int32_t CH7_SD;
int32_t CH8_SE;
int32_t CH9_SF;
int32_t CH10_LD1;
int32_t CH11_RD1;
int32_t CH12_S1;
int32_t CH13_S2;
int32_t CH14_LT;
int32_t CH15_RT;
int32_t IsOnline;
int32_t RxIndex;
} MSP_MK32_Button;
/*==============================================* /*==============================================*
* project-wide global variables * * project-wide global variables *

13
project/paint_robot_new/paint_robot_new.c

@ -16,11 +16,12 @@
: :
******************************************************************************/ ******************************************************************************/
#include "paint_robot_new.h"
#include "BHBF.h" #include "BHBF.h"
#include "pb.h" #include "pb.h"
#include "pb_decode.h" #include "pb_decode.h"
#include "../Protobuf/PSource/bsp_PV.pb.h" #include "../Protobuf/PSource/bsp_PV.pb.h"
#include "../Protobuf/PSource/msp_MK32.pb.h"
#include <stdint.h>
/*----------------------------------------------* /*----------------------------------------------*
* * * *
@ -33,13 +34,13 @@
/*----------------------------------------------* /*----------------------------------------------*
* * * *
*----------------------------------------------*/ *----------------------------------------------*/
static MSP_MK32_Button RB_MK32; static SP_MSP_MK32_Button RB_MK32;
static PV_struct_define decoded_PV_variable = { 0 };
static PV_struct_define decoded_PV = { 0 };
/*----------------------------------------------* /*----------------------------------------------*
* * * *
*----------------------------------------------*/ *----------------------------------------------*/
PV_struct_define decoded_PV_variable = { 0 };
PV_struct_define decoded_PV = { 0 };
/*----------------------------------------------* /*----------------------------------------------*
* * * *
@ -90,13 +91,11 @@ void decode_MK32(const char *buf, uint32_t _iSize)
// 按键数值转换:1050为中间值,272-1712 // 按键数值转换:1050为中间值,272-1712
for (int i = 0; i < 16; i++) for (int i = 0; i < 16; i++)
{ {
// 通过指针解引用赋值,完美替代原来的 RB_MK32[i + 1]
CH[i] = (int32_t)((CH[i] - 992) * 1.388889); CH[i] = (int32_t)((CH[i] - 992) * 1.388889);
} }
RD_MEMCPY(&RB_MK32, CH, sizeof(CH)); RD_MEMCPY(&(RB_MK32.CH0_RY_H), CH, sizeof(CH));
// buf[23] 才是在线标志字节,对应老工程 Sbus_Data_Count(&buffer[1]) 中的 buf[22]==buffer[23]
if (buf[23] == 0) if (buf[23] == 0)
{ {
RB_MK32.IsOnline = 1; RB_MK32.IsOnline = 1;

Loading…
Cancel
Save