Browse Source

AP_BoardConfig: added BRD_SAFETYOPTION parameter

allow control of safety button behaviour
mission-4.1.18
Andrew Tridgell 7 years ago
parent
commit
d8abf647e8
  1. 15
      libraries/AP_BoardConfig/AP_BoardConfig.cpp
  2. 17
      libraries/AP_BoardConfig/AP_BoardConfig.h

15
libraries/AP_BoardConfig/AP_BoardConfig.cpp

@ -82,6 +82,12 @@ @@ -82,6 +82,12 @@
#define HAL_IMU_TEMP_DEFAULT -1 // disabled
#endif
#if AP_FEATURE_SAFETY_BUTTON
#ifndef BOARD_SAFETY_OPTION_DEFAULT
#define BOARD_SAFETY_OPTION_DEFAULT (BOARD_SAFETY_OPTION_BUTTON_ACTIVE_SAFETY_OFF|BOARD_SAFETY_OPTION_BUTTON_ACTIVE_SAFETY_ON)
#endif
#endif
extern const AP_HAL::HAL& hal;
AP_BoardConfig *AP_BoardConfig::instance;
@ -196,6 +202,15 @@ const AP_Param::GroupInfo AP_BoardConfig::var_info[] = { @@ -196,6 +202,15 @@ const AP_Param::GroupInfo AP_BoardConfig::var_info[] = {
// @Path: ../libraries/AP_Param_Helper/AP_Param_Helper.cpp
AP_SUBGROUPINFO(param_helper, "", 12, AP_BoardConfig, AP_Param_Helper),
#endif
#if AP_FEATURE_SAFETY_BUTTON
// @Param: SAFETYOPTION
// @DisplayName: Options for safety button behavior
// @Description: This controls the activation of the safety button. It allows you to control if the safety button can be used for safety enable and/or disable, and whether the button is only active when disarmed
// @Bitmask: 0:ActiveForSafetyEnable,1:ActiveForSafetyDisable,2:ActiveWhenDisarmed
// @User: Standard
AP_GROUPINFO("SAFETYOPTION", 13, AP_BoardConfig, state.safety_option, BOARD_SAFETY_OPTION_DEFAULT),
#endif
AP_GROUPEND
};

17
libraries/AP_BoardConfig/AP_BoardConfig.h

@ -46,7 +46,7 @@ public: @@ -46,7 +46,7 @@ public:
AP_BoardConfig &operator=(const AP_BoardConfig&) = delete;
// singleton support
AP_BoardConfig *get_instance(void) {
static AP_BoardConfig *get_instance(void) {
return instance;
}
@ -124,6 +124,20 @@ public: @@ -124,6 +124,20 @@ public:
return 0;
#endif
}
#if AP_FEATURE_SAFETY_BUTTON
enum board_safety_button_option {
BOARD_SAFETY_OPTION_BUTTON_ACTIVE_SAFETY_OFF=1,
BOARD_SAFETY_OPTION_BUTTON_ACTIVE_SAFETY_ON=2,
BOARD_SAFETY_OPTION_BUTTON_ACTIVE_ARMED=4,
};
// return safety button options. Bits are in enum board_safety_button_option
uint16_t get_safety_button_options(void) {
return uint16_t(state.safety_option.get());
}
#endif
private:
static AP_BoardConfig *instance;
@ -134,6 +148,7 @@ private: @@ -134,6 +148,7 @@ private:
struct {
AP_Int8 pwm_count;
AP_Int8 safety_enable;
AP_Int16 safety_option;
AP_Int32 ignore_safety_channels;
#if CONFIG_HAL_BOARD == HAL_BOARD_PX4 || CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
AP_Int8 ser1_rtscts;

Loading…
Cancel
Save