diff --git a/RBcore/include/BHBF.h b/RBcore/include/BHBF.h index 205e79a..c97ad1a 100644 --- a/RBcore/include/BHBF.h +++ b/RBcore/include/BHBF.h @@ -95,6 +95,7 @@ typedef enum { CUSTOM_GET_PV, // 获取PV CUSTOM_SET_IV, // 设置IV CUSTOM_GET_MK32, // 获取MK32 + CUSTOM_CMD_PAINTGUN, // 控制喷枪 CUSTOM_CMD_END = 0x0300, } Motor_Cmd_e; diff --git a/project/paint_robot_new/paint_robot_new.c b/project/paint_robot_new/paint_robot_new.c index 4a95813..7bd4188 100644 --- a/project/paint_robot_new/paint_robot_new.c +++ b/project/paint_robot_new/paint_robot_new.c @@ -75,6 +75,16 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) } break; } + case CUSTOM_CMD_PAINTGUN: + { + int paintstate = -1; + if (pstMsg->m_uiDataLen >= sizeof(paintstate)) + { + RD_MEMCPY(&paintstate, pstMsg->m_aucData, sizeof(paintstate)); + HAL_GPIO_WritePin(OUT_1_GPIO_Port, OUT_1_Pin, paintstate); + } + break; + } case CUSTOM_GET_MK32: { if (pstMsg->m_uiDataLen >= sizeof(g_stMK32)) @@ -91,6 +101,17 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) g_stIV.RobotMoveSpeed = iVehicleSpeed; MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_GET_VEHICLE_SPEED, (void *)&iVehicleSpeed, sizeof(int)); + if (g_stMK32.CH6_SC == -1000) + { + int paintstate = 0; + MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_CMD_PAINTGUN, &paintstate, sizeof(int)); + } + else + { + int paintstate = 1; + MsgCenter_SendTo(MODULE_NAME_CUSTOM, CUSTOM_CMD_PAINTGUN, &paintstate, sizeof(int)); + } + if (abs(g_stMK32.CH2_LY_V) <= g_stCV.Joy_Sticker_Value_Allowance && abs(g_stMK32.CH3_LY_H) <= g_stCV.Joy_Sticker_Value_Allowance) { MsgCenter_SendTo(MODULE_NAME_RBCORE, CMD_STOP_ALL, NULL, 0);