soft_rc_input.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #ifndef __SOFT_RC_INPUT_H
  2. #define __SOFT_RC_INPUT_H
  3. #include "common.h"
  4. #include "stdbool.h"
  5. // S.BUS的通道数
  6. #define SBUS_CH 18
  7. // const unsigned char CH1=0,CH2=1,CH3=2,CH4=3,CH5=4,CH6=5,CH7=6;
  8. #define RC_INPUT_CH_NUM 16
  9. #define RC_CH1 0
  10. #define RC_CH2 1
  11. #define RC_CH3 2
  12. #define RC_CH4 3
  13. #define RC_CH5 4
  14. #define RC_CH6 5
  15. #define RC_CH7 6
  16. #define RC_CH8 7
  17. #define RC_CH9 8
  18. #define RC_CH10 9
  19. #define RC_CH11 10
  20. #define RC_CH12 11
  21. #define RC_CH13 12
  22. #define RC_CH14 13
  23. #define RC_CH15 14
  24. #define RC_CH16 15
  25. #define RC_ROLL RC_CH1
  26. #define RC_PITCH RC_CH2
  27. #define RC_THR RC_CH3
  28. #define RC_YAW RC_CH4
  29. typedef enum
  30. {
  31. // 信号正常
  32. RC_SIGNAL_HEALTH = 0,
  33. RC_SIGNAL_FAIL = 1,
  34. // 信号超允许范围
  35. RC_SIGNAL_BAD = 2
  36. } RcSignalHealthType;
  37. extern RcSignalHealthType rc_signal_health;
  38. // 遥控器是否有效
  39. extern comp_status comp_rc_status;
  40. //===================失控保护的油门量========================
  41. #define RC_FS_MIN 800
  42. #define RC_FS_MAX 980
  43. #define RC_IN_MIN 980
  44. #define RC_IN_MAX 2020
  45. #define RC_DEAD_ZONE 50
  46. #define ROCK_DEAD_ZONE 100
  47. #define MIN_S 1000
  48. #define MIN_E 1333
  49. #define MID_S 1334
  50. #define MID_E 1666
  51. #define MAX_S 1667
  52. #define MAX_E 2000
  53. typedef enum
  54. {
  55. RC_CALIB_NO = 0,
  56. RC_CALIB_START = 1,
  57. RC_CALIB_END = 2
  58. } RCCalibStatusType;
  59. extern RCCalibStatusType rc_cal_flag;
  60. //需要校准的通道
  61. #define RC_CALIB_CH_NUM 4
  62. extern short rc_in[RC_INPUT_CH_NUM];
  63. extern short raw_rc_in[RC_INPUT_CH_NUM];
  64. extern short tmp_rc_in[RC_INPUT_CH_NUM];
  65. extern short rc_cal_offset[RC_CALIB_CH_NUM];
  66. extern short rc_cal_factor_up[RC_CALIB_CH_NUM];
  67. extern short rc_cal_factor_down[RC_CALIB_CH_NUM];
  68. extern bool rc_offset_capture_flag;
  69. void rc_input_initial(void);
  70. void get_rc_value(void);
  71. void check_sbus_link_status(float dt_s);
  72. extern unsigned int rc_cal_time;
  73. void rc_input_calib_start(void);
  74. void rc_input_calib_end(void);
  75. void rc_input_calibration(void);
  76. void calc_rcfactor_calibration(void);
  77. #define KEY_UP 1
  78. #define KEY_DOWN 0
  79. extern short rock_in[4];
  80. extern char rock_key;
  81. #endif