mirror of https://github.com/ArduPilot/ardupilot
HAL_Linux: added duration to toneAlarm_set_buzzer_tone
required for disco
This commit is contained in:
parent
c83567dcba
commit
03b7c08be6
|
@ -39,7 +39,7 @@ bool ToneAlarm::init()
|
||||||
return true;
|
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)) {
|
if (is_zero(frequency) || is_zero(volume)) {
|
||||||
dprintf(run_fd,"0");
|
dprintf(run_fd,"0");
|
||||||
|
|
|
@ -8,7 +8,7 @@ class ToneAlarm {
|
||||||
public:
|
public:
|
||||||
ToneAlarm();
|
ToneAlarm();
|
||||||
virtual bool init();
|
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:
|
private:
|
||||||
int32_t period_fd;
|
int32_t period_fd;
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <AP_HAL_Linux/RCOutput_Bebop.h>
|
#include <AP_HAL_Linux/RCOutput_Bebop.h>
|
||||||
#include <AP_HAL_Linux/RCOutput_Disco.h>
|
#include <AP_HAL_Linux/RCOutput_Disco.h>
|
||||||
#include "ToneAlarm_Disco.h"
|
#include "ToneAlarm_Disco.h"
|
||||||
|
#include <AP_Math/AP_Math.h>
|
||||||
|
|
||||||
extern const AP_HAL::HAL &hal;
|
extern const AP_HAL::HAL &hal;
|
||||||
|
|
||||||
|
@ -34,12 +35,12 @@ bool ToneAlarm_Disco::init()
|
||||||
return true;
|
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)) {
|
if (is_zero(frequency) || is_zero(volume)) {
|
||||||
bebop_out->play_note(0, 0, 0);
|
bebop_out->play_note(0, 0, 0);
|
||||||
} else {
|
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,7 @@ class ToneAlarm_Disco : public ToneAlarm {
|
||||||
public:
|
public:
|
||||||
ToneAlarm_Disco();
|
ToneAlarm_Disco();
|
||||||
bool init() override;
|
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:
|
private:
|
||||||
RCOutput_Bebop *bebop_out;
|
RCOutput_Bebop *bebop_out;
|
||||||
|
|
|
@ -17,7 +17,6 @@ using namespace Linux;
|
||||||
|
|
||||||
extern const AP_HAL::HAL& hal;
|
extern const AP_HAL::HAL& hal;
|
||||||
|
|
||||||
static int state;
|
|
||||||
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO
|
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO
|
||||||
ToneAlarm_Disco Util::_toneAlarm;
|
ToneAlarm_Disco Util::_toneAlarm;
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -96,7 +96,9 @@ public:
|
||||||
int get_hw_arm32();
|
int get_hw_arm32();
|
||||||
|
|
||||||
bool toneAlarm_init() override { return _toneAlarm.init(); }
|
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:
|
private:
|
||||||
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO
|
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_DISCO
|
||||||
|
|
Loading…
Reference in New Issue