#ifndef SHOOT_HPP
#define SHOOT_HPP
#include "djiMotor.h"
#include "pid.h"

// 定义状态枚举
typedef enum {
    SHOOT_IDLE,        // 空闲状态
    SHOOT_FIRE,        // 发射状态
    SHOOT_BACK,   // 光电触发状态
    SHOOT_RETURN       // 自动返回状态
} ShootState_t;

// 定义状态枚举
typedef enum {
    BALL_IDLE,         // 空闲状态
    BALL_FINISH,        // 完成状态
//持球状态
    BALL_TAKE,
    BALL_LOSE

} BallState_t;

// 光电传感器读取宏
#define IS_PHOTOELECTRIC_TRIGGERED() (HAL_GPIO_ReadPin(STOP_GPIO_Port, STOP_Pin) == GPIO_PIN_RESET)

class Shoot
{
public:
    Shoot();
    void shootThree(void);
    void shootStop(void);
    void shootBack(void);
    void shootStateMachine(void);
    void trigger_control(void);
    float speed_5065;
    float speed_trigger;
    ShootState_t currentState;

    int16_t result;
    //暂时放在公共,task里使用
     CAN_MotorFeedback_t *motor_5065[2];
    //==========================公共变量==========================
    volatile BallState_t ballStatus;//是否有球
    volatile uint32_t flag_thread;//接收传回的线程通知

    //距离
    float distance;

private:

    //扳机2006
    static const float M2006_speed_PID[3];
    //电机速度pid结构体
    pid_type_def speed_pid;
    motor_measure_t *trigger_Motor;
    float speedSet;


};


float distanceToSpeed(float x);

#endif
