diff --git a/libraries/AP_Notify/AP_Notify.cpp b/libraries/AP_Notify/AP_Notify.cpp index 241c646a74..e3170d8d20 100644 --- a/libraries/AP_Notify/AP_Notify.cpp +++ b/libraries/AP_Notify/AP_Notify.cpp @@ -147,6 +147,15 @@ const AP_Param::GroupInfo AP_Notify::var_info[] = { // @User: Advanced AP_GROUPINFO("LED_TYPES", 6, AP_Notify, _led_type, BUILD_DEFAULT_LED_TYPE), +#if !defined(HAL_BUZZER_PIN) + // @Param: BUZZ_ON_LVL + // @DisplayName: Buzzer-on pin logic level + // @Description: Specifies pin level that indicates buzzer should play + // @Values: 0:LowIsOn,1:HighIsOn + // @User: Advanced + AP_GROUPINFO("BUZZ_ON_LVL", 7, AP_Notify, _buzzer_level, 1), +#endif + AP_GROUPEND }; diff --git a/libraries/AP_Notify/AP_Notify.h b/libraries/AP_Notify/AP_Notify.h index 4a3695ca6e..b99f38d73b 100644 --- a/libraries/AP_Notify/AP_Notify.h +++ b/libraries/AP_Notify/AP_Notify.h @@ -151,6 +151,7 @@ public: static const struct AP_Param::GroupInfo var_info[]; uint8_t get_buzz_pin() const { return _buzzer_pin; } + uint8_t get_buzz_level() const { return _buzzer_level; } private: @@ -169,6 +170,7 @@ private: AP_Int8 _oreo_theme; AP_Int8 _buzzer_pin; AP_Int32 _led_type; + AP_Int8 _buzzer_level; char _send_text[NOTIFY_TEXT_BUFFER_SIZE]; uint32_t _send_text_updated_millis; // last time text changed diff --git a/libraries/AP_Notify/Buzzer.cpp b/libraries/AP_Notify/Buzzer.cpp index 176df66926..8fca649657 100644 --- a/libraries/AP_Notify/Buzzer.cpp +++ b/libraries/AP_Notify/Buzzer.cpp @@ -22,8 +22,13 @@ #include "AP_Notify.h" #ifndef HAL_BUZZER_ON - #define HAL_BUZZER_ON 1 - #define HAL_BUZZER_OFF 0 + #if !defined(HAL_BUZZER_PIN) + #define HAL_BUZZER_ON (pNotify->get_buzz_level()) + #define HAL_BUZZER_OFF (!pNotify->get_buzz_level()) + #else + #define HAL_BUZZER_ON 1 + #define HAL_BUZZER_OFF 0 + #endif #endif