Quadcopter/User/device/ps2.h
2025-10-03 14:32:06 +08:00

32 lines
1010 B
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.

#ifndef PS2_PS2_H_
#define PS2_PS2_H_
#include "main.h"
/*
需要4个GPIO
3个推挽输出模式 CLK DO CS
1个上拉输入模式 DI
*/
typedef struct
{
uint8_t A_D; //模拟(红灯)为1 数字(无灯)为0
float Rocker_RX, Rocker_RY, Rocker_LX, Rocker_LY; //摇杆值(模拟状态为实际值0-0xFF)(数字态为等效的值0,0x80,0xFF)
//按键值0为未触发,1为触发态
_Bool Key_L1, Key_L2, Key_R1, Key_R2; //后侧大按键
_Bool Key_L_Right, Key_L_Left, Key_L_Up, Key_L_Down; //左侧按键
_Bool Key_R_Right, Key_R_Left, Key_R_Up, Key_R_Down; //右侧按键
_Bool Key_Select; //选择键
_Bool Key_Start; //开始键
_Bool Key_Rocker_Left, Key_Rocker_Right; //摇杆按键
} PS2_TypeDef;
extern PS2_TypeDef PS2_Data;
void PS2_Read_Data(void);
float StickToThrottle_Optimized(float stick_value);
void UpdateMotorSpeeds(int8_t Rocker_LX, int8_t Rocker_LY, float *motor_speeds);
#endif /* PS2_PS2_H_ */