Browse Source

HAL_Linux: added duration to toneAlarm_set_buzzer_tone

required for disco
master
Andrew Tridgell 7 years ago
parent
commit
03b7c08be6
  1. 2
      libraries/AP_HAL_Linux/ToneAlarm.cpp
  2. 2
      libraries/AP_HAL_Linux/ToneAlarm.h
  3. 5
      libraries/AP_HAL_Linux/ToneAlarm_Disco.cpp
  4. 2
      libraries/AP_HAL_Linux/ToneAlarm_Disco.h
  5. 1
      libraries/AP_HAL_Linux/Util.cpp
  6. 4
      libraries/AP_HAL_Linux/Util.h

2
libraries/AP_HAL_Linux/ToneAlarm.cpp

@ -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");

2
libraries/AP_HAL_Linux/ToneAlarm.h

@ -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;

5
libraries/AP_HAL_Linux/ToneAlarm_Disco.cpp

@ -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);
} }
} }

2
libraries/AP_HAL_Linux/ToneAlarm_Disco.h

@ -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;

1
libraries/AP_HAL_Linux/Util.cpp

@ -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

4
libraries/AP_HAL_Linux/Util.h

@ -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…
Cancel
Save