Skip to content

Commit

Permalink
AP_Notify: add parameter for logic level buzzer sounds at
Browse files Browse the repository at this point in the history
  • Loading branch information
peterbarker committed Mar 5, 2019
1 parent a97c9bd commit f8ac5a5
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
9 changes: 9 additions & 0 deletions libraries/AP_Notify/AP_Notify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
};

Expand Down
2 changes: 2 additions & 0 deletions libraries/AP_Notify/AP_Notify.h
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ class AP_Notify

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:

Expand All @@ -169,6 +170,7 @@ class AP_Notify
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
Expand Down
9 changes: 7 additions & 2 deletions libraries/AP_Notify/Buzzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit f8ac5a5

Please sign in to comment.