From 23882aaab03613247eb78cc2f9cd5eba117fbb0a Mon Sep 17 00:00:00 2001 From: Peter Barker Date: Fri, 27 Oct 2017 22:08:43 +1100 Subject: [PATCH] AP_Notify: only play not-ready-or-not-finished tone if we've been ready --- libraries/AP_Notify/ToneAlarm_PX4.cpp | 6 +++++- libraries/AP_Notify/ToneAlarm_PX4.h | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libraries/AP_Notify/ToneAlarm_PX4.cpp b/libraries/AP_Notify/ToneAlarm_PX4.cpp index e74f5dab9e..bd1ed9ce20 100644 --- a/libraries/AP_Notify/ToneAlarm_PX4.cpp +++ b/libraries/AP_Notify/ToneAlarm_PX4.cpp @@ -277,8 +277,12 @@ void ToneAlarm_PX4::update() flags.pre_arm_check = AP_Notify::flags.pre_arm_check; if (flags.pre_arm_check) { play_tone(AP_NOTIFY_PX4_TONE_QUIET_READY_OR_FINISHED); + _have_played_ready_tone = true; } else { - play_tone(AP_NOTIFY_PX4_TONE_QUIET_NOT_READY_OR_NOT_FINISHED); + // only play sad tone if we've ever played happy tone: + if (_have_played_ready_tone) { + play_tone(AP_NOTIFY_PX4_TONE_QUIET_NOT_READY_OR_NOT_FINISHED); + } } } diff --git a/libraries/AP_Notify/ToneAlarm_PX4.h b/libraries/AP_Notify/ToneAlarm_PX4.h index 13eaa4f751..565388c422 100644 --- a/libraries/AP_Notify/ToneAlarm_PX4.h +++ b/libraries/AP_Notify/ToneAlarm_PX4.h @@ -62,6 +62,7 @@ private: uint16_t leak_detected : 1; // 1 if leak detected uint16_t powering_off : 1; // 1 if smart battery is powering off } flags; + bool _have_played_ready_tone : 1; int8_t _cont_tone_playing; int8_t _tone_playing;