Sub: Add JSButton parameters to necessary places

This commit is contained in:
Rustom Jehangir 2016-03-12 07:15:18 -08:00 committed by Andrew Tridgell
parent 9d3bf13cff
commit 44904760cc
4 changed files with 110 additions and 1 deletions

View File

@ -576,6 +576,70 @@ const AP_Param::Info Sub::var_info[] = {
GGROUP(rc_14, "RC14_", RC_Channel_aux), GGROUP(rc_14, "RC14_", RC_Channel_aux),
#endif #endif
// @Group: BTN0_
// @Path: ../libraries/AP_JSButton/AP_JSButton.cpp
GGROUP(jbtn_0, "BTN0_", JSButton),
// @Group: BTN1_
// @Path: ../libraries/AP_JSButton/AP_JSButton.cpp
GGROUP(jbtn_1, "BTN1_", JSButton),
// @Group: BTN2_
// @Path: ../libraries/AP_JSButton/AP_JSButton.cpp
GGROUP(jbtn_2, "BTN2_", JSButton),
// @Group: BTN3_
// @Path: ../libraries/AP_JSButton/AP_JSButton.cpp
GGROUP(jbtn_3, "BTN3_", JSButton),
// @Group: BTN4_
// @Path: ../libraries/AP_JSButton/AP_JSButton.cpp
GGROUP(jbtn_4, "BTN4_", JSButton),
// @Group: BTN5_
// @Path: ../libraries/AP_JSButton/AP_JSButton.cpp
GGROUP(jbtn_5, "BTN5_", JSButton),
// @Group: BTN6_
// @Path: ../libraries/AP_JSButton/AP_JSButton.cpp
GGROUP(jbtn_6, "BTN6_", JSButton),
// @Group: BTN7_
// @Path: ../libraries/AP_JSButton/AP_JSButton.cpp
GGROUP(jbtn_7, "BTN7_", JSButton),
// @Group: BTN8_
// @Path: ../libraries/AP_JSButton/AP_JSButton.cpp
GGROUP(jbtn_8, "BTN8_", JSButton),
// @Group: BTN9_
// @Path: ../libraries/AP_JSButton/AP_JSButton.cpp
GGROUP(jbtn_9, "BTN9_", JSButton),
// @Group: BTN10_
// @Path: ../libraries/AP_JSButton/AP_JSButton.cpp
GGROUP(jbtn_10, "BTN10_", JSButton),
// @Group: BTN11_
// @Path: ../libraries/AP_JSButton/AP_JSButton.cpp
GGROUP(jbtn_11, "BTN11_", JSButton),
// @Group: BTN12_
// @Path: ../libraries/AP_JSButton/AP_JSButton.cpp
GGROUP(jbtn_12, "BTN12_", JSButton),
// @Group: BTN13_
// @Path: ../libraries/AP_JSButton/AP_JSButton.cpp
GGROUP(jbtn_13, "BTN13_", JSButton),
// @Group: BTN14_
// @Path: ../libraries/AP_JSButton/AP_JSButton.cpp
GGROUP(jbtn_14, "BTN14_", JSButton),
// @Group: BTN15_
// @Path: ../libraries/AP_JSButton/AP_JSButton.cpp
GGROUP(jbtn_15, "BTN15_", JSButton),
// @Param: RC_SPEED // @Param: RC_SPEED
// @DisplayName: ESC Update Speed // @DisplayName: ESC Update Speed
// @Description: This is the speed in Hertz that your ESCs will receive updates // @Description: This is the speed in Hertz that your ESCs will receive updates

View File

@ -363,6 +363,24 @@ public:
//Sub-specific parameters //Sub-specific parameters
k_param_surface_depth = 256, k_param_surface_depth = 256,
// Joystick button mapping parameters
k_param_jbtn_0 = 261,
k_param_jbtn_1,
k_param_jbtn_2,
k_param_jbtn_3,
k_param_jbtn_4,
k_param_jbtn_5,
k_param_jbtn_6,
k_param_jbtn_7,
k_param_jbtn_8,
k_param_jbtn_9,
k_param_jbtn_10,
k_param_jbtn_11,
k_param_jbtn_12,
k_param_jbtn_13,
k_param_jbtn_14,
k_param_jbtn_15, // 276
}; };
AP_Int16 format_version; AP_Int16 format_version;
@ -486,6 +504,24 @@ public:
AP_Int16 rc_speed; // speed of fast RC Channels in Hz AP_Int16 rc_speed; // speed of fast RC Channels in Hz
// Joystick button parameters
JSButton jbtn_0;
JSButton jbtn_1;
JSButton jbtn_2;
JSButton jbtn_3;
JSButton jbtn_4;
JSButton jbtn_5;
JSButton jbtn_6;
JSButton jbtn_7;
JSButton jbtn_8;
JSButton jbtn_9;
JSButton jbtn_10;
JSButton jbtn_11;
JSButton jbtn_12;
JSButton jbtn_13;
JSButton jbtn_14;
JSButton jbtn_15;
// Acro parameters // Acro parameters
AP_Float acro_rp_p; AP_Float acro_rp_p;
AP_Float acro_yaw_p; AP_Float acro_yaw_p;

View File

@ -89,6 +89,7 @@
#include <AP_Terrain/AP_Terrain.h> #include <AP_Terrain/AP_Terrain.h>
#include <AP_RPM/AP_RPM.h> #include <AP_RPM/AP_RPM.h>
#include <AC_InputManager/AC_InputManager.h> // Pilot input handling library #include <AC_InputManager/AC_InputManager.h> // Pilot input handling library
#include <AP_JSButton/AP_JSButton.h> // Joystick/gamepad button function assignment
// Configuration // Configuration
#include "defines.h" #include "defines.h"

View File

@ -24,6 +24,12 @@ void Sub::transform_manual_control_to_rc_override(int16_t x, int16_t y, int16_t
if ( tnow_ms - buttonDebounce > 50 ) { if ( tnow_ms - buttonDebounce > 50 ) {
buttonDebounce = tnow_ms; buttonDebounce = tnow_ms;
for ( uint8_t i = 0 ; i < 16 ; i++ ) {
if ( buttons & (1 << i) ) {
// handle_jsbutton_press(i);
}
}
// Button logic to arm/disarm motors (Start and back buttons) // Button logic to arm/disarm motors (Start and back buttons)
if ( buttons & (1 << 4) ) { if ( buttons & (1 << 4) ) {
init_arm_motors(true); init_arm_motors(true);
@ -75,4 +81,6 @@ void Sub::transform_manual_control_to_rc_override(int16_t x, int16_t y, int16_t
// record that rc are overwritten so we can trigger a failsafe if we lose contact with groundstation // record that rc are overwritten so we can trigger a failsafe if we lose contact with groundstation
failsafe.rc_override_active = hal.rcin->set_overrides(channels, 10); failsafe.rc_override_active = hal.rcin->set_overrides(channels, 10);
} }
//void Sub::handle_jsbutton_press(uint8_t button);