gimbal/User/device/remote_control.h
2026-01-03 02:30:09 +08:00

127 lines
3.7 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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.

/**
****************************(C) COPYRIGHT 2016 DJI****************************
* @file remote_control.c/h
* @brief ң¿؆÷´¦À񋂣¿؆÷ʇͨ¹ýÀˆSBUSµĐ­ҩ´«ʤ£¬ÀûӃDMA´«ʤ·½ʽ½ڔ¼CPU
* ׊Դ£¬ÀûӃ´®¿ڿՏЖжπ´À­ư´¦À򻺽£¬ͬʱ̡¹©һЩµ􏟖؆􄍁£¬´®¿ڍ
* µķ½ʽ±£֤Ȉ²導µĎȶ¨Д¡£
* @note
* @history
* Version Date Author Modification
* V1.0.0 Dec-26-2018 RM 1. ͪ³ɍ
*
@verbatim
==============================================================================
==============================================================================
@endverbatim
****************************(C) COPYRIGHT 2016 DJI****************************
*/
#ifndef REMOTE_CONTROL_H
#define REMOTE_CONTROL_H
#include "struct_typedef.h"
#include "bsp_rc.h"
#include <stdbool.h>
#define SBUS_RX_BUF_NUM 25u
#define RC_FRAME_LENGTH 18u
#define RC_CH_VALUE_MIN ((uint16_t)364)
#define RC_CH_VALUE_OFFSET ((uint16_t)1024)
#define RC_CH_VALUE_MAX ((uint16_t)1684)
/* ----------------------- RC Switch Definition----------------------------- */
#define RC_SW_UP ((uint16_t)1)
#define RC_SW_MID ((uint16_t)3)
#define RC_SW_DOWN ((uint16_t)2)
#define switch_is_down(s) (s == RC_SW_DOWN)
#define switch_is_mid(s) (s == RC_SW_MID)
#define switch_is_up(s) (s == RC_SW_UP)
/* ----------------------- PC Key Definition-------------------------------- */
#define KEY_PRESSED_OFFSET_W ((uint16_t)1 << 0)
#define KEY_PRESSED_OFFSET_S ((uint16_t)1 << 1)
#define KEY_PRESSED_OFFSET_A ((uint16_t)1 << 2)
#define KEY_PRESSED_OFFSET_D ((uint16_t)1 << 3)
#define KEY_PRESSED_OFFSET_SHIFT ((uint16_t)1 << 4)
#define KEY_PRESSED_OFFSET_CTRL ((uint16_t)1 << 5)
#define KEY_PRESSED_OFFSET_Q ((uint16_t)1 << 6)
#define KEY_PRESSED_OFFSET_E ((uint16_t)1 << 7)
#define KEY_PRESSED_OFFSET_R ((uint16_t)1 << 8)
#define KEY_PRESSED_OFFSET_F ((uint16_t)1 << 9)
#define KEY_PRESSED_OFFSET_G ((uint16_t)1 << 10)
#define KEY_PRESSED_OFFSET_Z ((uint16_t)1 << 11)
#define KEY_PRESSED_OFFSET_X ((uint16_t)1 << 12)
#define KEY_PRESSED_OFFSET_C ((uint16_t)1 << 13)
#define KEY_PRESSED_OFFSET_V ((uint16_t)1 << 14)
#define KEY_PRESSED_OFFSET_B ((uint16_t)1 << 15)
/* ----------------------- Data Struct ------------------------------------- */
#define OFF 1694
#define ON 306
#define MID 1000
#define MAX 306
#define MID 1000
#define MIN 1694
#define ADD 1694
#define MINUS 1694
typedef struct
{
int16_t ch[4];
int16_t sw[8];
} RC_ctrl_t;
typedef struct
{
bool online;
int8_t mode;
bool ai;
float ch_l_x; /* <20><>ҡ<EFBFBD><D2A1> X */
float ch_l_y; /* <20><>ҡ<EFBFBD><D2A1> Y<><59><EFBFBD><EFBFBD><EFBFBD>ţ<EFBFBD> */
float ch_r_x; /* <20><>ҡ<EFBFBD><D2A1> X */
float ch_r_y; /* <20><>ҡ<EFBFBD><D2A1> Y */
struct{
float x;
float y;
}chassis_ctrl_vec;
struct{
float w;
}gimbal_yaw_ctrl_vec;
struct{
float w;
}gimbal_pit_ctrl_vec;
struct{
bool ready;
bool firecmd;
}shoot;
} COMP_AT9S_CMD_t;
/* ----------------------- Internal Data ----------------------------------- */
/**
* @brief remote control init
* @param[in] none
* @retval none
*/
extern void remote_control_init(void);
/**
* @brief get remote control data point
* @param[in] none
* @retval remote control data point
*/
void USART3_IRQHandler1(void);
void DMA1_Stream1_IRQHandler1(void);
extern const RC_ctrl_t *get_remote_control_point(void);
#endif