mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
Added buzzer circuit breaker.
This commit is contained in:
parent
ca052ac68a
commit
06472861ce
@ -116,6 +116,7 @@
|
||||
#include <stm32_tim.h>
|
||||
|
||||
#include <systemlib/err.h>
|
||||
#include <systemlib/circuit_breaker.h>
|
||||
|
||||
/* Check that tone alarm and HRT timers are different */
|
||||
#if defined(TONE_ALARM_TIMER) && defined(HRT_TIMER)
|
||||
@ -273,6 +274,8 @@
|
||||
# define rDMAR REG(STM32_GTIM_DMAR_OFFSET)
|
||||
#endif
|
||||
|
||||
#define CBRK_BUZZER_KEY 782097
|
||||
|
||||
class ToneAlarm : public device::CDev
|
||||
{
|
||||
public:
|
||||
@ -288,6 +291,12 @@ public:
|
||||
return _tune_names[tune];
|
||||
}
|
||||
|
||||
enum {
|
||||
CBRK_OFF = 0,
|
||||
CBRK_ON,
|
||||
CBRK_UNINIT
|
||||
};
|
||||
|
||||
private:
|
||||
static const unsigned _tune_max = 1024 * 8; // be reasonable about user tunes
|
||||
const char *_default_tunes[TONE_NUMBER_OF_TUNES];
|
||||
@ -307,6 +316,7 @@ private:
|
||||
unsigned _octave;
|
||||
unsigned _silence_length; // if nonzero, silence before next note
|
||||
bool _repeat; // if true, tune restarts at end
|
||||
int _cbrk; //if true, no audio output
|
||||
|
||||
hrt_call _note_call; // HRT callout for note completion
|
||||
|
||||
@ -375,7 +385,8 @@ ToneAlarm::ToneAlarm() :
|
||||
_default_tune_number(0),
|
||||
_user_tune(nullptr),
|
||||
_tune(nullptr),
|
||||
_next(nullptr)
|
||||
_next(nullptr),
|
||||
_cbrk(CBRK_UNINIT)
|
||||
{
|
||||
// enable debug() calls
|
||||
//_debug_enabled = true;
|
||||
@ -537,6 +548,13 @@ ToneAlarm::rest_duration(unsigned rest_length, unsigned dots)
|
||||
void
|
||||
ToneAlarm::start_note(unsigned note)
|
||||
{
|
||||
// check if circuit breaker is enabled
|
||||
if (_cbrk == CBRK_UNINIT) {
|
||||
_cbrk = circuit_breaker_enabled("CBRK_BUZZER", CBRK_BUZZER_KEY);
|
||||
}
|
||||
|
||||
if (_cbrk != CBRK_OFF) { return; }
|
||||
|
||||
// compute the divisor
|
||||
unsigned divisor = note_to_divisor(note);
|
||||
|
||||
|
||||
@ -133,4 +133,17 @@ PARAM_DEFINE_INT32(CBRK_ENGINEFAIL, 284953);
|
||||
* @max 240024
|
||||
* @group Circuit Breaker
|
||||
*/
|
||||
PARAM_DEFINE_INT32(CBRK_GPSFAIL, 240024);
|
||||
PARAM_DEFINE_INT32(CBRK_GPSFAIL, 240024);
|
||||
|
||||
/**
|
||||
* Circuit breaker for disabling buzzer
|
||||
*
|
||||
* Setting this parameter to 782097 will disable the buzzer audio notification.
|
||||
*
|
||||
* WARNING: ENABLING THIS CIRCUIT BREAKER IS AT OWN RISK
|
||||
*
|
||||
* @min 0
|
||||
* @max 782097
|
||||
* @group Circuit Breaker
|
||||
*/
|
||||
PARAM_DEFINE_INT32(CBRK_BUZZER, 0);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user