diff --git a/libraries/AP_HAL_Linux/ToneAlarm.cpp b/libraries/AP_HAL_Linux/ToneAlarm.cpp index 0f3ec03007..fcc26ddf4d 100644 --- a/libraries/AP_HAL_Linux/ToneAlarm.cpp +++ b/libraries/AP_HAL_Linux/ToneAlarm.cpp @@ -39,7 +39,7 @@ bool ToneAlarm::init() return true; } -void ToneAlarm::set_buzzer_tone(float frequency, float volume) +void ToneAlarm::set_buzzer_tone(float frequency, float volume, uint32_t duration_ms) { if (is_zero(frequency) || is_zero(volume)) { dprintf(run_fd,"0"); diff --git a/libraries/AP_HAL_Linux/ToneAlarm.h b/libraries/AP_HAL_Linux/ToneAlarm.h index 3e4ddf6656..72e3f7d14f 100644 --- a/libraries/AP_HAL_Linux/ToneAlarm.h +++ b/libraries/AP_HAL_Linux/ToneAlarm.h @@ -8,7 +8,7 @@ class ToneAlarm { public: ToneAlarm(); virtual bool init(); - virtual void set_buzzer_tone(float frequency, float volume); + virtual void set_buzzer_tone(float frequency, float volume, uint32_t duration_ms); private: int32_t period_fd; diff --git a/libraries/AP_HAL_Linux/ToneAlarm_Disco.cpp b/libraries/AP_HAL_Linux/ToneAlarm_Disco.cpp index 90ae553f9a..a9fd39f2dc 100644 --- a/libraries/AP_HAL_Linux/ToneAlarm_Disco.cpp +++ b/libraries/AP_HAL_Linux/ToneAlarm_Disco.cpp @@ -20,6 +20,7 @@ #include #include #include "ToneAlarm_Disco.h" +#include extern const AP_HAL::HAL &hal; @@ -34,12 +35,12 @@ bool ToneAlarm_Disco::init() return true; } -void ToneAlarm_Disco::set_buzzer_tone(float frequency, float volume) +void ToneAlarm_Disco::set_buzzer_tone(float frequency, float volume, uint32_t duration_ms) { if (is_zero(frequency) || is_zero(volume)) { bebop_out->play_note(0, 0, 0); } else { - bebop_out->play_note(TONEALARM_PWM_POWER, (uint16_t)roundf(frequency), 10000); + bebop_out->play_note(TONEALARM_PWM_POWER, (uint16_t)roundf(frequency), duration_ms); } } diff --git a/libraries/AP_HAL_Linux/ToneAlarm_Disco.h b/libraries/AP_HAL_Linux/ToneAlarm_Disco.h index 2feb625190..52bf083499 100644 --- a/libraries/AP_HAL_Linux/ToneAlarm_Disco.h +++ b/libraries/AP_HAL_Linux/ToneAlarm_Disco.h @@ -13,7 +13,7 @@ class ToneAlarm_Disco : public ToneAlarm { public: ToneAlarm_Disco(); bool init() override; - void set_buzzer_tone(float frequency, float volume) override; + void set_buzzer_tone(float frequency, float volume, uint32_t duration_ms) override; private: RCOutput_Bebop *bebop_out; diff --git a/libraries/AP_HAL_Linux/Util.cpp b/libraries/AP_HAL_Linux/Util.cpp index c14e695343..378ee0e2c4 100644 --- a/libraries/AP_HAL_Linux/Util.cpp +++ b/libraries/AP_HAL_Linux/Util.cpp @@ -17,7 +17,6 @@ using namespace Linux; extern const AP_HAL::HAL& hal; -static int state; #if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO ToneAlarm_Disco Util::_toneAlarm; #else diff --git a/libraries/AP_HAL_Linux/Util.h b/libraries/AP_HAL_Linux/Util.h index 83ba05bd3a..13ff1801c1 100644 --- a/libraries/AP_HAL_Linux/Util.h +++ b/libraries/AP_HAL_Linux/Util.h @@ -96,7 +96,9 @@ public: int get_hw_arm32(); bool toneAlarm_init() override { return _toneAlarm.init(); } - void toneAlarm_set_buzzer_tone(float frequency, float volume) override { _toneAlarm.set_buzzer_tone(frequency, volume); } + void toneAlarm_set_buzzer_tone(float frequency, float volume, uint32_t duration_ms) override { + _toneAlarm.set_buzzer_tone(frequency, volume, duration_ms); + } private: #if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO