Give priority to power off tune over other tunes (e.g. Battery Low)

Make Power Off tune not interruptable

This solves the case of Low Battery warning tune overriding the power
off tune, as now the Power off tune is not interruptable by any other
tune unless override flag is specified

commander_helper: resolve "redundant boolean literal in ternary expression result"
This commit is contained in:
Junwoo Hwang
2022-07-08 14:51:15 +02:00
committed by Matthias Grob
parent 652b153383
commit f66c3914f6
3 changed files with 6 additions and 8 deletions
+1 -1
View File
@@ -104,4 +104,4 @@ PX4_DEFINE_TUNE(15, SD_ERROR, "MNBG",
PX4_DEFINE_TUNE(16, PROG_PX4IO, "MLL32CP8MB", false /* Program PX4IO */)
PX4_DEFINE_TUNE(17, PROG_PX4IO_OK, "MLL8CDE", false /* Program PX4IO success */)
PX4_DEFINE_TUNE(18, PROG_PX4IO_ERR, "ML<<CP4CP4CP4CP4CP4", true /* Program PX4IO fail */)
PX4_DEFINE_TUNE(19, POWER_OFF, "MFT255a8g8f8e8c8<b8a8g4", true /* When pressing off button */)
PX4_DEFINE_TUNE(19, POWER_OFF, "MFT255a8g8f8e8c8<b8a8g4", false /* When pressing off button */)
+3 -5
View File
@@ -107,13 +107,11 @@ static_assert(sizeof(actuator_armed_s) == 16, "actuator_armed equality operator
#if defined(BOARD_HAS_POWER_CONTROL)
static orb_advert_t tune_control_pub = nullptr;
static void play_power_button_down_tune()
{
tune_control_s tune_control{};
tune_control.volume = tune_control_s::VOLUME_LEVEL_DEFAULT;
tune_control.tune_id = tune_control_s::TUNE_ID_POWER_OFF;
tune_control.timestamp = hrt_absolute_time();
orb_publish(ORB_ID(tune_control), tune_control_pub, &tune_control);
// Override any other tunes because power-off sound should have the priority
set_tune_override(tune_control_s::TUNE_ID_POWER_OFF);
}
static void stop_tune()
+2 -2
View File
@@ -177,8 +177,8 @@ void set_tune(const int tune_id)
{
const hrt_abstime current_time = hrt_absolute_time();
const unsigned int new_tune_duration = tune_durations[tune_id];
const bool current_tune_is_repeating = (tune_end == 0) ? true : false;
const bool new_tune_is_repeating = (new_tune_duration == 0) ? true : false;
const bool current_tune_is_repeating = (tune_end == 0);
const bool new_tune_is_repeating = (new_tune_duration == 0);
bool set_new_tune = false;