R1_up/User/task/shootTask.cpp
2025-06-12 17:07:28 +08:00

64 lines
1.2 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "TopDefine.h"
#include "FreeRTOS.h"
#include "userTask.h"
#include <cmsis_os2.h>
#include "shootTask.hpp"
#include "shoot.hpp"
#include "remote_control.h"
#include "nuc.h"
extern RC_ctrl_t rc_ctrl;
Shoot shoot;
NUC_t nucData; // 自瞄
int shoot_flag = 0;
int a2;
int goangle=0;
//E键 sw[0]👆 200 中 1000 👇1800
//F键 sw[1]👆 1800 👇200
void FunctionShoot(void *argument)
{
(void)argument; /* 未使用argument消除警告 */
const uint32_t delay_tick = osKernelGetTickFreq() / TASK_FREQ_CTRL_SHOOT;
uint32_t tick = osKernelGetTickCount();
while(1)
{
#ifdef DEBUG
task_struct.stack_water_mark.shoot = osThreadGetStackSpace(osThreadGetId());
#endif
shoot.rc_mode(); //遥控器模式
//我放的任务通知 运球成功放置过来后
shoot.flag_thread=osThreadFlagsGet();
if(shoot.flag_thread & BALL_OK)
{
a2=2;
}
shoot_flag=HAL_GPIO_ReadPin(STOP_GPIO_Port, STOP_Pin);
if (osMessageQueueGet(task_struct.msgq.nuc, &nucData, NULL, 0) == osOK)
{
shoot.distanceGet(nucData);
}
//shoot.GO_SendData(goangle,5);
shoot.shoot_control();
// shoot.t_posSet=goangle;
// shoot.trigger_control();
tick += delay_tick; /* 计算下一个唤醒时刻 */
osDelayUntil(tick);
}
}