AP_Notify: add and use AP_NOTIFY_TONEALARM_ENABLED

This commit is contained in:
Peter Barker 2023-04-21 11:35:37 +10:00 committed by Peter Barker
parent 6933000395
commit dfcadfc618
3 changed files with 6 additions and 4 deletions

View File

@ -374,7 +374,7 @@ void AP_Notify::add_backends(void)
// ChibiOS noise makers // ChibiOS noise makers
#if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS #if CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS
ADD_BACKEND(new Buzzer()); ADD_BACKEND(new Buzzer());
#if HAL_PWM_COUNT > 0 || HAL_DSHOT_ALARM_ENABLED #if AP_NOTIFY_TONEALARM_ENABLED
ADD_BACKEND(new AP_ToneAlarm()); ADD_BACKEND(new AP_ToneAlarm());
#endif #endif

View File

@ -48,3 +48,7 @@
#ifndef AP_NOTIFY_NEOPIXEL_ENABLED #ifndef AP_NOTIFY_NEOPIXEL_ENABLED
#define AP_NOTIFY_NEOPIXEL_ENABLED AP_NOTIFY_SERIALLED_ENABLED #define AP_NOTIFY_NEOPIXEL_ENABLED AP_NOTIFY_SERIALLED_ENABLED
#endif #endif
#ifndef AP_NOTIFY_TONEALARM_ENABLED
#define AP_NOTIFY_TONEALARM_ENABLED ((defined(HAL_PWM_ALARM) || HAL_DSHOT_ALARM_ENABLED))
#endif

View File

@ -105,9 +105,7 @@ bool AP_ToneAlarm::init()
if (pNotify->buzzer_enabled() == false) { if (pNotify->buzzer_enabled() == false) {
return false; return false;
} }
#if ((defined(HAL_PWM_ALARM) || defined(HAL_PWM_ALT_ALARM) || HAL_DSHOT_ALARM_ENABLED) && CONFIG_HAL_BOARD == HAL_BOARD_CHIBIOS) || \ #if AP_NOTIFY_TONEALARM_ENABLED
CONFIG_HAL_BOARD == HAL_BOARD_LINUX || \
CONFIG_HAL_BOARD == HAL_BOARD_SITL
if (!hal.util->toneAlarm_init(pNotify->get_buzzer_types())) { if (!hal.util->toneAlarm_init(pNotify->get_buzzer_types())) {
return false; return false;
} }