diff --git a/RBcore/client_setting.c b/RBcore/client_setting.c index 8777d33..82c3f4f 100644 --- a/RBcore/client_setting.c +++ b/RBcore/client_setting.c @@ -126,7 +126,6 @@ static void SendIV_ModuleHandler(const Msg_t *pstMsg) g_IV_buffer[IV_o_stream.bytes_written + 3] = crc & 0xff;; rd_ComSend(g_ptlpuart, g_IV_buffer, IV_o_stream.bytes_written + 4); - Rd_Delay(1000); } break; } diff --git a/project/paint_robot_new/paint_robot_new.c b/project/paint_robot_new/paint_robot_new.c index b626e1d..aecf95a 100644 --- a/project/paint_robot_new/paint_robot_new.c +++ b/project/paint_robot_new/paint_robot_new.c @@ -57,6 +57,8 @@ static IV_struct_define g_stIV; * 宏定义 * *----------------------------------------------*/ +#define IV_SEND_TIME 500 // IV上报周期(单位毫秒) + static void Custom_ModuleHandler(const Msg_t *pstMsg) { if (NULL == pstMsg) @@ -89,6 +91,15 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) RD_MEMCPY(&g_stMK32, pstMsg->m_aucData, sizeof(g_stMK32)); } + int iSpeedSelection = 3 * (g_stMK32.CH11_RD1 + 1000) / 200; + int iVehicleSpeed = 1; + if (iSpeedSelection > 0) + { + iVehicleSpeed = g_stCV.Speed_m_per_min*iSpeedSelection/30; + } + g_stIV.RobotMoveSpeed = iVehicleSpeed; + MsgCenter_SendTo(MODULE_NAME_RBCORE, RBCORE_GET_VEHICLE_SPEED, (void *)&iVehicleSpeed, 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, RBCORE_CMD_STOP_ALL, NULL, 0); @@ -151,10 +162,17 @@ static void Custom_ModuleHandler(const Msg_t *pstMsg) void Custom_Task(void *argument) { g_uiCustomModuleID = MsgCenter_Register(MODULE_NAME_CUSTOM, Custom_ModuleHandler); + uint32_t uiLastSendTick = Rd_GetTime(); while(1) { MsgCenter_ProcessWait(g_uiCustomModuleID, 2); - MsgCenter_SendTo(MODULE_NAME_SENDIV, CUSTOM_SET_IV, (void *)&g_stIV, sizeof(g_stIV)); + + uint32_t uiNowTick = Rd_GetTime(); + if ((int32_t)(uiNowTick - uiLastSendTick) >= IV_SEND_TIME) + { + uiLastSendTick = uiNowTick; + MsgCenter_SendTo(MODULE_NAME_SENDIV, CUSTOM_SET_IV, (void *)&g_stIV, sizeof(g_stIV)); + } } }