AP_JSButton.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #pragma once
  2. #include <AP_Param/AP_Param.h>
  3. class JSButton {
  4. public:
  5. JSButton();
  6. // Button functions
  7. typedef enum {
  8. k_none = 0, ///< disabled
  9. k_shift = 1, ///< "shift" buttons to allow more functions
  10. k_mode_clean = 2, ///< arm/disarm vehicle toggle
  11. k_arm = 3, ///< arm vehicle
  12. k_disarm = 4, ///< disarm vehicle
  13. k_mode_manual = 5, ///< enter enter manual mode
  14. k_mode_stabilize = 6, ///< enter stabilize mode
  15. k_mode_depth_hold = 7, ///< enter depth hold mode
  16. k_mode_poshold = 8, ///< enter poshold mode
  17. k_mode_auto = 9, ///< enter auto mode
  18. k_mode_circle = 10, ///< enter circle mode
  19. k_mode_guided = 11, ///< enter guided mode
  20. k_mode_acro = 12, ///< enter acro mode
  21. k_arm_toggle = 13, ///< enter clean mode
  22. k_gain_toggle = 14, ///< enter new mode
  23. // 12-20 reserved for future mode functions
  24. k_mount_center = 21, ///< move mount to center
  25. k_mount_tilt_up = 22, ///< tilt mount up
  26. k_mount_tilt_down = 23, ///< tilt mount down
  27. k_camera_trigger = 24, ///< trigger camera shutter
  28. k_camera_source_toggle = 25, ///< toggle camera source
  29. k_mount_pan_right = 26, ///< pan mount right
  30. k_mount_pan_left = 27, ///< pan mount left
  31. // 26-30 reserved for future camera functions
  32. k_lights1_cycle = 31, ///< lights 1 cycle
  33. k_lights1_brighter = 32, ///< lights 1 up
  34. k_lights1_dimmer = 33, ///< lights 1 down
  35. k_lights2_cycle = 34, ///< lights 2 cycle
  36. k_lights2_brighter = 35, ///< lights 2 up
  37. k_lights2_dimmer = 36, ///< lights 2 down
  38. // 37-40 reserved for future light functions
  39. k_mode_sport = 41, ///< toggle different gain settings
  40. k_gain_inc = 42, ///< increase control gain
  41. k_gain_dec = 43, ///< decrease control gain
  42. k_trim_roll_inc = 44, ///< increase roll trim
  43. k_trim_roll_dec = 45, ///< decrease roll trim
  44. k_trim_pitch_inc = 46, ///< increase pitch trim
  45. k_trim_pitch_dec = 47, ///< decrease pitch trim
  46. k_input_hold_set = 48, ///< toggle input hold (trim to current controls)
  47. k_roll_pitch_toggle = 49, ///< adjust roll/pitch input instead of forward/lateral
  48. // 50 reserved for future function
  49. k_relay_1_on = 51, ///< trigger relay on
  50. k_relay_1_off = 52, ///< trigger relay off
  51. k_relay_1_toggle = 53, ///< trigger relay toggle
  52. k_relay_2_on = 54, ///< trigger relay on
  53. k_relay_2_off = 55, ///< trigger relay off
  54. k_relay_2_toggle = 56, ///< trigger relay toggle
  55. k_relay_3_on = 57, ///< trigger relay on
  56. k_relay_3_off = 58, ///< trigger relay off
  57. k_relay_3_toggle = 59, ///< trigger relay toggle
  58. // 60 reserved for future function
  59. k_servo_1_inc = 61, ///< increase servo output
  60. k_servo_1_dec = 62, ///< decrease servo output
  61. k_servo_1_min = 63, ///< center servo
  62. k_servo_1_max = 64, ///< set servo output to minimum (SERVOn_MIN)
  63. k_servo_1_center = 65, ///< set servo output to maximum (SERVOn_MAX)
  64. k_servo_2_inc = 66,
  65. k_servo_2_dec = 67,
  66. k_servo_2_min = 68,
  67. k_servo_2_max = 69,
  68. k_servo_2_center = 70,
  69. k_servo_3_inc = 71,
  70. k_servo_3_dec = 72,
  71. k_servo_3_min = 73,
  72. k_servo_3_max = 74,
  73. k_servo_3_center = 75,
  74. k_servo_1_min_momentary = 76, ///< set servo output to minimum (SERVOn_MIN) until released
  75. k_servo_1_max_momentary = 77, ///< set servo output to minimum (SERVOn_MAX) until released
  76. k_servo_1_min_toggle = 78, ///< toggle servo output btwn trim (SERVOn_TRIM) and min (SERVOn_MIN)
  77. k_servo_1_max_toggle = 79, ///< toggle servo output btwn trim (SERVOn_TRIM) and max (SERVOn_MAX)
  78. k_servo_2_min_momentary = 80,
  79. k_servo_2_max_momentary = 81,
  80. k_servo_2_min_toggle = 82,
  81. k_servo_2_max_toggle = 83,
  82. k_servo_3_min_momentary = 84,
  83. k_servo_3_max_momentary = 85,
  84. k_servo_3_min_toggle = 86,
  85. k_servo_3_max_toggle = 87,
  86. // 88-90 reserved for future functions
  87. k_custom_1 = 91, ///< custom user button 1
  88. k_custom_2 = 92, ///< custom user button 2
  89. k_custom_3 = 93, ///< custom user button 3
  90. k_custom_4 = 94, ///< custom user button 4
  91. k_custom_5 = 95, ///< custom user button 5
  92. k_custom_6 = 96, ///< custom user button 6
  93. // 97-100 reserved for future functions
  94. k_relay_4_on = 101, ///< trigger relay on
  95. k_relay_4_off = 102, ///< trigger relay off
  96. k_relay_4_toggle = 103, ///< trigger relay toggle
  97. k_relay_1_momentary = 104, ///< relay toggle when button is pushed, and again when released
  98. k_relay_2_momentary = 105,
  99. k_relay_3_momentary = 106,
  100. k_relay_4_momentary = 107,
  101. // 108+ reserved for future functions
  102. k_nr_btn_functions ///< This must be the last enum value (only add new values _before_ this one)
  103. } button_function_t;
  104. // If shift is false, returns the function assigned to this button
  105. // If shift is true, returns the shift function assigned to this button
  106. uint8_t function(bool shift = false) const;
  107. // Sets the default function and shift function parameter values for this button
  108. void set_default(button_function_t f, button_function_t sf);
  109. static const struct AP_Param::GroupInfo var_info[];
  110. private:
  111. // Button mappings
  112. AP_Int8 _function;
  113. AP_Int8 _sfunction;
  114. };